Run from the command line¶
Installing the package registers the ob-analytics command. Put
-v / --verbose before the subcommand for debug-level logging. Every
subcommand calls its input path and its output -o / --output. The
CLI flag reference lists every flag of every
subcommand.
| Subcommand | Description |
|---|---|
process |
Run the pipeline on a data source and save the result (optional --gallery) |
audit |
Check a run's data quality; exit non-zero when a check fails (old name: validate) |
gallery |
Generate an HTML plot gallery from saved Parquet data |
bitstamp-demo |
Run the Bitstamp demo (pipeline + gallery) |
lobster-demo |
Run the LOBSTER demo on local data (pipeline + gallery) |
capture |
Live-capture market data from a registered source ([live] extra) |
sources |
List the registered sources, what each can do, and the keys it needs |
# Process a data source
ob-analytics process orders.csv -o results/
ob-analytics process data/ --source lobster --trading-date 2012-06-21
ob-analytics process orders.csv -o results/ --gallery --backend plotly
# Check data quality (crossed book, dropped messages, impossible values, ...)
ob-analytics audit orders.csv
ob-analytics audit orders.csv --json
ob-analytics audit results/ --from-parquet --strict
# Build a gallery from saved Parquet
ob-analytics gallery results/ -o my_gallery/
ob-analytics gallery results/ --title "My Analysis"
# End-to-end demos (pipeline + gallery)
ob-analytics bitstamp-demo orders.csv -o demo_out/
ob-analytics lobster-demo /path/to/lobster_data --trading-date 2012-06-21 -o demo_out/
# Live capture
ob-analytics capture bitstamp --pair btcusd --minutes 10 -o capture/
ob-analytics capture ccxt --venue kraken --pair BTC/USD -o kraken/
process saves each table with the run's config and declarations. gallery and
audit --from-parquet read the run back with
load_result, so a saved run
keeps its tick size, lot size and display precision: a LOBSTER run still shows
whole shares. Given a live capture, process and audit use the tick size and
lot size in its meta.json, as Pipeline.run does in Python.
The bitstamp-demo and lobster-demo subcommands run the pipeline, save
Parquet and build an HTML plot gallery. bitstamp-demo --roundtrip also
writes the result and reads it back to check the round trip.
process --gallery, gallery and the two demos take the same gallery
options: --view, --backend and --title.
A missing input file or a bad setting ends the command with one line on
stderr, starting ob-analytics: error:, and exit code 1.
Set how the pipeline runs¶
process and audit take the settings that PipelineConfig and
RunContext take in Python:
| Flag | Python | What it sets |
|---|---|---|
--tick-size |
PipelineConfig(tick_size=...) |
The price step, in the quote currency, and the decimals shown |
--lot-size |
PipelineConfig(lot_size=...) |
The size step, in the base asset, and the decimals shown |
--depth-bins |
PipelineConfig(depth_bins=...) |
Number of depth bins on each side of the book |
--depth-bps |
PipelineConfig(depth_bps=...) |
Width of each depth bin, in basis points |
--trading-date |
RunContext(trading_date=...) |
The date of a session-relative feed (LOBSTER) |
--session-tz |
RunContext(session_tz=...) |
The venue's time zone for a session-relative feed |
--symbol |
RunContext(symbol=...) |
The instrument, in a symbol column on each row |
--venue |
RunContext(venue=...) |
The venue, in a venue column on each row |
ob-analytics process capture/ --tick-size 0.001 --lot-size 0.0001
ob-analytics process data/ --source lobster --trading-date 2012-06-21 --session-tz Europe/London
A flag left out keeps the source's default. A capture's tick size and lot size
come from its meta.json unless --tick-size or --lot-size is given.
audit --from-parquet refuses these flags: a saved result keeps the settings
of its own run.
Choose the source and its settings¶
--source names the source that reads the input. A live capture needs none:
its meta.json names the source that reads it back, such as depth_csv for a
ccxt capture. For any other input the default is bitstamp. If --source
reads another level than the capture recorded (bitstamp on an L2 capture,
say), the command stops and names both. If it reads the same level but is not
the source the capture names, the command warns, names the recorded source, and
reads with yours.
Each field of the source's settings is a flag, as for capture. Add
--help after the path, or after --source, to list them:
ob-analytics process file.dbn.zst --source databento --help
ob-analytics process file.dbn.zst --source databento --instrument-id 1108 -o out/
ob-analytics process prices.csv --source depth_csv --price-divisor 100 -o out/
The flag reference lists the settings flags of each built-in source.
Save in another format¶
process --format saves in any format
save_data writes. A format
for this package (parquet, the default, depth_csv, bitstamp, lobster)
writes a folder; an export to another tool (hftbacktest, nautilus,
databento) writes one file, so give -o a file name with its extension:
ob-analytics process orders.csv --format bitstamp -o bitstamp_out/
ob-analytics process orders.csv --format hftbacktest -o session.npz
With --gallery, a folder holds its gallery in gallery/, and a file has its
gallery next to it, in <name>_gallery/. A segmented capture is saved as one
folder per segment, so it takes only a format that writes a folder.
Run one time window at a time¶
process --cut TIME cuts the input at TIME and runs the depth stages on one
window at a time, as
Pipeline.run_windows
does. Peak memory is then set by the largest window rather than by the whole
input. Give --cut once for each cut; a time with no zone is read as UTC:
Each window starts from the book the window before ended with, so the cuts do
not show in the output. --no-carry starts each window from an empty book
instead. A windowed run writes Parquet, and builds no gallery: run
ob-analytics gallery windows/ on its output.
Set up a capture source¶
The flags after capture <source> are the capture's own (--pair,
--minutes, -o / --output, --roll-minutes, --roll-mb, --no-raw)
and one for each field of the source's settings class. The
CLI flag reference lists
them for each built-in source, and --help lists them for any source:
For ccxt and cryptofeed, --venue names the venue; for kalshi,
--pair takes the market ticker; for kraken, --depth sets how many price
levels a side Kraken sends. A source from a
plug-in package gets its flags the same way, so it is set up from the command
line as from Python. A field gets a flag named after it when its type is one
the command line reads (str, int, float, bool, a Literal, an Enum
or Path); a field marked with CliOption takes its
help text, flag name or value type from the marker. An API key is never a
flag: it is read from its environment variable (see
Use an API key).
Related¶
- CLI flag reference — every flag of every subcommand
- Check data quality with
audit— theauditverb in depth - Capture live data — the
captureverb in depth