When a limit order fills
sim.fill-modelWhat it does
A simulated limit order fills only when the price trades through it. Just touching the limit isn't enough. A buy also fills only if the account has the cash to pay for it.
How it works
The simulator is the part of Rungfolio that decides which orders would have filled. Each trading night, practice mode replays that day's regular session against the ladder's working orders, one 1-minute bar at a time. A bar sums up one minute of trading: the price at its open, its high, its low and its close. A backtest runs the same rules on 5-minute bars by default, or on 1-minute bars for a range of up to a year. A 5-minute bar fills as a 1-minute bar with its open, high and low would, so a 5-minute backtest can differ a little from practice nights.
- A buy limit fills, at its limit, when a bar trades at least one tick below the limit.
- A sell limit fills, at its limit, when a bar trades at least one tick above it.
A tick is the smallest step an order's price can take: $0.01 for prices of $1.00 and above, and $0.0001 below. Rounding to the tick has the details.
A bar that only reaches the limit, or trades past it by less than a tick, is a touch, not a fill.
There's one exception: the first bar an order works in, usually the session's first. If that bar opens beyond the limit, by any amount, the order fills at the open instead, as gap fills explains. In any later bar, the order fills only at its limit, by the rule above, even when the bar opens beyond it.
Orders fill completely. The simulator doesn't model partial fills, and what the simulator doesn't model lists this and its other limits.
A sell can't fill in the same bar as its buy, as no same-bar round trips explains.
Example
The first row lists the orders working at the open: two buys, on rungs 2 and 3. The 9:30 bar's low only touches rung 2's buy limit, so nothing fills. The 9:31 bar trades a tick below that limit, and the buy fills at its limit. The 9:32 bar does the same for rung 3.
| Bar | Open | High | Low | Close | Fills |
|---|---|---|---|---|---|
| Working | Rung 2: Buy 6 TNA @ 81.95 → sell @ 84.41 · GTC OTO Rung 3: Buy 6 TNA @ 81.75 → sell @ 84.21 · GTC OTO | ||||
| 9:30 am | 82.10 | 82.14 | 81.95 | 81.98 | Nothing filled. |
| 9:31 am | 81.98 | 82.00 | 81.94 | 81.96 | Rung 2 bought 6 shares at 81.95. The 81.95 buy filled because the price traded through it, down to 81.94. Rule: sim.fill-model |
| 9:32 am | 81.96 | 82.01 | 81.74 | 81.80 | Rung 3 bought 6 shares at 81.75. The 81.75 buy filled because the price traded through it, down to 81.74. Rule: sim.fill-model |
| Cash | $50,000.00 before the first bar, $49,017.80 after the last. | ||||
The order within a bar
In each bar, the simulator tries the working orders in a fixed order:
- At the session's first bar only, any exits from the price floor sell at the bar's open (trading sessions).
- Then the sells, from the lowest limit up. They come before the buys, so the cash they bring in can pay for a buy in the same bar.
- Then the buys, from the highest limit down, the order in which a falling price reaches them.
Orders with the same limit also go in a fixed order. So the result never depends on how the orders happen to be stored: the same bars and orders always give the same fills.
An account with several ladders replays their tickers together, a minute at a time. In each minute, every ladder's exits and sells come first, ladder by ladder in priority order, and then every ladder's buys, in the same order. Each ladder's bar keeps the order above. A ticker with no bar in a minute sits that minute out.
The cash guard
A buy fills only if the account's cash covers it: its shares times the price it fills at. A buy the cash can't cover doesn't fill, and it stays working. The simulator notes it once per session, at the first bar that reached it, with the cash there was then.
Each buy is checked against the cash left at that point. So a buy the cash can't cover doesn't hold back a cheaper one below it, and a buy passed over early in a session can still fill later in it, once a sell has brought in the cash.
The cash is the account's, not a ladder's. An account's ladders share one pot of it, minute by minute, as in a real brokerage account:
- A sale on any ladder pays for a buy on any ladder, in the same minute or later.
- Within a minute, every ladder's sales come before any ladder's buys, so the cash they bring in counts first.
- Then the buys meet the cash in priority order. When it runs short, the ladder higher in the order fills first, and a buy on a lower ladder that the rest can't cover waits.
Say an account has $500 in cash. At 10:15, a TNA sale brings in $510, and in the same minute buys on two lower ladders are reached, $492 on SOXL's and $498 on LABU's, with SOXL above LABU. The sale comes first, so there's $1,010. SOXL's buy fills, leaving $518, and LABU's fills too, leaving $20. Had the sale come a minute later, SOXL's buy would have filled from the $500 at 10:15, and LABU's, with only $8 left, wouldn't have filled then.
The guard matters only when open lots are worth more than they cost. The capital cap keeps capital in use plus the planned buys, across every ladder in the account, within a share of the account value. Capital in use counts the lots at cost, but the account value counts them at the last close. While the lots are worth no more than they cost, that keeps the planned buys within the cash. Once they're worth more, a cap set high can let a plan arm more buys than the cash covers.
This made-up account has only $500 in cash, far less than its two buys would cost, to show the guard at work. Rung 2's buy fills at 9:31 and leaves too little for rung 3's, which the 9:32 bar reaches.
| Bar | Open | High | Low | Close | Fills |
|---|---|---|---|---|---|
| Working | Rung 2: Buy 6 TNA @ 81.95 → sell @ 84.41 · GTC OTO Rung 3: Buy 6 TNA @ 81.75 → sell @ 84.21 · GTC OTO | ||||
| 9:30 am | 82.10 | 82.14 | 81.95 | 81.98 | Nothing filled. |
| 9:31 am | 81.98 | 82.00 | 81.94 | 81.96 | Rung 2 bought 6 shares at 81.95. The 81.95 buy filled because the price traded through it, down to 81.94. Rule: sim.fill-model |
| 9:32 am | 81.96 | 82.01 | 81.74 | 81.80 | Rung 3 bought nothing. The 81.75 buy was reached, but the account's $8.30 in cash couldn't cover it, so it didn't fill. Rule: sim.fill-model |
| Cash | $500.00 before the first bar, $8.30 after the last. | ||||
Why
At exactly your price, other orders may be ahead of yours in the queue, so a touch doesn't prove your order would have filled. Asking for a trade-through keeps simulated results from looking better than real ones.
The cash guard keeps practice cash from going below $0, so the simulator never buys with money the account doesn't have.
In the app
On Home, each of last night's fills has a "why?". For a fill under this rule, it names the low or the high that traded through the limit. Buys the cash couldn't cover show as a note for their ladder, such as "2 TNA buys skipped last night: the cash didn't cover them." Its words "the cash didn't cover" link to this article.