Commit graph Warrior_EA/research/bidask.py
Author SHA1 Message Date
AnimateDread
3459db887b infra: bid/ask M1 bars and an order engine that makes the fill bug unavailable
Three results today were invalidated by the same family of error: a price level
used as an entry while the outcome was measured from somewhere else. The defence
is not vigilance - it is an interface where the mistake cannot be expressed.

bidask.py  M1 bars carrying SEPARATE BID and ASK OHLC, built from the tick
  stream in one parallel pass. Every existing bar file stores MID, which is fine
  for measuring returns and useless for simulating orders, because no order ever
  executes at the mid. Mid bars force the spread to be bolted on afterwards as an
  average - the approximation that let today's artifacts through. With both sides
  carried, the spread is whatever it actually was, including the overnight and
  news blowouts an average hides. Fails loudly if ask < bid.

fills.py  owns the ENTIRE trade lifecycle; no test may open a position any other
  way. Longs enter at the ask and exit at the bid, shorts the reverse. A buy stop
  triggers on the ask and fills at the trigger price OR the bar's open if the bar
  gapped past it, which is where real slippage comes from. Limits fill on the
  opposite side and a gap is capped in their favour.

  The invariant that was violated: THE OUTCOME CLOCK STARTS AT THE FILL BAR. The
  fill index IS the start index - they are the same variable and cannot diverge.
  That is what went wrong before, and it is now unrepresentable rather than
  merely discouraged.

  Same-bar ambiguity is REPORTED, not assumed away: every result carries the
  fraction of trades decided by a bar containing both barriers, alongside fill
  rate and unresolved rate. A resolution-limited result now says so itself.

M1 rather than raw ticks is a deliberate, stated bound: 513M ticks per symbol is
~8 GB packed and four symbols will not fit in memory, while M1 keeps it at ~500 MB
and cuts the residual ambiguity 60x versus H1. It is an approximation with a
visible error bar, not an exact simulator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 00:08:30 -04:00