You can’t do crypto quant without pandas. Your market data is a table, your indicators are columns, and your backtest engine chews on time-indexed DataFrames — vectorbt, Freqtrade, the strategy classes in your strategy/ directory, they all consume this exact data structure.
But most people learn pandas the wrong way: grinding through syntax manuals, memorizing APIs, finishing the book, and still not knowing how to handle a single candlestick.
This is the pandas crash course I put together for myself. The guiding principle is one: don’t learn syntax — learn by driving real crypto data. In quant, pandas does exactly four things — read data in, reshape it into a time-series table, calculate technical indicators, and run statistical analysis. I break it into 6 steps, each pairing a set of concepts with runnable code you can drop straight into a JupyterLab notebook. By the end, you’ll be able to independently pull data from ccxt → process it with pandas → run a vectorbt backtest — the full pipeline.
Environment assumption: you have a Python environment with ccxt + pandas + vectorbt installed (mine is the .venv in the LynxCrypto project) and JupyterLab is already running. If not, pip install ccxt pandas vectorbt jupyterlab gets you set up.
Pre-game (optional, but recommended to skim)
If you’re starting from zero with pandas, spend 30–60 minutes running through one of these HTML tutorials — all of them let you copy-paste and run the code directly:
- Kaggle’s free Pandas course — https://www.kaggle.com/learn/pandas Runs code and exercises right in the browser, for free. The smoothest path to understanding Series / DataFrame / index / grouping concepts.
- Pandas Official 10 Minutes to pandas — https://pandas.pydata.org/docs/user_guide/10min.html The official quick overview, all code is copy-pasteable. Builds a “what pandas can do” mental map.
- Chapters 5–9 of Python for Data Analysis (by pandas author Wes McKinney) — freely available online, practical in tone, great to keep as a reference.
Work through any one of the above, then return to the 6 steps below. You’ll move much faster than if you just memorized syntax.
Step 1 — Turn Market Data into a DataFrame (Reading + Structure)
Concepts covered: Series, DataFrame, index, columns, dtypes, head / tail, to_datetime
Task: Pull BTC/USDT candlestick (OHLCV) data from an exchange via ccxt, and convert it into a time-indexed table.
| |
Key takeaway: Each column in the table is a Series; the whole table is a DataFrame; the leftmost time column is the index. The index is the foundation of every pandas time-series operation — everything downstream (resampling, slicing, etc.) rests on it.
Step 2 — Time-Series Reshaping and Slicing (Indexing, Slicing, Resampling)
Concepts covered: DatetimeIndex, loc / iloc slicing, resample, time zones
Task: Resample 1-minute data into 4-hour candles, then take a recent slice.
| |
Key takeaway: loc slices by label (time strings / index values), iloc slices by position (Nth row). resample is the core tool for compressing high-frequency data into low-frequency — quant work heavily depends on it for 1m→4h, 1h→1d conversions.
Step 3 — Calculate Technical Indicators by Hand (Column Ops, rolling, shift, ewm)
Concepts covered: Column operations, rolling (rolling window), shift (lag), ewm (exponentially weighted), apply / lambda
Task: Without using any pre-built indicator library, calculate MA, RSI, and MACD from scratch to understand what’s going on under the hood.
| |
Key takeaway: rolling(20).mean() opens a sliding window of 20 elements and computes the mean — almost every trend indicator derives from this. shift(1) slides data back by one position, commonly used to “compare today’s value against yesterday’s”. ewm computes a weighted mean with exponential decay, used by both RSI and MACD. Calculating these by hand makes it crystal clear what’s happening inside the pre-built functions from ft-pandas-ta.
Step 4 — Multi-Asset Alignment (concat, merge, correlation)
Concepts covered: concat, merge / join, multi-asset time alignment, fillna, corr (correlation)
Task: Align BTC and ETH closing prices onto one table, then compute their correlation.
| |
Key takeaway: The core of any multi-asset strategy (pair trading, cross-coin arbitrage) is “time alignment” — if the two coins’ timestamps don’t line up, use fillna or dropna; concat(axis=1) is the workhorse for horizontal merging. The high correlation between BTC and ETH is a fundamental fact of the crypto market, and both pair trading and statistical arbitrage are built on top of it.
Step 5 — Statistics and Visualization (describe, groupby, plotting)
Concepts covered: describe, pct_change (returns), groupby (grouping), agg (aggregation), plot
Task: Compute return distributions, group by day/hour to find patterns, and plot.
| |
Key takeaway: describe() is the fastest data health check; groupby is “group by some column, then compute separately for each group” — quant work relies on it for finding patterns by hour / day of week / month. The shape of the return distribution (whether it’s normal, whether it has fat tails) determines your strategy’s risk assumptions. Crypto returns exhibit pronounced fat tails — that’s why the martingale strategy always loses in the long run (see the liquidation math in my previous post).
Step 6 — Bridge to vectorbt (Feeding DataFrames into the Backtest Engine)
Concepts covered: No new pandas concepts here — this step is about understanding “how the research output enters the backtest”: the pandas DataFrame is vectorbt’s standard input.
Task: Use the MA20 from Step 3 to generate a crossover signal, then feed it into vectorbt.
| |
Key takeaway: By this point, pandas data is “production-ready” — vectorbt, your strategy classes in strategy/, all consume this exact time-indexed DataFrame. During research, you prototype ideas in the notebook (these 6 steps); once solidified, you extract the logic into a .py module under strategy/. That’s the division of labor: the notebook is your scratchpad, the .py is your deliverable.
What you can do after this
- You’ve walked through the 6 core pandas actions in quant (read / slice / calculate indicators / align / summarize / feed to backtest) using real crypto data
- You can independently pull data from ccxt → process with pandas → run a vectorbt backtest through the full pipeline
- Next step: compare your hand-calculated indicators and signals against the strategies already in your
strategy/folder (mine uses MacdCross as the reference), and understand the mapping between the “notebook exploration version” and the “engineering module version”
Four Anti-patterns (I fell into them, don’t)
- Don’t cram ten ideas into one notebook — one notebook per research question, or you won’t even understand your own work three months from now.
- Write assumptions and conclusions at the top of each notebook — when you look back, read those two lines first before diving into the code.
- Extract finalized logic back into
.py— notebooks should only hold research process, not become a catch-all stew. - Don’t just read — run — type out every snippet yourself, tweak parameters, observe the output change. You won’t learn by just watching.
This is the hands-on intro to the LynxCrypto series. Other articles in the series: Research Blueprint · From Grid Martingale to Alpha (Part 1) · Falsification · WFO Verdict · Tools Roadmap
