From d459580e40168dc2e470b9f35288bd7070212080 Mon Sep 17 00:00:00 2001 From: Thykof Date: Tue, 16 Dec 2025 20:01:30 +0100 Subject: [PATCH] refactor: should_skip_xau --- neurons/validator.py | 13 ------------- synth/utils/opening_hours.py | 24 ------------------------ tests/test_validator.py | 19 ------------------- 3 files changed, 56 deletions(-) delete mode 100644 synth/utils/opening_hours.py diff --git a/neurons/validator.py b/neurons/validator.py index cd3fc2ae..3ea08932 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -32,7 +32,6 @@ round_time_to_minutes, ) from synth.utils.logging import setup_gcp_logging -from synth.utils.opening_hours import should_skip_xau from synth.validator.forward import ( calculate_moving_average_and_update_rewards, calculate_scores, @@ -162,11 +161,6 @@ def select_asset( latest_index = asset_list.index(latest_asset) asset = asset_list[(latest_index + 1) % len(asset_list)] - future_start_time = get_current_time() + timedelta(seconds=delay) - future_start_time = round_time_to_minutes(future_start_time) - if should_skip_xau(future_start_time) and asset == "XAU": - asset = asset_list[(asset_list.index("XAU") + 1) % len(asset_list)] - return asset def cycle_low_frequency(self, asset: str): @@ -214,13 +208,6 @@ def forward_prompt(self, asset: str, prompt_config: PromptConfig): request_time, prompt_config.timeout_extra_seconds ) - if should_skip_xau(start_time) and asset == "XAU": - bt.logging.info( - "Skipping XAU simulation as market is closed", - "forward_prompt", - ) - return - simulation_input = SimulationInput( asset=asset, start_time=start_time.isoformat(), diff --git a/synth/utils/opening_hours.py b/synth/utils/opening_hours.py deleted file mode 100644 index 21ec3a53..00000000 --- a/synth/utils/opening_hours.py +++ /dev/null @@ -1,24 +0,0 @@ -import pytz -from datetime import datetime, timedelta - - -def should_skip_xau(start_time: datetime) -> bool: - """ - Determines whether to skip the XAU (Gold) market based on the current time. - - Returns: - bool: True if the XAU market should be skipped, False otherwise. - """ - ny_time = start_time.astimezone(pytz.timezone("America/New_York")) - - # Find the most recent Friday at 17:00 - days_since_friday = (ny_time.weekday() - 4) % 7 # Friday is 4 - last_friday = (ny_time - timedelta(days=days_since_friday)).replace( - hour=17, minute=0, second=0, microsecond=0 - ) - - # Saturday at 17:00 following most recent Friday 17:00 - saturday_17 = last_friday + timedelta(days=1) - - # Check if current time is between Friday 17:00 and Saturday 17:00 - return last_friday <= ny_time < saturday_17 diff --git a/tests/test_validator.py b/tests/test_validator.py index 508ade5a..93a13325 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -54,22 +54,3 @@ def test_select_asset(self): latest_asset, asset_list, 0 ) self.assertEqual(selected_asset, "LTC") - - def test_select_asset_gold(self): - latest_asset = "ETH" - asset_list = ["BTC", "ETH", "XAU", "LTC"] - - with patch( - "neurons.validator.get_current_time" - ) as mock_get_current_time: - mock_get_current_time.return_value = datetime( - 2025, 12, 3, 12, 36, 30, tzinfo=timezone.utc - ) - with patch( - "neurons.validator.should_skip_xau" - ) as mock_should_skip_xau: - mock_should_skip_xau.return_value = True - selected_asset = Validator.select_asset( - latest_asset, asset_list, 0 - ) - self.assertEqual(selected_asset, "LTC")