Install
pip install "aperiodic[polars]" pandas vectorbtThe code
# pip install "aperiodic[polars]" pandas vectorbt
from datetime import date
import aperiodic
import vectorbt as vbt
window = dict(
timestamp="exchange", interval="5m", exchange="binance-futures",
symbol="perpetual-BTC-USDT:USDT", start_date=date(2025, 5, 1),
end_date=date(2025, 5, 31), preview=True, output="pandas",
show_progress=False,
)
bars = aperiodic.get_ohlcv(**window).set_index("time")
flow = aperiodic.get_metrics(metric="flow", **window).set_index("time")
# Share of taker volume that was buying, per 5-minute bar
buy_share = flow["taker_buy_volume"] / (
flow["taker_buy_volume"] + flow["taker_sell_volume"]
)
entries = buy_share > buy_share.quantile(0.95)
exits = entries.shift(6, fill_value=False) # hold for 30 minutes
pf = vbt.Portfolio.from_signals(
bars["close"], entries, exits, fees=0.0005, freq="5min"
)
print(entries.sum(), "entries")
print(pf.stats())What it prints: 447 entries, then VectorBT’s stats table for the portfolio.
How the data fits VectorBT
Why the result is not on this page
One month of one coin, with 5 bps fees and no slippage model, is enough to check the plumbing and far too little to judge the signal. Run it on years of bars and more coins before you read anything into the stats.
Bars are stamped at their open
The time column is the start of the bar: the first 5-minute bar of May 2025 is 2025-05-01 00:00:00 UTC, and its metrics describe what happened until 00:05. A signal built from a bar is known at its close, so trade on it from the next bar.
Exchange time or arrival time
timestamp="exchange" builds every bar on the venue’s clock. timestamp="true" builds it on when each event reached our collectors closest to the exchange, so a bar holds only what a live strategy could have seen by its close. That is the clock to backtest on if you plan to trade live. The preview is exchange time only; local time comes with a plan.
Metrics join on time
Every dataset shares the same time column for a given symbol, interval and timestamp choice, so OHLCV, flow, funding or open interest join on the index without resampling.
The preview is one month of one coin
Without a key, every dataset previews the Binance BTCUSDT perpetual at 5 minutes for May 2025. With a free account’s key, drop preview=True and pass api_key= for every metric over 2025 on BTC, ETH, SOL and 10 RWA perps, on any venue, from 1 minute to 1 day. A plan opens every perp and every year.
Delisted coins are in the data
On a plan, the same call works for every perpetual on Binance, OKX and Hyperliquid, including the ones since delisted, so a cross-sectional backtest has no survivorship bias. Published bars are never recalculated, so it reads the same history next year.
Pull years at once
Set start_date and end_date years apart and the SDK downloads the parquet files in parallel, 10 at a time by default (max_concurrent). Prime and above have no API rate limits; Pro has high ones.
Beyond the preview
The snippet uses ohlcv and flow. Swap in any of the 220 metrics across 19 datasets (catalog). A free account gets all of them for 2025 on BTC, ETH, SOL and 10 RWA perps. For every perp and every year, funding, open interest, basis, slippage and price impact are on Pro, from $199 a month billed yearly, and L1 and L2 order book imbalance and liquidity are on Prime (pricing). The VectorBT documentation covers everything on its side.