Skip to content

feat: 改进价格预测模型并修复API错误#1

Merged
Jerryy959 merged 4 commits into
mainfrom
feat/predict-fix-and-volatility-scaling
May 25, 2026
Merged

feat: 改进价格预测模型并修复API错误#1
Jerryy959 merged 4 commits into
mainfrom
feat/predict-fix-and-volatility-scaling

Conversation

@Jerryy959

Copy link
Copy Markdown
Member

本次提交包含两项主要更新:

  1. 功能: 增强了价格预测模型。交易流(Trade Flow)对价格的影响现在会根据市场波动率进行动态缩放。

    • 引入了 TRADE_FLOW_VOLATILITY_SCALING 作为新的可配置参数。
    • 在市场平稳时,交易流的影响力会增强;在市场波动剧烈时,其影响力会减弱,以提高策略的稳定性。
  2. 修复: 解决了在处理Polymarket API返回的每日奖励数据时,因无效的数字格式而导致的程序崩溃问题 (decimal.InvalidOperation)。代码现在可以更安全地处理API的异常返回值。

本次提交包含两项主要更新:

1.  **功能**: 增强了价格预测模型。交易流(Trade Flow)对价格的影响现在会根据市场波动率进行动态缩放。
    *   引入了 TRADE_FLOW_VOLATILITY_SCALING 作为新的可配置参数。
    *   在市场平稳时,交易流的影响力会增强;在市场波动剧烈时,其影响力会减弱,以提高策略的稳定性。

2.  **修复**: 解决了在处理Polymarket API返回的每日奖励数据时,因无效的数字格式而导致的程序崩溃问题 (decimal.InvalidOperation)。代码现在可以更安全地处理API的异常返回值。

@pm-gemini-code-assist pm-gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread polymarket_adapter.py

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread polymarket_adapter.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread polymarket_adapter.py Outdated
return Decimal(str(result or "0"))
try:
return Decimal(str(value))
except (ValueError, decimal.InvalidOperation):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-cli /review 帮我回答以及修复这个问题

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-cli /review 帮我回答以及修复这个问题

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-cli /review 帮我回答以及修复这个问题

Comment thread advanced_predictors.py
self,
impact_bps_per_imbalance: Decimal,
min_confidence: Decimal,
trade_flow_volatility_scaling: Decimal,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-cli /review 帮我回答以及修复这个问题

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-cli /review 帮我回答以及修复这个问题

Jerryy959 and others added 2 commits May 26, 2026 01:24
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>
@github-actions

Copy link
Copy Markdown

🤖 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.

@github-actions

Copy link
Copy Markdown

🤖 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.

@github-actions

Copy link
Copy Markdown

🤖 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.

@github-actions

Copy link
Copy Markdown

🤖 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.
@github-actions

Copy link
Copy Markdown

🤖 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.

@Jerryy959
Jerryy959 merged commit ec36f60 into main May 25, 2026
12 of 13 checks passed
@Jerryy959
Jerryy959 deleted the feat/predict-fix-and-volatility-scaling branch May 25, 2026 18:18
Jerryy959 added a commit that referenced this pull request May 27, 2026
…ty-scaling

feat: 改进价格预测模型并修复API错误
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant