Repository navigation
fix(backtests): keep a pipeline order's zero confidence instead of reading it as 0.75 - #673
Open
subidhkhanal wants to merge 1 commit into
Open
subidhkhanal wants to merge 1 commit into
subidhkhanal wants to merge 1 commit into
Conversation
…ading it as 0.75 pipeline_output_to_decision read an order's confidence as float(value or 0.75), so confidence 0 became 0.75, passed the 0.3 floor and traded. Only a missing or empty confidence now takes the 0.75 default.
Contributor
|
@subidhkhanal is attempting to deploy a commit to the allan-feng's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
pipeline_output_to_decision(infrastructure/llm/pipeline_runner.py,ordersbranch) read an order's confidence as:The
or 0.75was meant as a default for a missing confidence. In Python,0 or 0.75is0.75, though, because 0 is falsy. So a pipeline order withconfidence: 0("not confident at all") was read as 0.75, passed the 0.3 floor inmake_trading_decision_with_llmand traded.Reproduced on
mainbefore the fix. Running a pipeline reply of{"orders": [{"symbol": "AAPL", "side": "buy", "qty": 10, "confidence": 0}]}throughPortfolioManager.make_trading_decision_with_llmplaced the buy:The fix
Only a missing (
None) or empty ("") confidence takes the 0.75 default; a real0is kept:Missing and empty confidence behave exactly as before. Non-numeric confidence (e.g.
"high") is also unchanged: it still raises, which is #663's scope and is left for that issue.Tests
test_pipeline_runner.py::test_pipeline_order_with_zero_confidence_keeps_it: confidence 0 stays 0.0, and a missing confidence is still 0.75.test_portfolio_manager_move.py::test_pipeline_order_with_zero_confidence_does_not_trade: end to end, a zero-confidence pipeline order produces no action.main(assert 0.75 == 0.0, and the buy above) and pass with the fix.tests/infrastructure/llm,tests/backtesting,tests/domain/backtesting,tests/conformance): 1133 passed, 0 failed.Related: #663 quotes the same line, for non-numeric values raising. This PR does not close it.