Crypto DCA Backtester
Simulates weekly dollar-cost averaging vs a lump-sum investment of the same total capital, using real historical daily prices from CoinGecko's free market_chart API. No API key needed.
When to use
- Deciding whether to DCA into a position or deploy capital all at once
- Backtesting how DCA would have performed on a specific coin over the last N days (up to 365)
- Comparing entry strategies across multiple coins before allocating
- Building intuition for how DCA smooths volatility vs a single entry point
Commands
python3 scripts/dca_backtest.py --coin bitcoin --days 365 --weekly-contribution 100
python3 scripts/dca_backtest.py --coin ethereum --days 90 --weekly-contribution 250
python3 scripts/dca_backtest.py --coin solana --days 365 --weekly-contribution 100 --json
--coin takes a CoinGecko coin id (e.g. bitcoin, ethereum, solana, matic-network) — use CoinGecko's /coins/list if you need to look one up.
Output
Total invested, end portfolio value, and return % for both DCA and lump-sum, using the same total capital for a fair comparison, plus a declared winner for that specific historical window.
Notes
- Data source: CoinGecko free
market_chartendpoint, daily granularity, max 365-day lookback on the free tier. - This is a historical return comparison only — it does not model volatility-adjusted or risk-adjusted returns, and past performance over one specific window is not predictive of future results. Not financial advice.
- Requests use a curl-style User-Agent; some public API providers block the default Python User-Agent.
