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}