Reuse the Python callback method-name string and expose constant-time position count and presence. Preserve dynamic callbacks, Bar identity, and snapshot behavior with regression tests.
Add isolated callback measurements and replace approximate cross-library comparisons with matched trades and equity assertions, separate setup/run timings, and reproducible reports. Track the remaining ingestion bottleneck in #53.
Refs #48, #38, #39, #53
Codex 🤖, On behalf of Khizar
Reject invalid numeric inputs at Python boundaries before account mutation or grid workers start. Preserve partial-close no-ops and profit-locking stops, and reject invalid native SMA windows without panicking.
Refs #16
Codex 🤖, On behalf of Khizar
Process opening SL/TP triggers before intrabar range touches, preserving midpoint triggers and exit costs. Add regression coverage and document execution and migration behavior.
Refs #8
Codex 🤖, On behalf of Khizar
Adds two Broker methods for path-dependent strategies:
- close_partial(id, lot_size) scales out of a position and leaves the
remainder open under the same id, so it can keep being managed.
- update_sl(id, stop_loss) moves the stop in place. A trailing stop no
longer has to close and reopen, which paid spread and commission on
every step.
Both are reachable from Python as Strategy.close_partial and
Strategy.update_sl.
Closing a position, part of one, or the whole book previously repeated
the same PnL and commission arithmetic in four places. That is now one
settle() helper taking the number of lots to close, so a partial close
is the same code with a smaller number and the feature made broker.rs
shorter rather than longer.
Commission splits across the legs: the entry was charged on the full
size when the position opened, so settle only takes the exit leg for
the lots being closed. Two 0.5 closes land on the same cash as one 1.0
close, which is what closing_partially_twice_matches_closing_once pins.
update_sl deliberately does not check which way the stop moves, since
widening a stop is a legitimate thing for a strategy to do.