mirror of
https://github.com/alphabench/raptorbt.git
synced 2026-11-02 07:56:12 +00:00
Plain words: 0.10.1 taught the engine to report how long a trade lasted in real time rather than in bars. On tick runs that number never arrived -- it came back empty every time, and a caller with nothing to render fell back to the bar count, so a scalping strategy still reported "132 bars" for a hold that really lasted about four minutes, on a run where no bar existed at all. The measurement was being thrown away before anyone saw it. The average was computed by looking each trade's entry_idx / exit_idx up in the equity timeline. Those indices count EVENTS; the timeline holds one entry per EQUITY SAMPLE. On a bar run the two agree, because one event is one bar -- which is why this never showed up there. On a tick session they diverge: equity is sampled once per print, but quotes advance the index too. Measured on one session of a liquid NSE equity, 28,642 prints against 28,635 quotes, a trade closing on the final event carried exit_idx = 57276 against a 28,642-entry timeline. The lookup missed, every span was discarded, and the "cover every trade or report nothing" guard then correctly returned None for the whole run. The guard was right; its input was wrong. The span now comes from the trade's own entry_time / exit_time, which every production path -- portfolio ledger, single-instrument position book, options runner -- already populates from the same clock. That makes the figure exact on bar and tick runs alike rather than merely tolerant of the mismatch, and it removes an indexing assumption that was only ever true by coincidence. A tick run that reported no holding duration at all now reports a real one: on the shape above, 28,641 s of hold where the field was previously None. Not addressed here: avg_holding_period itself still counts events, so on that same run it reads 57,282 rather than the 28,642 prints. It is a bar count and still means bars wherever bars exist; what a caller should render to a person is the _secs field, as the 0.10.1 README already says. Tests: one Rust case pinning that a trade index sitting past the equity timeline still yields the right duration, and one Python case driving run_tick_strategy through the wheel, where the print and quote streams actually diverge. Both were confirmed to fail when the fix is reverted to the old indexing. The two existing duration cases pass unchanged, which is the evidence that bar runs are untouched. 529 Rust and 409 Python tests pass. Co-authored-by: Pier Code <no-reply@piercode.com>
9 lines
130 B
TOML
9 lines
130 B
TOML
version = 1
|
|
revision = 1
|
|
requires-python = ">=3.10"
|
|
|
|
[[package]]
|
|
name = "raptorbt"
|
|
version = "0.10.2"
|
|
source = { editable = "." }
|