Skip to content
Wildflower
Join free
Backtesting in Python (optional)

Free Trading School · Level 7 · Course 7.5

Where test data comes from

Lesson 5 of 15 in Backtesting in Python (optional)Module 1: Getting started

Advanced · Backtesting in Python

Where test data comes from

Wildflower Trading School · Lesson 7.5.1.5

Wildflower

A test is only as good as the prices you feed it. By the end of this lesson, you'll know where traders get price data, and what you're allowed to do with it. You'll also know the limits every data file has, and how one bad number can turn into a false result.

1 of 9

What you'll learn

  • Find price data. Get price history from your platform, your broker, or a data seller.
  • Read the terms. Market data is licensed. Terms say what you may download and share.
  • Note each file's limits. Bars hide price order. Joined futures contracts leave seams.
  • Check the data first. Look for repeats, highs below lows, gaps and huge moves.
  • Catch a bad price. One typo can show a gain that never happened, so check odd moves.

Exercise

  1. Find out whether your charting platform or broker lets you export bars, and read what its terms say you may do with them.
  2. Then run the four checks from this lesson on any file you have.

Next: Calculating indicators.

Quick check

  1. 1. A bar touched both your stop and your target. What can the bar alone tell you?

  2. 2. Why read your data provider's terms?

  3. 3. A close in your file is ten times too small for one day. What happens to the test?

0 of 3 answered.

Finished this lesson?

Tick it off and keep your place

Make a free account and we'll remember where you are, so “Calculating indicators” is waiting next time.

Read the full notes

Test data comes from your platform, your broker, or companies and exchanges that sell history, under terms you need to read. Every file has limits, and one bad number can make a false result, so check it first.

  • Sources: your charting platform's download (on TradingView, Download chart data saves what the chart shows; plan limits apply); your broker or trading platform; exchanges and data companies that sell history; free files online, where you need to know who made them. Prices start at the exchange and reach you through a (Broker, platform and data feed).
  • What you may do: market data is owned and licensed. Your provider's terms say what you may download and use it for. Sharing or posting files is usually limited. Read the terms; they differ by provider.
  • Limits: a bar hides the order of prices inside it; futures , so a has seams, sometimes closed up by a file (Continuous charts and their gaps); time zone and ; how much history, and in what detail.
  • Checks: bad.index.duplicated().sum(), (bad["high"] < bad["low"]).sum(), bad.isna().sum().sum(), and the biggest bad["close"].pct_change().abs(). More: Historical data for testing.
  • One typo (4,040.50 saved as 404.05) made two impossible moves: about −90% and about +911%. A test that traded it would show a gain that never existed.

Worked example

Made-up numbers

What one typo does to a test

Made-up numbers · close before 3,984.50 · typo close 404.05 · next close 4,086.75 · $5 a

  1. (404.05 − 3,984.50) ÷ 3,984.50 = about −90%
  2. (4,086.75 − 404.05) ÷ 404.05 = about +911%
  3. Short at 3,984.50, out at 404.05: 3,580.45 points.
  4. 3,580.45 × $5 = a fake $17,902.25 on one contract.

A price that never traded can make a whole test look good.

Your turn

Drill

Made-up numbers · close before 5,000 · typo close 500

Trading is risky. You can lose money. Test results are hypothetical, and a test can't tell you what will happen next. This lesson explains how testing works. It isn't advice.