fix: use Any in JSONDict to resolve ty type-check errors#84
Conversation
|
Codex Infinity Start a task on this PR's branch by commenting:
Tasks and logs: https://codex-infinity.com |
There was a problem hiding this comment.
💡 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) |
There was a problem hiding this comment.
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 👍 / 👎.
9d843ec to
2430b52
Compare
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>
2430b52 to
2671b43
Compare
Summary
JSONDicttype alias fromdict[str, object]todict[str, Any]inrl_trading_agent_binance/trade_binance_live.pytytype-check errors (invalid-argument-type) whereobjectvalues from dict access were passed tofloat(), which expectsConvertibleToFloatdict[str, Any]is the standard typing for JSON data in PythonTest plan
ty checklocally on all CI-checked files — all checks passed🤖 Generated with Claude Code