Skip to content

Commit

Permalink
Allow quote sources to update independently of price sources being up…
Browse files Browse the repository at this point in the history
…dated
  • Loading branch information
jbonilla-tao committed Feb 24, 2025
1 parent 9e6fa58 commit 5cd6ad5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions vali_objects/utils/mdd_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion vali_objects/vali_dataclasses/price_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 3 additions & 1 deletion vali_objects/vali_dataclasses/quote_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 5cd6ad5

Please sign in to comment.