Backtesting with a US Stock Historical Data API: Check a Close Breakout at the Next Open
TickDB Research ·
Backtesting with a US Stock Historical Data API: Check a Close Breakout at the Next Open
If a daily strategy confirms a breakout at the close, can it still enter at the next open? Use historical AAPL candles to record the signal, the opening-price condition and the fill assumption separately.
AAPL closed at $348.91 on October 29, $1.73 above the previous trading day's high of $347.18. That meets a close-above-prior-high rule. The next daily bar opened at $346.715, $0.465 below the original threshold.
A strategy that acts at the next open after every confirmed signal still has an execution candidate. A rule that requires the next open to be above the same level rejects it. Decide which rule you intend to test before choosing the price data.
Put three facts on each signal record
Record when the signal becomes known, which threshold was in force, and when the strategy could act. Here the signal uses the final closing price, so it becomes known after that price is available. The threshold comes from the prior trading day's high. The daily opening price is a proxy for the following regular-session open.
Carry the original threshold into that next session. Recalculating a previous high on the execution date asks a new question and should produce a separate record.
Use five AAPL daily bars to test both entry rules
The October 26–30, 2026 sample contains five unadjusted daily bars. October 26 supplies the first previous high; the four subsequent days are evaluated. Prices are in USD. [1, 2]
| Signal date | Previous high | Close | Next open check |
|---|---|---|---|
| Oct 27 | 347.09 | 347.10 | 346.92, $0.17 below |
| Oct 28 | 347.78 | 343.83 | No trigger |
| Oct 29 | 347.18 | 348.91 | 346.715, $0.465 below |
| Oct 30 | 351.43 | 344.63 | No trigger |

Figure 1. Each signal uses its own threshold as zero. The segments connect two observations and do not depict overnight prices. [1]
There were two signals and two next-open candidates under the first rule. Neither opening price passed the second rule. The larger breakout failed the opening-price check too. Actual fills depend on order type, submission time and the execution model.
Choose data granularity after defining the action
- Start with
GET /v1/market/klinein the TickDB US Stocks API. Useinterval=1dand consistent adjustment settings. Keep the retrieval time and the response's adjustment field. Verify the session convention, calendar and access to explicit date ranges. [2, 3] - When the rule permits an intraday recross, use
interval=1mand state whether you need a minute close or any trade across the level. A minute high can flag a possible touch, while a minute close tests a closing rule. Event order inside a bar or actual fills require finer data or order records. - When the next trading day's candle is missing, check the calendar before moving the row. Mark a missing record for retrieval. Check a consistent adjustment convention if a split or dividend falls within the window.
Save signal date, original threshold, trigger flag, next session's open and the execution-condition flag. Here is the core calculation for the triggered rows.
from decimal import Decimal as D
for values in [("347.09", "347.10", "346.92"),
("347.18", "348.91", "346.715")]:
threshold, close, open_next = map(D, values)
print(close > threshold, open_next > threshold, open_next - threshold)
Actual outputs are True False -0.17 and True False -0.465. They show the trigger flag, the opening-condition flag and the distance from the threshold.
FAQ
Can I assume a fill at the close that generates the signal? Check when the final input became available and when the order could have been submitted. A rule dependent on the final close needs an explanation if the model also fills at that price.
Does a minute high above the threshold confirm a fill? First classify the touch according to the rule. Use order records or an explicitly documented fill model to determine execution.
References
- TickDB AAPL.US daily candle archive, October 26–30, 2026, unadjusted. Sample dates checked against the archived calendar.
- TickDB Docs, Historical K-Line, for windows, granularity and adjustment.
- Nasdaq, U.S. Market Holidays & Trading Hours.
7 markets · 42,688 symbols
- US stocks
- 14,386
- Hong Kong market
- 3,354
- China stocks, ETFs & bonds
- 7,576
- Forex & metals
- 1,228
- Indices
- 13,960
- Futures
- 1,172
- Crypto
- 1,012