Auditing Online Course Strategies with AI: Out-of-Sample Backtesting and Building Your Own XQ Minute-Bar Database

TL;DR: The course strategy really did make money back when the instructor taught it, but its out-of-sample results are poor, so you need AI plus a complete historical database to run a backtest audit and see whether the performance can last.

Key ideas

  • Verifying course material can be handed to AI in stages: first understand the key points of the material and decide which techniques can be quantified, then backtest the quantifiable ones, and finally produce a summary report; this time the conclusion was that the instructor did not lie, but the backtest showed no edge.
  • Good in-sample performance does not mean a strategy works: it may be overfitting, or the market at the time may simply have suited it; many parameters that are extremely critical (for example, a moving average of 38 works but 39 and 37 both fail) is a warning sign, and you should also be wary when an instructor shows only successful cases.
  • A backtest must confirm that there is trading volume, otherwise AI may carry over the previous bar's closing price and create fake trades; you also need to prepare the database and a pre-written research-rules prompt in advance.
  • To build your own minute-bar database: in XQ, use the single-run output in the view tool, split the output into segments when the data for over 1800 stocks is large, update weekly, then convert and store it as Parquet with DuckDB; if you don't want to maintain it, you can rent the paid FinMind service instead, depending on your budget.
量化交易科學園區 - 江加宏Length 56:06Quant Trading Science Park
Episodes
  1. Mon, Nov 28Custom SwingHighBar: Finding Perfect Peaks with Rising Left Side and Falling Right Side
  2. Sat, Dec 31Automatically Detecting an M-Top with XScript: Swing Highs, Neckline and Multiple Filter Conditions
  3. Thu, Mar 16Detecting Volume-Price Divergence with Code: Comparing Price and Volume at Two Swing Highs
  4. Wed, Mar 29Recreating the Day-Trading Three Lines and a Short Alert for Breakouts That Fall Back, Using XS
  5. Tue, Apr 11RSI Bearish Divergence Algorithm and Tolerant Sampling: Syncing Price Highs with Indicator Highs
  6. Thu, Apr 20Measuring Bullish Strength from a Single Candlestick
  7. Fri, Apr 28Manual Entry, Automatic Exit: Using XQ Semi-Automated Trading to Free Up Office Workers
  8. Sun, May 14Automated Trading Without Coding Skills: Split a Strategy into Four Building Blocks of Stock Selection, Entry, Exit and Position Control
  9. Mon, Jun 5Is a High-Volume Long Upper Shadow a Reversal or a Bullish Shakeout? A 3-Year Backtest
  10. Sat, Jun 17Picking Stocks at the Second-Wave Breakout: Big Prior Rally, Low-Volume Consolidation, Then a High-Volume Long Red Candle
  11. Wed, Sep 23Disposition stocks no longer pull back under the new rules: buy those that close strong on day 1 and sell on day 5
  12. Wed, Oct 7A Live Trading Strategy Under the New Disposition Stock Rules: Buy on Day 1, Sell on the Last Day, and Use Stop-Losses
  13. Wed, Oct 21Foreign Capital Rotates Into Defensive Stocks, and a Review of Live Disposition Stock Trades
  14. Wed, Oct 28SDT Shared Variables: Fixed Memory That Saves Resources and Lets Instruments in the Same Strategy Pass Data to Each Other
  15. Wed, Nov 4Disposition Stock Strategy Flips From Bull to Bear: Why It Is Paused When the Market Weakens
  16. Wed, Nov 18Auditing Online Course Strategies with AI: Out-of-Sample Backtesting and Building Your Own XQ Minute-Bar Database
  17. Wed, Nov 25Options Long Straddle Backtest: Trading It Every Day Loses Over the Long Run, With Chances to Profit Only in High-Volatility Periods
▶ Watch the original on YouTube
Ask AI about this episode

Copy the prompt, paste it into an AI service, and add the question. The AI reads the notes on this site and links to the page and the video timestamps.

Or open directly:ChatGPTClaudeGrokPerplexity

Section summaries

  1. 0:05Original performance of an options course, backtested by AI

    This demonstrates using AI to backtest the material of an options course; besides the original conditions, the AI also tries other conditions on its own. The backtest of the original conditions did make a profit, and the period covered by the handout performed especially well, then fell back and fluctuated, yet overall it still made money, showing that the performance at the time of teaching was real.

    ▶ Watch from here
    Slide: Original performance of an options course, backtested by AI
  2. 1:25AI produces the backtest analysis and summary report

    Give the course's PDF and videos to AI and ask it to organize the material, decide which techniques can be quantified, backtest them and write a summary. The instructor claimed a big profit of 36 × 10,000 and a 69% win rate; the AI backtest gave about 32 × 10,000, with the gap attributed to fees and how fills are determined, confirming that what the instructor said was true. But the out-of-sample results were poor, possibly because of overfitting or because the market at the time happened to suit it: after earning the most in 2021, it lost steadily. During the process you need to prepare the database and a prompt of rules in advance, and remind the AI that a backtest must have trading volume, otherwise fake trades will appear.

    ▶ Watch from here
  3. 29:45Choosing the channel for exporting minute-bar data from XQ

    Since you are already renting XQ, you should make good use of it; earlier I taught how to pull daily bars, and next we switch to minute bars. XQ has four places that can export: indicator, stock screening, view and trading. The indicator can only work one stock at a time, so it is ruled out; when exporting minute bars only two choices remain, view and trading, and here I chose view.

    ▶ Watch from here
    Slide: Choosing the channel for exporting minute-bar data from XQ
  4. 31:45Writing the minute-bar export script and explaining the fields

    The export script is very simple: the user enters a start date, and it prints the output path, date and time, stock name, and open, high, low, close and volume; if you need other fields you can append them at the end, and you must tell the AI what each field means.

    ▶ Watch from here
    Slide: Writing the minute-bar export script and explaining the fields
  5. 34:35Exporting 1-minute bars with a single run in Strategy Radar

    Exporting 1-minute bars for over 1800 stocks by backtesting or automated trading doesn't work: because the backtest runs on XQ's servers, memory blows up quickly and only about 200–300 stocks have data. The correct way is to add the script to Strategy Radar and switch to single-run mode, setting the start date and a 1-minute bar frequency; when the data is large you must split it up, for example exporting once per half year, since pulling 5 years at once will definitely crash, and after that just update weekly.

    ▶ Watch from here
  6. 41:35Storing minute-bar data and choosing a data source

    Minute-bar data is stored with Parquet plus DuckDB rather than sqlite, because sqlite files for 1-minute bars or tick data become very large and queries are slow, while this kind of data is rarely modified, so what you want is a small footprint and fast reads. If building your own is a hassle, you can instead use the paid FinMind, at 8888 per year, which saves maintenance and includes historical options data, but has traffic limits; a self-built database has no traffic limits, so choose according to your budget.

    ▶ Watch from here

This page summarizes the video; it is not an official transcript. Original video: Auditing Online Course Strategies with AI: Out-of-Sample Backtesting and Building Your Own XQ Minute-Bar Database (量化交易科學園區 - 江加宏), copyright belongs to the original creator.