Repository navigation
Conversation
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
polakowo
requested changes
Nov 11, 2026
polakowo
left a comment
Owner
There was a problem hiding this comment.
Thanks for the PR! With vectorbt-rust 1.2.0, AvgEntryPrice silently behaves as Close: your [100, 50, 80, 90] example exits at bar 2 instead of bar 3. Please gate the new native capability and fall back to Numba (or reject it clearly) on older wheels, with a released-wheel regression test. Please also cover partial closes, reversals and cash sharing on both engines.
Author
|
Could a maintainer take a look at this when you get a chance? The change adds StopEntryPrice.AvgEntryPrice so an averaged-into position seeds its stop from the running average entry price instead of the latest fill (closes #711). Happy to adjust the approach or add coverage wherever you'd like. |
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.
Closes #711
When a position accumulates,
upon_stop_update="override"re-bases the stop on the latest entry price. For an averaged-into position, that ties the stop to the most recent (and potentially extreme) fill rather than the position's actual cost basis.This adds
StopEntryPrice.AvgEntryPriceas an explicit option that seeds the initial SL/TP stop price from the running average entry price of the current position:simulate_from_signals_nbandsimulate_from_signal_func_nbtrack the per-column average entry price (set on open/reversal, volume-weighted on increase, unchanged on partial close)simulate_from_signals_non_shared_innerandsimulate_from_signals_innerCloseremains the default,upon_stop_update="override"still re-seeds the stop when the position increases (now from the average entry price), and"keep"retains the original stopTests:
test_stop_entry_price_avg_entrycovers TP and SL stops for accumulating long and short positions, the behavioral difference against the defaultClosebasis, andupon_stop_update="keep". The fulltests/test_portfolio.pysuite passes (219 tests), and the numba and Rust engines produce identical order records on the new scenarios.