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 datePrevious highCloseNext open check
Oct 27347.09347.10346.92, $0.17 below
Oct 28347.78343.83No trigger
Oct 29347.18348.91346.715, $0.465 below
Oct 30351.43344.63No trigger

Both closes exceed their original thresholds while the following opens fall below them

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

  1. Start with GET /v1/market/kline in the TickDB US Stocks API. Use interval=1d and 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]
  2. When the rule permits an intraday recross, use interval=1m and 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.
  3. 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

  1. TickDB AAPL.US daily candle archive, October 26–30, 2026, unadjusted. Sample dates checked against the archived calendar.
  2. TickDB Docs, Historical K-Line, for windows, granularity and adjustment.
  3. 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
11/24/2026

Related articles

Did Your Watchlist Follow the Index? A Midday Review with a Real-Time China A-Share Stock API

On November 23, the ChiNext Index opened lower and was up 1.22% by midday. Yet 209 stocks in our example watchlist were still below their previous close. Use opening prices, previous closes, and midday quotes from a real-time China A-share stock API to see which stocks rebounded, which turned positive, and whether your watchlist still warrants a risk flag.

TickDB Research ·

Moving a Hong Kong stock data API into Docker? Check the first quote after restart

Before moving a Hong Kong stock dashboard, alerting service, or risk monitor to Docker, what should count as recovery? In our local Tencent test, the first quote request returned HTTP 403. A later run returned a valid snapshot. The controlled restart command returned after 0.223 seconds, and the first quote passed validation after 1.580 seconds. It was still the previous session's quote. This article shows what to check on a weekend and what to verify again during trading.

TickDB Research ·