"Build it and they will come" works for software. It does not work for quantitative trading.
In 2019, a talented backend engineer I know spent three months building a mean-reversion strategy on what he believed was clean AAPL price data. The backtest showed a Sharpe ratio of 1.8. The live account lost 12% in six weeks. The problem was not the code. The problem was that his data was split-adjusted in one place and unadjusted in another, creating phantom returns that never existed.
This is the gap between software engineering and quantitative finance. You can write elegant code against a flawed data model, and the result is not a slow program. The result is a strategy that looks brilliant in simulation and implodes in production.
This article identifies the five financial concepts that most frequently cause this class of failure for engineers entering quantitative trading. These are not the concepts you will find in a finance textbook cover-to-cover. They are the concepts that textbooks assume you already know, and that junior quant roles assume you learned somewhere else.
Master these five, and you will stop generating phantom alpha. The rest you can learn while building.
Why Most Engineers Get Burned on Data Before They Get Burned on Strategy
Before diving into the five concepts, it helps to understand why engineers are particularly vulnerable to financial data traps.
Software engineers think in deterministic systems. A database returns a value. A function returns a value. The same input always produces the same output. This mental model is correct for code. It is dangerously incorrect for financial data.
Financial data carries embedded assumptions about what a price means, when it applies, and what adjustments have been applied to it. Two price feeds can both report "the AAPL close price" and return different numbers on the same day. Neither is wrong. They are answering different questions.
The five concepts in this article are the ones where this mismatch most commonly causes backtesting disasters:
- Adjusted close and price adjustment — how splits, dividends, and corporate actions reshape historical prices
- Ex-dividend dates — the sharp discontinuities that appear in unadjusted data
- Short selling mechanics — the costs, risks, and mechanics of betting against an asset
- Options fundamentals — the vocabulary, pricing logic, and Greeks that underpin modern quantitative strategies
- Futures basics — contango, backwardation, settlement mechanics, and why futures data behaves differently from spot
Each of these has a direct implementation consequence. Understanding them is not optional if you are building systems that consume financial data or design strategies that interact with real market mechanics.
Concept 1: Adjusted Close and the Anatomy of Price Adjustment
The Problem with Raw Close Prices
When a stock trades at $150 on Tuesday and closes at $151 on Wednesday, a naive data pipeline reports a $1 gain. But what if between those two closes, the company executed a 10-for-1 stock split? In that case, every Tuesday price must be divided by 10 to be comparable to Wednesday prices. The raw close data shows a gain. The split-adjusted data shows a fractional loss.
This is not a hypothetical edge case. Stock splits happen routinely. More importantly, cash dividends cause a similar but subtler effect: when a company pays a $0.96 quarterly dividend, the stock price theoretically drops by $0.96 on the ex-dividend date, not because the company lost value, but because that value was distributed to shareholders.
If your backtest uses unadjusted closes to compute returns, you are including phantom gains from dividend payments. Strategies that appear to generate alpha from dividend-rich stocks are often just harvesting a data artifact.
What Adjusted Close Actually Means
Adjusted close is a backward-looking correction applied to historical prices. It retroactively modifies every pre-event price so that return calculations remain consistent across the corporate action.
Three types of adjustments exist:
| Adjustment Type | Trigger | How It Adjusts Price |
|---|---|---|
| Stock split | Forward split (e.g., 2-for-1) | All prior prices divided by 2 |
| Cash dividend | Ex-dividend date | Prior prices reduced by dividend amount |
| Stock dividend | Bonus shares issued | Prior prices adjusted by the ratio of new to old shares |
A common misconception is that adjusted close only corrects for splits. In practice, most data providers apply a "split-adjusted" close that accounts for both splits and dividends. Some apply a "total return" adjustment that also adds back dividend reinvestment effects.
When you pull historical price data from TickDB's kline endpoint, the OHLCV fields reflect the adjusted close convention used by the data provider. For US equities, this is typically split-and-dividend adjusted. For crypto, adjustments are generally not applied because there are no corporate actions.
The Implementation Consequence
import os
import requests
# Fetch 6 months of AAPL daily data — adjusted close convention
# ⚠️ Always verify adjusted vs. unadjusted with your data provider
# TickDB's kline endpoint returns adjusted data for US equities
headers = {"X-API-Key": os.environ.get("TICKDB_API_KEY")}
params = {
"symbol": "AAPL.US",
"interval": "1d",
"limit": 180 # approximately 6 months
}
response = requests.get(
"https://api.tickdb.ai/v1/market/kline",
headers=headers,
params=params,
timeout=(3.05, 10)
)
data = response.json()
if data.get("code") == 0:
candles = data["data"]
for candle in candles[-5:]: # Show last 5 trading days
timestamp, open_, high, low, close, volume = candle
# close is already adjusted — do not apply a second adjustment
print(f"{timestamp}: close={close}")
else:
print(f"API error {data.get('code')}: {data.get('message')}")
Critical rule: If you are pulling data from multiple sources, verify the adjustment convention for each. Mixing adjusted and unadjusted data within a single backtest is the single most common cause of phantom Sharpe ratios.
Concept 2: Ex-Dividend Dates and the Discontinuity Problem
Why the Ex-Dividend Date Exists
When a company declares a dividend, it announces three dates:
- Declaration date: The board formally approves the dividend.
- Record date: The date on which shareholders must be on the books to receive the dividend.
- Payment date: The date the dividend is actually paid.
Between the record date and the payment date sits the ex-dividend date, typically one business day before the record date. On the ex-dividend date, the stock begins trading "ex-dividend," meaning new buyers are not entitled to the upcoming dividend. The theoretical price drop on the ex-dividend date equals the dividend amount.
This creates a discontinuity in unadjusted price series:
Day -3: Close $100.00 (last day buyer receives dividend)
Day -2: Open $100.00 (no trading on weekend)
Day -1: Open $99.04 (ex-div open: $100.00 - $0.96 dividend = $99.04)
Day -1: Close $99.20
In an unadjusted price series, this looks like a $0.80 loss with no apparent cause. In an adjusted series, prior prices are reduced by $0.96, making the ex-div day look flat.
Why This Matters for Your Backtest
If your strategy has any sensitivity to single-day price moves, the ex-dividend date can generate false signals. This is particularly dangerous for:
- Mean-reversion strategies: A $0.96 dividend drop looks like a textbook mean-reversion opportunity. The price will not revert; the dividend was already paid out.
- Breakout strategies: A stock breaking above its prior close on the ex-dividend date may not actually be breaking through any real resistance.
- Pairs trading: If two stocks in a pair have different ex-div calendars, the divergence on ex-div days can generate spurious signals that dominate your statistical analysis.
The Implementation Fix
Most quality data providers (including TickDB) apply ex-dividend adjustments retroactively. However, you should still write your code defensively:
from datetime import datetime, timedelta
def is_ex_dividend_date(symbol, date, dividend_schedule):
"""
Check if a given date is an ex-dividend date for a symbol.
dividend_schedule: dict mapping ex-div dates to dividend amounts
"""
date_str = date.strftime("%Y-%m-%d")
return dividend_schedule.get(date_str, 0.0)
# When computing returns around known ex-div dates,
# flag the return as dividend-adjusted vs. price-only
def compute_adjusted_return(close_prev, close_curr, dividend_amount):
"""Correct for dividend drop on ex-div day."""
if dividend_amount > 0:
# Price dropped due to dividend distribution — add it back
price_return = (close_curr + dividend_amount - close_prev) / close_prev
else:
price_return = (close_curr - close_prev) / close_prev
return price_return
Rule of thumb: If your strategy references single-day returns, always check whether any of those days are ex-dividend dates for the positions you hold or are analyzing. Calendars of ex-div dates for major US equities are publicly available from exchanges.
Concept 3: Short Selling — Mechanics, Costs, and Data Implications
The Basics of Being Net Short
Going long is intuitive: you buy an asset, you own it, you profit if it rises. Going short is the inverse: you borrow an asset, sell it at today's price, and aim to buy it back later at a lower price, returning the borrowed shares and keeping the difference.
Short selling introduces three categories of complexity that do not exist in long-only strategies:
Borrow costs: You pay a fee to borrow shares. This fee varies by stock and by market conditions. Heavily shorted stocks can have borrow rates exceeding 50% annualized. Small-cap stocks with limited share availability can be impossible to borrow.
Margin and liquidation risk: Your broker lends you the shares against collateral. If your position moves against you, you receive a margin call. A short position in a stock that triples can generate losses that exceed your initial investment.
Dividend obligations: When you short a stock, you owe the lender the dividends paid during the loan period. Shorting a high-dividend stock can erode returns significantly if you do not account for this cost.
Short Interest and the Meaning of Days to Cover
Short interest is the total number of shares sold short but not yet covered. It is expressed as a percentage of float (shares available for trading). High short interest indicates a crowded bearish bet.
Days to cover is short interest divided by average daily volume:
Days to Cover = Short Interest / Average Daily Volume (shares)
A high days-to-cover ratio signals that covering short positions could take weeks. If a short squeeze occurs — a rapid price increase forcing short sellers to buy back shares — the buying pressure compounds because everyone is covering simultaneously. This is not a theoretical scenario. GameStop in January 2021 demonstrated how days-to-cover ratios above 10 can produce violent short squeezes.
Short Selling Data in Practice
TickDB does not provide short interest data directly. However, understanding its implications matters when you design strategies that interact with shortable assets:
- Stat arb strategies: Long-short equity strategies typically net their exposure. The short side incurs borrow costs that must be factored into your expected return model.
- Event-driven strategies: High short interest amplifies short squeeze risk around positive catalysts (earnings beats, FDA approvals, contract wins).
- Options market structure: Elevated short interest often correlates with elevated put buying, which affects implied volatility surfaces and your options strategy design.
Concept 4: Options Fundamentals for Engineers Who Think in APIs
Why Options Are Not Just "Bets on Stocks"
Options are contracts that give the holder the right — but not the obligation — to buy (call) or sell (put) an underlying asset at a specified price (strike) before a specified date (expiration).
What makes options uniquely powerful for quants is that they encode information about the market's expectations. The price of an option reflects the market's estimate of the probability distribution of future stock prices. This is why options data is a primary input for volatility models, event-driven strategies, and risk management systems.
The Core Vocabulary
| Term | Plain-English Definition | Engineering Analogy |
|---|---|---|
| Call option | Right to buy at strike price | Forward contract with a cap on your cost |
| Put option | Right to sell at strike price | Insurance against price decline |
| Strike price | Fixed price in the contract | The "deal price" parameter |
| Expiration | Last day the option is valid | TTL (time-to-live) in a caching system |
| Premium | Price you pay for the option | Cost of the contract |
| In the money (ITM) | Strike is favorable relative to spot | Deep value / already-profitable |
| Out of the money (OTM) | Strike is unfavorable relative to spot | Deep discount / speculative |
| At the money (ATM) | Strike equals approximately spot | Baseline reference point |
The Black-Scholes Foundation
The Black-Scholes model provides a closed-form solution for European option pricing. Even if you do not implement it from scratch, understanding its inputs is essential because they appear everywhere in quantitative trading:
Call Premium = f(S, K, T, r, σ)
Where:
S = Current stock price
K = Strike price
T = Time to expiration (in years)
r = Risk-free interest rate
σ = Volatility (standard deviation of annual returns)
The critical insight is that volatility (σ) is the only input that cannot be directly observed. You must estimate it from historical data (historical volatility) or infer it from current option prices (implied volatility). This is the foundation of the volatility surface — a 3D plot of implied volatility across strikes and expirations.
The Greeks: First-Order Sensitivities
Options prices change in response to five factors. The "Greeks" quantify each sensitivity:
| Greek | Measures | Typical Use |
|---|---|---|
| Delta (Δ) | Price sensitivity to underlying move | Hedging, position sizing |
| Gamma (Γ) | Rate of change of delta | Understanding hedging frequency |
| Theta (Θ) | Time decay per day | Decay is your enemy when long options |
| Vega (ν) | Sensitivity to volatility change | Volatility trading |
| Rho (ρ) | Sensitivity to interest rate change | Typically negligible for short-dated options |
For a programmer, the Greeks are functions, not constants. Delta changes as the stock moves, as time passes, and as implied volatility shifts. Building a position that is "delta-neutral" requires continuous rebalancing.
Where Options Data Comes From
TickDB does not currently offer options chain data. However, understanding options mechanics is essential for:
- Backtesting event-driven strategies that interact with earnings, FDA decisions, or macro events where implied volatility moves are a core signal
- Understanding why market makers widen spreads before earnings announcements
- Designing multi-leg strategies that use options to hedge tail risk in your core equity positions
For options data, dedicated providers include CBOE, OCC, and aggregators like Databento. Integrating options data with equity price data from TickDB is a common architecture in production quant systems.
Concept 5: Futures Basics — Contango, Backwardation, and Settlement Mechanics
What a Futures Contract Actually Is
A futures contract is an agreement to buy or sell an asset at a predetermined price on a future date. Unlike a stock, the "price" of a futures contract is not a current market value — it is a forward price reflecting expectations about the asset's value at settlement.
Futures exist for commodities (oil, gold, wheat), indices (S&P 500 E-mini, Nasdaq), currencies, and increasingly, crypto (BTC futures on CME). Each contract has:
- Underlying: The asset being traded
- Contract size: How much of the underlying one contract controls
- Expiration date: When the contract settles
- Settlement method: Cash-settled vs. physically delivered
Contango and Backwardation
The relationship between the futures price and the expected future spot price defines two regimes:
Contango (the normal case): Futures price > Current spot price
Current oil spot: $80.00
3-month oil futures: $82.50 (+3.1% premium)
Contango exists because holding futures has costs — storage (for physical commodities), financing (cost of carry), and convenience yield (the benefit of physically holding the asset).
Backwardation (the exception): Futures price < Current spot price
Backwardation occurs when the spot price includes a premium for immediate delivery scarcity. This happens in oil markets during supply gluts, or in equity index futures during crisis periods when investors are willing to accept below-spot prices to get exposure quickly.
Why This Destroys Long-Term Commodity Backtests
If you backtest a strategy that holds oil futures long-term, the roll return — the return from rolling from an expiring contract to the next — compounds against you in contango markets.
Oil contango scenario:
You hold front-month oil futures expiring in 30 days
You must sell the expiring contract at $80 and buy the next contract
Next contract costs $82.50 due to contango
Roll cost = $2.50 per barrel = -3.1% loss on every roll
This is why commodity indices have historically underperformed the spot price of the underlying commodities. Long-only commodity strategies without active roll management erode in contango markets. This is not a data error. It is a structural cost of futures-based investing.
Settlement: Cash vs. Physical
Most financial futures (equity index, treasury, crypto) are cash-settled: at expiration, the contract settles to a calculated reference price, and no physical asset changes hands.
Commodity futures (oil, gold, agricultural) can be physically delivered: if you hold the contract to expiration, you are obligated to receive (or deliver) the physical commodity. Most traders never intend physical delivery, but the possibility affects the dynamics near expiration.
Understanding settlement mechanics matters for:
- Last-day trading: Prices can behave erratically on the final trading day as the contract converges to the settlement price
- Roll timing: Choosing when to roll from the front-month to the next contract affects your entry/exit prices
- Data consistency: Settlement prices may differ from the last traded price — ensure your data source specifies which price it reports
The Five Concepts: A Practical Integration Guide
Here is how these five concepts connect in a typical quant workflow:
| Phase | Where These Concepts Appear |
|---|---|
| Data ingestion | Verify adjusted vs. unadjusted close (Concept 1); flag ex-div dates (Concept 2) |
| Signal generation | Account for dividend adjustments in single-day return calculations (Concepts 1, 2) |
| Portfolio construction | Model short borrow costs and margin requirements (Concept 3) |
| Risk management | Use options Greeks for delta hedging (Concept 4); understand implied vs. realized vol |
| Execution analysis | Handle futures roll costs in commodity strategies (Concept 5) |
These are not isolated topics. A sophisticated event-driven strategy that holds short options positions into earnings must account for short borrow costs (Concept 3), the ex-div date of the underlying (Concept 2), and the implied volatility crush that follows the announcement (Concept 4).
Next Steps
If you are an engineer building your first quant system, start by auditing your data pipeline for adjusted vs. unadjusted price sources. This single check will eliminate the most common class of backtesting failures.
If you want to test these concepts against real market data, sign up at tickdb.ai for a free API key. The /v1/market/kline endpoint provides 10+ years of split-and-dividend-adjusted OHLCV data for US equities, which gives you a clean foundation for computing return series without phantom dividend artifacts.
If you need historical options data to build volatility models, combine TickDB's equity price data with a dedicated options data provider. The equity OHLCV from TickDB serves as the underlying price feed for any options pricing model you implement.
If you use AI coding assistants, search for and install the tickdb-market-data SKILL in your AI tool's marketplace. It provides pre-built utilities for fetching adjusted close data, handling WebSocket subscriptions, and computing rolling returns — allowing you to focus on strategy logic rather than data plumbing.
This article does not constitute investment advice. Markets involve risk; past performance does not guarantee future results.