-
Notifications
You must be signed in to change notification settings - Fork 311
feat(hip-3-pusher): Mark price support #3206
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| def get_price_from_oracle_mid_average(self, symbol: str, oracle_update: OracleUpdate): | ||
| oracle_price = oracle_update.oracle.get(symbol) | ||
| if oracle_price is None: | ||
| return None | ||
|
|
||
| mid_price_update: PriceUpdate | None = self.hl_mid_state.get(symbol) | ||
| if mid_price_update is None: | ||
| logger.warning("mid price for {} is missing", symbol) | ||
| return None | ||
| time_diff = mid_price_update.time_diff(time.time()) | ||
| if time_diff >= self.stale_price_threshold_seconds: | ||
| logger.warning("mid price for {} is stale by {} seconds", symbol, time_diff) | ||
| return None | ||
|
|
||
| return (float(oracle_price) + float(mid_price_update.price)) / 2.0 |
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 logic is simple for now, but maybe you want to generate a quick unit test anyway?
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.
As per Slack discussion, need to improve testing, will put in a separate PR.
Summary
Support mark price as mean(oracle, mid).
Rationale
How has this been tested?