Commit 49b799b
committed
feat(strategy): port backtest simulator improvements into main
Bring the backtest simulator improvements into main without the broker/live system: trailing-stop activation-level fills, qty_percent exit-leg re-arm prevention, intraday filled-order cap flatten/latch, risk-rule enforcement (max_drawdown, max_intraday_loss, max_cons_loss_days), gap-open and multi-bracket OCA fill ordering, same-bar exit fill priority, and lot-size rounding.
Split the single Position class into PositionBase (abstract) and SimPosition; wire core/script.py and core/strategy_stats.py onto the new types. Add the _strategy_suppressed and _is_live lib flags the simulator references, and a _create_24_7_sessions() helper on CCXTProvider (get_opening_hours_and_sessions delegates to it) for the new tests.
Add 11 strategy regression tests covering the ported behaviour.1 parent 3646ee7 commit 49b799b
17 files changed
Lines changed: 1881 additions & 230 deletions
File tree
- src/pynecore
- core
- lib
- strategy
- providers
- tests/t01_lib/t30_strategy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
| 475 | + | |
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| |||
0 commit comments