BUG: Fix simulation correctness bugs in slippage, cancel policy, and order params#316
Open
pandashark wants to merge 1 commit intostefan-jansen:mainfrom
Open
BUG: Fix simulation correctness bugs in slippage, cancel policy, and order params#316pandashark wants to merge 1 commit intostefan-jansen:mainfrom
pandashark wants to merge 1 commit intostefan-jansen:mainfrom
Conversation
…order params Fix execute_daily_cancel_policy to cancel all orders for all assets, not just the first order when multiple are open. Fix NoSlippage and FixedSlippage to use order.open_amount instead of order.amount. Fix VolumeShareSlippage to return (None, None) on null price. Wrap before_trading_start in try/finally to reset _in_before_trading_start flag on exception. Use 'is not None' for limit_price/stop_price checks to allow price of 0.0. Closes stefan-jansen#313
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.
Summary
Fixes 5 simulation correctness bugs that can produce incorrect backtest results:
execute_daily_cancel_policyonly cancelled the first order per asset and skipped assets with a single order entirely. Replaced inline logic withcancel_all_orders_for_asset().NoSlippageandFixedSlippageusedorder.amountinstead oforder.open_amount, overfilling partially filled orders.VolumeShareSlippagereturned bareNoneon NaN price instead of(None, None), causingTypeErrorduring tuple unpacking.before_trading_startdidn't reset_in_before_trading_starton exception, permanently blocking orders.limit_price/stop_priceused truthiness checks, treating0.0as falsy and silently converting toMarketOrder.Closes #313
Test plan
test_eod_order_cancel_dailyto match corrected EODCancel behavior