$ learn algo-trading --write-the-code --paper-first

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-05
import 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.

Read the 30-line walkthrough → Drill the concepts →

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.

What's Inside

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.

Results appear here.

Sharpe Ratio + Max Drawdown

Paste a comma- or space-separated list of periodic returns (e.g. daily P&L as decimals).

Results appear here.

Max Drawdown Analyzer

Paste your equity curve (account value, NAV, or any positive series) to get peak, trough, and max drawdown with recovery status.

Results appear here.

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.

Results appear here.

Backtest Health Check

Enter your backtest summary metrics to flag common red flags — overfitting, poor risk-adjusted returns, thin edge, and small sample size.

Results appear here.

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:

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:

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.

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.