Repository navigation
Commit 6b77f06
Pine adapter: admission fill half on, close-first entries, point order, exit tombstones, pyramiding records (#335)
TradingView admits an order in two halves: rules 2 and 5 at the signal close,
then one price-scale check at the fill. This change turns the fill half on and
adds the TradingView behaviours that the fixtures under
tests/fixtures/admission_rules pin. Each rule has its own internal switch in
MarginRuleSwitches. All switches are on, and only tests change one.
- unified_placement: the placement half, split out of fill_price_recheck. A
reversal that rule 5 refuses stays placed, marked signal_price_refused. It
drops at its fill, and the script's later close of the held id stays an
ordinary close.
- fill_price_recheck, now on: the whole order drops iff
sig10(sig10(E_signal) / (Q m)) is under the slipped tick-built fill quote.
The tie band is removed. Inside the unified scope, the explicit market
long's money check on the unslipped next-bar quote is never reached.
- close_first_admission: an entry the script placed on the same bar behind its
own strategy.close(<held id>) or strategy.close_all() of the position it
opposes is checked by rule 2 only.
- It fills flat with its frozen quantity.
- The fact is recorded once, at the close or close_all call, and stamped on
the entry at its entry() call.
- point_fills_before_margin: at the open, the queued orders execute first,
then the exits the open reaches, then the margin check on what is left. Two
kinds of order fill before that check:
- a protective strategy.exit stop or limit that the opening print reaches
and whose entry holds units of the position; an exit armed for an entry
that holds nothing fills nothing there. from_entry_units, the units an
exit's entry holds, is shared with the process_orders_on_close bracket
ranking in flush_pending_bracket_legs, whose inert exit also needs an
entry with no working order; each site keeps its own test;
- a close the script placed ahead of its opposite entry.
Two shapes keep the earlier order:
- A process_orders_on_close short's call sized at the previous close,
while the open does not re-size it, is a queued order, so it executes
before a stop the open gaps through (TradingView's tape of
axealgo-tp-sl-toolkit-axealgo on OANDA:XAUUSD: the call of 1, then the
stop's 1.62). A call the open re-sizes is the open's own check, after the
exits; no tape decides that shape yet.
- A partial exit fills first only when what it leaves is margined; a
remainder still short keeps the call at the open first. No tape decides
that case yet.
test_point_order_open_call pins both shapes, each with a control.
- exit_child_tombstones: a partial exit child that filled is never revived for
the entry incarnation it filled under.
- pyramiding_ledger_records: under pyramiding above one, the cap counts the
open close-ledger records, one per entry fill not yet booked, not the
physical lots. An exit armed for one opening books that opening first.
Every rule runs only on a power-of-ten lot grid, which every tape and every
population member uses. The unified admission also leaves out
calc_on_order_fills, the bar magnifier, stops that reverse, default-sized
stops, a resting book and same-open pairs; those keep the earlier rules. New
durable state is folded into the source-adapter hash only while it is set.
Three rules are left out, because nothing tells them apart from the current
behaviour. Decision counters ran over every ctest fixture and 198 replayed
population scripts and found no divergence:
- the commission-0 POOC unit: 23,510 calls;
- the whole-book add at the signal close: 413 calls;
- the lagged follow-up on whole-share grids: 1 call.
docs/pine-adapter-kernel-notes.md section 1.8 names the TradingView control
each one needs.
Fixtures:
- tests/fixtures/admission_rules: 73 TradingView tapes in four groups,
gap_admission, point_order_and_book, stop_priority and explicit_short.
- The engine reproduces all 73, and 56 of the 59 NYSE:F tapes book the same
trades as a backtest and as a stream; the other three cross a holiday
that a stream takes as an in-session gap.
- Each of the six rules above loses tapes when turned off alone.
- test_qty_step_lot_grid_case, the hosted lot-grid case, still books every
recorded row exactly, with and without the 1e-05 grid.
- The explicit-short twin control in test_taro_price_gap_admission_l4d is
re-pinned on TradingView's own tape of it (explicit_short/offset0-fill).
TradingView fills that order, so its literal check moves to the -.00032
offset, where the order is declined.
- The margin_call_rules, margin_ledger_rules and forward-replay lists drop the
entries the fill half now reproduces.
- test_integer_flat_budget_tie_l4d asserts the one row it moves. On a 0.01
lot grid, rule 2 drops a default long from flat one ulp under the cost, as
TradingView's margin_ledger_rules tape eth-flat-m100-ulp-under does.
The witness tables move on hash fields only. Every closed trade of every
run-pass is identical, field for field, to the parent commit's.
The margin-rules notes said the unified admission ships off; it now ships
on, so these sentences of docs/pine-adapter-kernel-notes.md are replaced:
- "Two narrowings keep the scraped population's orders on the earlier rules"
- "Outside that scope the engine's earlier admission rules run unchanged."
- "The tree ships this unified admission off"
- "gates it whole, its fill half and the placement half's reach"
- "With it on, the scraped population lost orders"
- "keeps the earlier scopes: an explicit quantity from flat"
- "With the shipped switches the engine reproduces 170"
- "The tests list 3 single-position and 104 ledger tapes"
- "The fill re-check, and with it the unified admission"
- "On the scraped population it dropped reversals and openings"
- "The tapes pin the check only at a one-tick"
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>1 parent 7afba5c commit 6b77f06
361 files changed
Lines changed: 8900 additions & 711 deletions
File tree
- docs
- adr
- design
- pages
- include/pineforge/source
- src/source
- tests
- fixtures/admission_rules
- bars
- explicit_short/offset0-fill
- gap_admission
- cf1-cf-long-gapup7
- cf10-cf-exp-long-ulp-d0616
- cf10-cf-exp-long-ulp-d0829
- cf11-rev-exp-long-ulp-d0616
- cf11-rev-exp-long-ulp-d0829
- cf12-flat-exp-long-ulp-d0616
- cf12-flat-exp-long-ulp-d0829
- cf1b-cf-long-gapup3
- cf2-cf-short-gapup7
- cf3-rev-long-gapup7
- cf3b-rev-long-gapup3
- cf4-rev-exp-long-gapup7
- cf5-cf-exp-long-gapup7
- cf7-cf-exp-long-money-short
- cf7b-cf-exp-long-money-short-d0506
- cf7c-cf-exp-short-money-short-d0507
- cf8-flat-long-gapup7
- cf8-flat-short-gapup7
- cf9-cfall-long-gapup7
- point_order_and_book
- add1-short-wholebook
- add2-short-wholebook-at-fill
- c1-gapstop-fee-slip
- c2-gapstop-percent
- c3a-entry-then-close
- c3b-closeall-first
- c4-xau-weekend-gapstop
- c5-pooc-tp-tombstone
- c5b-pooc-tp-tombstone-marketable
- pyr1-records-below-lots
- pyr2-records-above-lots
- stop_priority
- close-reversal-102180
- close-reversal-102500
- close-reversal-103000
- stop-01
- stop-02
- stop-03
- stop-04
- stop-05
- stop-06
- stop-07
- stop-08
- stop-09
- stop-10
- stop-11
- stop-12
- stop-13
- stop-14
- stop-15
- stop-16
- stop-17
- stop-18
- stop-19
- stop-20
- stop-21
- stop-22
- stop-23
- stop-24
- stop-25
- stop-26
- stop-27
- stop-28
- stop-29
- stop-30
- stop-31
- stop-32
- stop-33
- stop-34
- stop-35
- stop-36
- stop-37
- stop-38
- stop-39
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1496 | 1496 | | |
1497 | 1497 | | |
1498 | 1498 | | |
1499 | | - | |
| 1499 | + | |
1500 | 1500 | | |
1501 | 1501 | | |
1502 | 1502 | | |
| |||
0 commit comments