Repository navigation
ENH: Support time-varying bid-ask spreads - #1393
AtomicGlance wants to merge 1 commit into
Conversation
|
I reran the full backtesting.py test module on this branch (83 passed, 1 skipped). Before I make any further API changes, could you confirm that a spread sequence/Series aligned to the input bars is the preferred interface alongside the existing scalar value? I鈥檝e kept the current spread convention and apply the value from the actual fill bar for market, limit, and stop orders. I鈥檇 also appreciate confirmation on whether a Series must have an identical index and how missing values should be handled. |
8045baf to
89afc8f
Compare
|
Hi, following up on the per-bar spread proposal here and the trade-count addition in #1394. Before doing more work, I鈥檇 appreciate your view on whether these APIs fit the project鈥檚 direction. In particular, is requiring a spread Series to match the data index the interface you鈥檇 prefer? If either feature is outside the intended scope, that would also be helpful to know. Thanks! |
Summary
Fixes #1300.
Backtest(..., spread=...)now accepts either the existing scalar rate or a one-dimensional per-bar array-like value. A pandas Series must use the same index as the OHLC data. Values are validated as finite, numeric, and non-negative, and are applied at the bar where an order is filled. Scalar spreads keep the existing execution path and results.The spread remains a relative rate, consistent with the current API. Data-source spreads expressed in price units can be converted to rates before passing them to
Backtest.Tests
backtesting/test/_test.pysuite: 83 passed, 1 skipped