feat: 改进价格预测模型并修复API错误#1
Conversation
本次提交包含两项主要更新:
1. **功能**: 增强了价格预测模型。交易流(Trade Flow)对价格的影响现在会根据市场波动率进行动态缩放。
* 引入了 TRADE_FLOW_VOLATILITY_SCALING 作为新的可配置参数。
* 在市场平稳时,交易流的影响力会增强;在市场波动剧烈时,其影响力会减弱,以提高策略的稳定性。
2. **修复**: 解决了在处理Polymarket API返回的每日奖励数据时,因无效的数字格式而导致的程序崩溃问题 (decimal.InvalidOperation)。代码现在可以更安全地处理API的异常返回值。
There was a problem hiding this comment.
Code Review
This pull request introduces a normalized volatility calculation and a configurable trade_flow_volatility_scaling parameter to scale trade flow adjustments in AdvancedPredictor. It also adds error handling for decimal conversions in polymarket_adapter.py. The review feedback identifies a critical issue in polymarket_adapter.py where attempting to catch decimal.InvalidOperation will raise a NameError because the decimal module is not imported. It is recommended to catch ValueError instead, which already covers InvalidOperation.
There was a problem hiding this comment.
Code Review
This pull request introduces a volatility-scaled trade flow adjustment to the advanced predictor, allowing the trading bot to scale the impact of trade flow based on market volatility. It also adds robust exception handling when parsing reward estimates in the Polymarket adapter. A critical issue was identified in the adapter's exception handling where referencing decimal.InvalidOperation without importing the decimal module would raise a NameError, and a suggestion was provided to catch ArithmeticError instead.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0ce2cac57
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return Decimal(str(result or "0")) | ||
| try: | ||
| return Decimal(str(value)) | ||
| except (ValueError, decimal.InvalidOperation): |
There was a problem hiding this comment.
Import InvalidOperation before handling reward parse failures
The new exception handler in today_rewards_estimate catches decimal.InvalidOperation, but decimal is never imported in this module. When the API returns a malformed numeric value (the exact case this patch intends to handle), Python raises a NameError while evaluating the except clause, so the method still crashes instead of returning Decimal("0").
Useful? React with 👍 / 👎.
| self, | ||
| impact_bps_per_imbalance: Decimal, | ||
| min_confidence: Decimal, | ||
| trade_flow_volatility_scaling: Decimal, |
There was a problem hiding this comment.
Preserve AdvancedPredictor constructor compatibility
Making trade_flow_volatility_scaling a required constructor argument introduces a runtime TypeError for callers still using the previous two-argument API. In this repo, tests/test_strategy_components.py still constructs AdvancedPredictor without the new parameter, so this commit breaks that execution path unless a default is provided or all callers are updated.
Useful? React with 👍 / 👎.
Co-authored-by: pm-gemini-code-assist[bot] <287756688+pm-gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
🤖 Hi @Jerryy959, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
🤖 Hi @Jerryy959, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
🤖 Hi @Jerryy959, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
🤖 Hi @Jerryy959, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
This change automatically trusts the workspace when the gemini-review workflow runs. This prevents the workflow from halting on an interactive prompt in a non-interactive CI environment.
|
🤖 Hi @Jerryy959, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
…ty-scaling feat: 改进价格预测模型并修复API错误
本次提交包含两项主要更新:
功能: 增强了价格预测模型。交易流(Trade Flow)对价格的影响现在会根据市场波动率进行动态缩放。
修复: 解决了在处理Polymarket API返回的每日奖励数据时,因无效的数字格式而导致的程序崩溃问题 (decimal.InvalidOperation)。代码现在可以更安全地处理API的异常返回值。