Practice trading without hindsight bias. Replay historical price action.
Project description
Trade Replay
Practice trading without hindsight bias. Learn by doing.
Trade Replay lets you replay historical price action candle-by-candle, making trading decisions in real-time without knowing what comes next. Perfect for practicing pattern recognition, testing strategies, and building intuition.
Features
- Historical Replay: Step through past price action one candle at a time
- Paper Trading: Execute fake trades during replay, track P&L
- No Hindsight: Chart only shows up to "current" candle - no peeking
- Multiple Timeframes: 1m, 5m, 15m, 1h, 4h, 1d candles
- Random Mode: Drop into random historical moments (no date bias)
- Performance Tracking: Track your simulated performance over sessions
- Scenario Library: Curated replays of famous pumps, dumps, and patterns
Installation
pip install trade-replay
Quick Start
# Start a replay session
trade-replay start BTC --timeframe 1h
# Random historical moment (no cheating!)
trade-replay random ETH --timeframe 15m
# Replay a specific date range
trade-replay start BTC --from 2021-01-01 --to 2021-03-01
# Famous scenarios
trade-replay scenario --list
trade-replay scenario "btc-2021-crash"
Example Session
$ trade-replay random BTC --timeframe 1h
TRADE REPLAY - BTC/USD (1h)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Date hidden until session ends | Candle 1 of ???
Price Chart (last 50 candles)
┌────────────────────────────────────────────┐
62k│ ▄ │
61k│ ██▄ │
60k│ ▄▄▄ ████ │
59k│ ▄██████████▀ │
58k│ ▄▄▄██████████ │
57k│ ▄▄███████████▀ │
56k│ ▄▄███████████▀ │
55k│ ▄▄██████████▀▀ │
54k│▄▄██████████▀ │
└────────────────────────────────────────────┘
NOW ▲
Current: $61,234 | High: $62,100 | Low: $60,890
Position: FLAT | Session P&L: $0
Commands:
[n]ext candle [b]uy [s]ell [c]lose position
[j]ump 5 [q]uit [i]nfo [r]eview trades
> n
...advancing 1 candle...
┌────────────────────────────────────────────┐
62k│ ▄▄ │
61k│ ███▄ │
60k│ ▄▄▄ █████▄ │
...
└────────────────────────────────────────────┘
Current: $60,456 (-1.3%) | Position: FLAT
> b
BUY ORDER
Size [100-10000 USD]: 1000
Entry: $60,456 | Size: $1,000
Position opened! Stop loss? [price or 'n']: 59000
Take profit? [price or 'n']: 65000
Position: LONG $1,000 @ $60,456
Stop: $59,000 | Target: $65,000
> n
> n
> n
...advancing 3 candles...
Current: $58,200 (-3.7%)
⚠️ STOP LOSS HIT @ $59,000
Position closed: -$24.12 (-2.4%)
Session P&L: -$24.12
> q
SESSION COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Reveal: This was BTC from 2024-03-15 to 2024-03-18
(The pre-halving pullback)
Session Stats:
Candles played: 47
Trades: 1
Win rate: 0%
Net P&L: -$24.12
Review your trades? [y/n]: y
Trade #1: LONG @ $60,456 → Stopped @ $59,000
Result: -2.4%
Notes: Bought into resistance, stop was too tight
Modes
Standard Replay
trade-replay start BTC --from 2021-11-01 --to 2021-12-01
Replay a specific period. Good for studying known events.
Random Mode
trade-replay random ETH --timeframe 4h
Drops you into a random point in history. Prevents hindsight bias since you don't know what event you're in.
Scenario Mode
trade-replay scenario "luna-crash"
Curated replays of famous market events:
btc-2017-bull- The legendary 2017 bull runbtc-2021-crash- May 2021 crash (65k → 30k)luna-crash- LUNA/UST collapseftx-collapse- November 2022covid-crash- March 2020 Black Thursdayeth-merge- The Merge event
Practice Mode
trade-replay practice --patterns
Focuses on specific chart patterns (head & shoulders, double bottom, etc.)
Commands During Replay
| Key | Action |
|---|---|
n |
Next candle |
j |
Jump 5 candles |
J |
Jump 20 candles |
b |
Buy / Long |
s |
Sell / Short |
c |
Close position |
i |
Info (volume, indicators) |
r |
Review trades |
q |
Quit session |
Indicators (Optional)
# Add indicators to chart
trade-replay start BTC --indicators rsi,sma20,sma50
Available: rsi, macd, sma{N}, ema{N}, bbands, volume
Track Progress
# View your replay statistics
trade-replay stats
REPLAY STATISTICS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total sessions: 23
Total trades: 67
Win rate: 43%
Avg winner: +4.2%
Avg loser: -2.8%
Profit factor: 1.4
Best session: +$342 (ETH 2021-08)
Worst session: -$198 (BTC random)
Improving? Your last 10 sessions: 51% win rate (vs 38% first 10)
Use as Library
from trade_replay import Replay
replay = Replay("BTC", timeframe="1h", start="2021-06-01", end="2021-07-01")
while replay.has_next():
candle = replay.next()
print(f"Price: {candle.close}")
# Your logic here
if should_buy(candle):
replay.buy(size=1000, stop_loss=candle.close * 0.95)
if should_sell(candle):
replay.close_position()
print(replay.results())
Data Sources
- Crypto: CoinGecko, Binance historical (free)
- Stocks: Yahoo Finance (free)
Data is cached locally after first download.
Philosophy
Reading about trading is not the same as trading. Trade Replay lets you:
- Practice decisions under uncertainty
- Build pattern recognition through repetition
- Test strategies on historical data
- Remove hindsight bias (you can't unknow what BTC did in 2021)
Paper trading is good. Replay trading is better - unlimited scenarios, faster iteration.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trade_replay-0.1.0.tar.gz.
File metadata
- Download URL: trade_replay-0.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e1ea4fa00d6bdd43b0b2f27be53fa5c1257cd4d83bbc63edc8c7dfc2c5c54a1
|
|
| MD5 |
254190f454591dc0f3e2249dfab82028
|
|
| BLAKE2b-256 |
cbe90f7776ebb5ee973a85f76543cd233c8ebd07a0f35a9481da8f2a79b03791
|
File details
Details for the file trade_replay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trade_replay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72a9eb26a519ebf92d7f1cf38744b88cae9669b69bbdca3b7eb460f8941248bd
|
|
| MD5 |
a53cdcf40f4d21ac1fb9a73e85047f7f
|
|
| BLAKE2b-256 |
1e4dff7b634a4a4cd290e4102463a2953b1347243fc3b55aed6c418a3cfabda7
|