Learn algorithmic trading by writing the code yourself
Below is a complete SMA-crossover backtest — 15 lines, real data, honest costs. AlgoDrill teaches you to write, test, and risk-manage strategies like this from scratch, and to read the results without fooling yourself.
hero_sma_crossover.py
# SMA crossover backtest — the whole bot.# vectorbt 1.0.0 · yfinance 1.4.1 · run 2026-06-05import vectorbt as vbt
price = vbt.YFData.download("SPY", start="2015-01-01", end="2024-12-31").get("Close")fast = vbt.MA.run(price,10)slow = vbt.MA.run(price,50)entries = fast.ma_crossed_above(slow)exits = fast.ma_crossed_below(slow)pf = vbt.Portfolio.from_signals( price, entries, exits, fees=0.0005, freq="d")print(f"Total Return {pf.total_return():>8.1%}")print(f"Sharpe Ratio {pf.sharpe_ratio():>8.2f}")print(f"Max Drawdown {pf.max_drawdown():>8.1%}")
$ python hero_sma_crossover.py
Total Return
+106.6%
Sharpe Ratio
0.87
Max Drawdown
-15.1%
Real output, run 2026-06-05: SPY daily closes 2015–2024 via yfinance, vectorbt 1.0.0, 5 bps fees per side. Buy & hold returned +240.8% over the same window — the point isn't that this simple bot wins (it doesn't), it's that you can measure exactly how it behaves before risking anything. Educational example, not financial advice.
AlgoDrill exists to prove that automated trading is just code — code you can write. Every concept ships toward a runnable example, every tool comparison is neutral and cited, and the agentic-AI module (in development) teaches you to build LLM-driven paper-trading agents end to end — state machines, prompt design, data pipelines, and feedback loops — before you risk a single dollar. The Kelly, Sharpe, drawdown, and expectancy calculators below are live; the flashcards make it stick.
Five live calculators in one tabbed console: Kelly fraction, Sharpe/Sortino/Calmar, drawdown, trade expectancy, and a backtest health check. Paste your numbers, get instant feedback. Open the tools →
Live Tools
Five browser-side calculators for the numbers every systematic trader watches — position sizing, risk-adjusted return, drawdown, trade stats, and a backtest sanity check. Pick a tab; nothing leaves the page.
Kelly Criterion + Expectancy
Enter your historical win rate and average win/loss to compute optimal position sizing.
Sharpe Ratio + Max Drawdown
Paste a comma- or space-separated list of periodic returns (e.g. daily P&L as decimals).
Max Drawdown Analyzer
Paste your equity curve (account value, NAV, or any positive series) to get peak, trough, and max drawdown with recovery status.
Trade Expectancy Batch Calculator
Paste your trade P&L values (positive = win, negative = loss) to get win rate, expectancy, payoff ratio, and profit factor across your full trade history.
Backtest Health Check
Enter your backtest summary metrics to flag common red flags — overfitting, poor risk-adjusted returns, thin edge, and small sample size.
How to Think About Algorithmic Trading Risk
Most retail algo traders fail not because their signals are wrong, but because their position sizing destroys the account before the edge can compound. The four numbers below are the minimum viable dashboard for any systematic strategy:
Kelly Fraction: The maximum fraction of capital to risk per trade that maximizes long-run geometric growth. A positive Kelly means you have positive expected value; negative Kelly means stop trading the setup immediately. Most pros use half-Kelly (50% of the output) to reduce variance and path risk. Full Kelly Criterion guide →
Expectancy: Average profit per trade in dollar terms (reported here as $/trade). To get the R-multiple ("per dollar risked"), divide expectancy by your average loss. Below zero: the strategy is a net drain regardless of position sizing.
Sharpe Ratio: Risk-adjusted return. Measures how much excess return you earn per unit of volatility, annualized (×√252 for daily returns). Values below 0.5 are weak; 1.0+ is respectable; 2.0+ is exceptional (and worth scrutinizing for look-ahead bias or overfitting). Full Sharpe Ratio guide →
Sortino Ratio: Like the Sharpe, but divides excess return by downside deviation only — penalizing harmful downside volatility while ignoring upside swings. For the same return series it runs ≈1.41× the Sharpe when returns are positive; a large gap signals positive skew. Full Sortino Ratio guide →
Max Drawdown: The largest peak-to-trough decline in the equity curve. This is the number you actually feel psychologically — a 40% drawdown requires a 67% recovery just to break even. Know your drawdown before you trade real money. The Calmar Ratio pairs max drawdown directly with annual return: Calmar = CAGR / MaxDD. Full Calmar Ratio guide →
Information Ratio: Active return per unit of tracking error — the standard metric for benchmarked strategies (long-only equity, factor funds, tactical overlay). Unlike Sharpe, which measures absolute risk-adjusted return, IR measures how consistently a strategy beats its benchmark. The Fundamental Law of Active Management states IR ≈ IC × √BR, where IC is forecast accuracy and BR is the number of independent bets per year. Full Information Ratio guide →
The Kelly and Sharpe calculators above work entirely in your browser — no data leaves the page.
What the Agentic AI Module Covers
The agentic-AI module is the differentiating content on AlgoDrill — the only structured curriculum that teaches you to build LLM-driven paper-trading agents, not just use them as chatbots. Read the full architecture guide →
The architecture has five layers:
Data ingestion: Streaming price data from broker APIs (paper accounts only), normalizing tick data into feature vectors an LLM can interpret.
Signal generation: Prompt engineering for trading decisions — structured outputs, chain-of-thought for market-regime classification, and tool use for accessing indicators in real time.
Execution loop: A paper-trade state machine that processes LLM decisions, applies position sizing (Kelly-constrained), and logs fills to a local ledger.
Feedback loop: Automated performance evaluation that feeds back Sharpe, drawdown, and expectancy metrics to the agent as context, enabling iterative improvement without human intervention.
Guardrails: Hard constraints enforced at the code level — max position size, daily loss limit, and circuit breakers — so the agent cannot exceed risk parameters even if the LLM generates a rogue signal.
Every lesson is a flashcard drill, not a video. You read the concept, recall the structure, and verify against the answer. The goal is retention, not passive consumption.
Choosing Your Algo Stack — Module 2 Comparison Guides
Picking the wrong backtesting framework, broker API, or data provider is an architecture mistake, not a configuration one. AlgoDrill’s Module 2 hub pages compare each layer of the systematic trading stack on the axes that matter: maintenance status, live-trading support, cost, and fit for your strategy type. All comparisons are neutral and unaffiliated.
Broker APIs — 11 broker and execution APIs compared (Alpaca, IBKR, Tradier, Tastytrade, OANDA, ccxt, Binance, and more). Paper trading availability, SDK support, cost structure, and the ib_insync → ib_async transition.
Market Data Providers — 9 providers compared (Polygon/Massive, Databento, Tiingo, yfinance, Norgate, and more). Free tiers, granularity, and survivorship-bias-free status. Includes the IEX Cloud shutdown and Polygon rebrand.
Trading Platforms — 8 platforms compared (TradingView, NinjaTrader, MetaTrader 4/5, MultiCharts, Sierra Chart, TrendSpider, ProRealTime). Native vs webhook automation, scripting language, and asset coverage.
Event-Driven vs Vectorized Backtesting — The conceptual foundation for all framework comparisons: engine architecture, look-ahead hazards, and the pro dual-pipeline workflow.
Frequently Asked Questions
What is AlgoDrill?
AlgoDrill is a free flashcard-style educational platform for algorithmic trading. It covers strategy archetypes and backtesting concepts today, with an agentic AI module (LLM-driven paper-trading agents) in development. It also includes live Kelly Criterion, Sharpe Ratio, drawdown, and expectancy calculators.
Does AlgoDrill execute trades or manage my money?
No. AlgoDrill never executes trades, never holds API keys, and never connects to your brokerage. It is a purely educational platform. We teach the architecture; you wire your own broker on your own account.
What is the Kelly Criterion?
The Kelly Criterion is a formula for optimal position sizing: given your win rate, average win, and average loss, it computes the fraction of capital to risk per trade that maximizes long-run portfolio growth. Many practitioners use half-Kelly (50% of the output) to reduce variance.
What is the Sharpe Ratio?
The Sharpe Ratio measures risk-adjusted return: average excess return divided by standard deviation of returns. Above 1.0 is good; above 2.0 is excellent. Below 0.5 suggests the strategy does not compensate for its volatility.
What is an agentic AI trading agent?
An agentic AI trading agent uses an LLM to reason about market data, generate trading signals, and paper-trade in a feedback loop. AlgoDrill will teach the full architecture: data ingestion, LLM signal generation, paper-trade execution, and performance evaluation — all before risking real capital. The dedicated deck is in development.
What is Sortino Ratio?
The Sortino Ratio is a variation of the Sharpe Ratio that penalizes only downside volatility — returns below a target rate (the MAR, commonly 0 or the risk-free rate) — not upside volatility. A positively skewed strategy (frequent small losses, rare large gains) scores relatively higher on Sortino than on Sharpe, because its large gains are not counted as risk. Sortino above 1.0 is generally considered good; below 0.5 is weak.
What is Calmar Ratio?
The Calmar Ratio is the annualized geometric return divided by maximum drawdown. It measures how much annual return you earn per unit of worst-case drawdown risk. A Calmar above 1.0 means you earn more than your worst drawdown in a given year — a useful bar for trend-following and CTA-style strategies.
What is profit factor in trading?
Profit factor is the ratio of gross profit (sum of winning trades) to gross loss (sum of losing trades). A profit factor above 1.0 means the system is net profitable; below 1.2 the edge is so thin that commissions and slippage can easily flip it negative. Above 2.0 is strong; above 3.0 warrants scrutiny for overfitting.
Is AlgoDrill free?
Yes, completely free. No account, no subscription, no credit card. All tools run in your browser — no data leaves the page.