Skip to content

fix: use Any in JSONDict to resolve ty type-check errors#84

Open
lee101 wants to merge 1 commit into
mainfrom
ci-fix/stock-prediction-type-check
Open

fix: use Any in JSONDict to resolve ty type-check errors#84
lee101 wants to merge 1 commit into
mainfrom
ci-fix/stock-prediction-type-check

Conversation

@lee101

@lee101 lee101 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Changed JSONDict type alias from dict[str, object] to dict[str, Any] in rl_trading_agent_binance/trade_binance_live.py
  • This fixes all 7 ty type-check errors (invalid-argument-type) where object values from dict access were passed to float(), which expects ConvertibleToFloat
  • dict[str, Any] is the standard typing for JSON data in Python

Test plan

  • Ran ty check locally on all CI-checked files — all checks passed
  • Verified the change is a single-line type alias fix with no runtime behavior change

🤖 Generated with Claude Code

@lee101

lee101 commented Apr 6, 2026

Copy link
Copy Markdown
Owner Author

Codex Infinity
Hi! I'm Codex Infinity, your coding agent for this repo.

Start a task on this PR's branch by commenting:

Tasks and logs: https://codex-infinity.com

@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: 9d843ec48d

ℹ️ 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".


def _get_market_price(sym_cfg: BinanceSymbolConfig, execution_mode: str) -> float:
return float(binance_wrapper.get_symbol_price(_execution_pair(sym_cfg, execution_mode)))
return float(binance_wrapper.get_symbol_price(_execution_pair(sym_cfg, execution_mode)) or 0.0)

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 Preserve price-fetch failure signal in _get_market_price

Falling back to 0.0 here turns a transient Binance price-fetch failure (None) into a valid-looking price, which changes control flow in callers that relied on an exception to skip trading that symbol. In run_trading_cycle, a 0.0 price can zero out position_value and clear position_qty for risk checks, then proceed to new-buy logic as if no position exists, leading to over-allocation during API outages instead of safely skipping the symbol.

Useful? React with 👍 / 👎.

@lee101 lee101 force-pushed the ci-fix/stock-prediction-type-check branch from 9d843ec to 2430b52 Compare April 12, 2026 09:34
@lee101 lee101 changed the title fix: handle None return from get_symbol_price to pass ty type-check CI fix: use Any in JSONDict to resolve ty type-check errors Apr 12, 2026
The `ty` type checker reports `invalid-argument-type` errors when
`dict[str, object]` values are passed to `float()`, since `object` is
not assignable to `ConvertibleToFloat`. Changing to `dict[str, Any]`
is semantically correct for JSON data and resolves all 7 errors in
trade_binance_live.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lee101 lee101 force-pushed the ci-fix/stock-prediction-type-check branch from 2430b52 to 2671b43 Compare April 13, 2026 02:09
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