-
Notifications
You must be signed in to change notification settings - Fork 31
Correctly call live/historic prices for rest #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Here's the code health analysis summary for commits Analysis Summary
Code Coverage Report
|
777459b to
6727d4f
Compare
|
|
||
| def get_closes_websocket(self, trade_pairs: List[TradePair], trade_pair_to_last_order_time_ms) -> dict[str: PriceSource]: | ||
| def get_closes_websocket(self, trade_pairs: List[TradePair], time_ms) -> dict[str: PriceSource]: | ||
| events = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice cleanup!
|
|
||
| def time_delta_from_now_ms(self, now_ms: int) -> int: | ||
| def time_delta_from_now_ms(self, now_ms:int = None) -> int: | ||
| if not now_ms: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix. this could have caused errors
neurons/validator.py
Outdated
| ) | ||
|
|
||
| price_sources = self.live_price_fetcher.get_sorted_price_sources_for_trade_pair(trade_pair, now_ms) | ||
| price_sources = self.live_price_fetcher.get_sorted_price_sources_for_trade_pair(trade_pair) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not pass the time from before? It is the closest timestamp to the order received time as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data services check whether or not there is any value assigned to time_ms, so even if the timestamp is right now, it will try to retrieve historical data. It looked like the validator was trying to fetch live data, so to call the same endpoint live endpoint it called before, I passed in None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of this code segment is to get the price closest to the price when the order was received by the validator. That's why the code passed "now_ms" to get_sorted_price_sources_for_trade_pair. By using the current time, it will be a little bit in the future compared to when the order was placed.
| bars_df = cls.get_bars_with_features(trade_pair, processed_ms, adv_lookback_window, calc_vol_window) | ||
| row_selected = bars_df.iloc[-1] | ||
| annualized_volatility = row_selected['annualized_vol'] | ||
| annualized_volatility = row_selected['annualized_vol'] # recalculate slippage false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure what this comment means
neurons/backtest_manager.py
Outdated
| secrets = ValiUtils.get_secrets() # {'polygon_apikey': '123', 'tiingo_apikey': '456'} | ||
| btm = BacktestManager(hk_to_positions, start_time_ms, secrets, None, capital=500_000, | ||
| use_slippage=True, fetch_slippage_data=False, recalculate_slippage=False, | ||
| use_slippage=True, fetch_slippage_data=True, recalculate_slippage=True, # recalculate slippage fetch slippage data originally false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these changes necessary or is it only for the local testing
35ed251 to
6deb4ef
Compare
02765d7 to
5671c2a
Compare
🤖 Claude AI Code ReviewLast reviewed on: 09:43:27 SummaryThis PR refactors the price fetching mechanism to properly distinguish between live and historical price queries. The main changes unify timestamp handling across trade pairs and explicitly pass ✅ Strengths
|
Taoshi Pull Request
Description
Pass order time for historic price calls / pass None for live price calls to data services.
Order times are unified to one timestamp for each trade pair.
Related Issues (JIRA)
[Reference any related issues or tasks that this pull request addresses or closes.]
Checklist
Reviewer Instructions
[Provide any specific instructions or areas you would like the reviewer to focus on.]
Definition of Done
Checklist (for the reviewer)
Optional: Deploy Notes
[Any instructions or notes related to deployment, if applicable.]
/cc @mention_reviewer