Build an ML dataset
The quiet killer of financial ML is the dataset: features that quietly know the future. ?asof= returns what was knowable at that moment, nothing more, so the leakage class of bugs is gone before the first epoch.
The recipe
1. Features at time T
An as-of scan is a feature-vector factory: every ticker that existed at that moment, with 421+ computed columns as they stood.
curl -s -X POST "https://api.tickerbot.io/v2/scan" \
-H "Authorization: Bearer $TICKERBOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "q": "market_cap > 1e9",
"asof": "2023-06-01",
"columns": "ticker,price,rsi_14,pe_ratio,volume_change_vs_avg,day_change_pct" }'2. Labels at T+n
Forward outcomes come from /v2/series: pull the price path after the feature date and compute the label your task needs.
curl -s "https://api.tickerbot.io/v2/series?tickers=AAPL,MSFT,RIOT\
&columns=close&interval=1d&from=2023-06-01&to=2023-07-01" \
-H "Authorization: Bearer $TICKERBOT_API_KEY"3. The dataset loop
Walk the calendar: features as-of each date, labels from the window after it. The temporal boundary is enforced by the API, not by your discipline.
rows = []
for date in feature_dates: # e.g. monthly, 2018 → today
feats = scan(asof=date, q="market_cap > 1e9", columns=FEATURES)
prices = series(tickers=[f["ticker"] for f in feats],
columns="close", interval="1d",
frm=date, to=date + HORIZON)
for f in feats:
rows.append({ **f, "label": forward_return(prices, f["ticker"]) })
train, test = split_by_time(rows) # never randomly — by time4. Check what the data can support
Before trusting depth, ask for it: per-ticker, per-field measured coverage.
curl -s https://api.tickerbot.io/v2/tickers/AAPL/coverage \
-H "Authorization: Bearer $TICKERBOT_API_KEY"Endpoints used
| Endpoint | Role in this build |
|---|---|
POST /v2/scan + asof | Point-in-time feature vectors: what was knowable, when it was knowable |
GET /v2/series | The label side: forward price paths on one aligned grid |
GET /v2/tickers/{ticker}/coverage | Measured per-field depth: know your dataset’s limits up front |
GET /v2/tickers/symbols | The queryable universe, per asset class |