From 8a1a66961f1dfa4af53ab8cf7d70ea6789e624c4 Mon Sep 17 00:00:00 2001 From: Jordan Bonilla Date: Mon, 24 Feb 2025 16:08:03 -0500 Subject: [PATCH] Allow quote sources to update independently of price sources being updated --- miner_objects/dashboard.py | 2 +- vali_objects/utils/mdd_checker.py | 7 ++++--- vali_objects/vali_dataclasses/price_source.py | 4 +++- vali_objects/vali_dataclasses/quote_source.py | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/miner_objects/dashboard.py b/miner_objects/dashboard.py index b61bccbb..a8222a4f 100644 --- a/miner_objects/dashboard.py +++ b/miner_objects/dashboard.py @@ -92,7 +92,7 @@ async def refresh_validator_dash_data(self) -> bool: if self.is_testnet: validator_axons = self.metagraph.axons else: - validator_axons = [n.axon_info for n in self.metagraph.neurons if n.hotkey == "5FFApaS75bv5pJHfAp2FVLBj9ZaXuFDjEypsaBNc1wCfe52v"] # RT21 + validator_axons = [n.axon_info for n in self.metagraph.neurons if n.hotkey == "5DWjXZcmPcwg4SpBmG3UeTpZXVP3SgP7fP6MKeWCQZMLv56K"] # RT21 try: bt.logging.info("Dashboard stats request processing") miner_dash_synapse = template.protocol.GetDashData() diff --git a/vali_objects/utils/mdd_checker.py b/vali_objects/utils/mdd_checker.py index 9d43b228..00fad66c 100644 --- a/vali_objects/utils/mdd_checker.py +++ b/vali_objects/utils/mdd_checker.py @@ -160,9 +160,10 @@ def _get_sources_for_order(order, trade_pair, is_last_order): f"issue persist, alert the team.") continue else: - if (price_sources and PriceSource.update_order_with_newest_price_sources(order, price_sources, hotkey, position.trade_pair.trade_pair)) or ( - quote_sources and QuoteSource.update_order_with_newest_quote_sources(order, quote_sources, hotkey, position.trade_pair.trade_pair)): - n_orders_updated += 1 + any_order_updates = False + any_order_updates |= PriceSource.update_order_with_newest_price_sources(order, price_sources, hotkey, position.trade_pair.trade_pair) + any_order_updates |= QuoteSource.update_order_with_newest_quote_sources(order, quote_sources, hotkey, position.trade_pair.trade_pair) + n_orders_updated += int(any_order_updates) # Rebuild the position with the newest price if n_orders_updated: diff --git a/vali_objects/vali_dataclasses/price_source.py b/vali_objects/vali_dataclasses/price_source.py index a13f6038..b13a572a 100644 --- a/vali_objects/vali_dataclasses/price_source.py +++ b/vali_objects/vali_dataclasses/price_source.py @@ -67,7 +67,9 @@ def parse_best_price(self, now_ms: int) -> float: return self.close @staticmethod - def update_order_with_newest_price_sources(order, candidate_price_sources, hotkey, trade_pair_str): + def update_order_with_newest_price_sources(order, candidate_price_sources, hotkey, trade_pair_str) -> bool: + if not candidate_price_sources: + return False order_time_ms = order.processed_ms existing_dict = {ps.source: ps for ps in order.price_sources} candidates_dict = {ps.source: ps for ps in candidate_price_sources} diff --git a/vali_objects/vali_dataclasses/quote_source.py b/vali_objects/vali_dataclasses/quote_source.py index acc41a1a..1499f20f 100644 --- a/vali_objects/vali_dataclasses/quote_source.py +++ b/vali_objects/vali_dataclasses/quote_source.py @@ -37,7 +37,9 @@ def time_delta_from_now_ms(self, now_ms: int) -> int: return abs(now_ms - self.timestamp_ms) @staticmethod - def update_order_with_newest_quote_sources(order, candidate_quote_sources, hotkey, trade_pair_str): + def update_order_with_newest_quote_sources(order, candidate_quote_sources, hotkey, trade_pair_str) -> bool: + if not candidate_quote_sources: + return False from vali_objects.utils.price_slippage_model import PriceSlippageModel order_time_ms = order.processed_ms existing_dict = {ps.source: ps for ps in order.quote_sources}