vike-cli data
Get market data into the hist store without knowing a second binary's name — fetch real public bars or seed the synthetic demo tape, with an optional --json document describing the run.
data puts bars into the hist store the backtest engine reads. It is not a collector: every
byte of the work is done by the standalone backtest engine, which has carried --fetch and
--seed-demo since long before this verb existed. What was missing was discoverability —
vike-cli init ends by telling a new user to run backtest --seed-demo, which is a different binary
with a different name, and somebody who installed "the vike CLI" has no reason to expect that the
tool which runs a backtest is not the tool which fetches the data for one. So this is a route
(crates/vike-cli/src/cmd/data.rs), and crate::cmd::engine is the one place that knows where the
engine lives and what its exit codes mean.
It could not be anything else. Fetching writes a hist store, which needs DataFusion, and this crate's whole identity is being DataFusion-free — see the dispatcher.
usage: vike-cli data fetch <SPEC> (--days N | --from LABEL --to LABEL) [--store DIR] [--json]
vike-cli data seed-demo [--store DIR] [--json]Subcommands
| subcommand | what it writes |
|---|---|
fetch SPEC | real public bars, over a window. SPEC is VENUE:SYMBOL:INTERVAL, e.g. binance:BTCUSDT:1h. No credentials — this is public market data |
seed-demo | the synthetic demo tape: venue demo, a closed-form curve, not market data. It is the slice the shipped user_data/profiles/backtest.toml names, so a fresh install can run that profile immediately. Safe to re-run |
Flags
| flag | meaning |
|---|---|
--days N | fetch: a window counting back from now |
--from LABEL / --to LABEL | fetch: an explicit window — epoch-ms, or YYYY-MM-DDTHH. The two go together |
--store DIR | the hist-store root to write into |
--engine PATH | the standalone engine to run, instead of searching <project>/bin, this executable's directory, and PATH |
--json | one JSON object on stdout describing the run |
-h, --help | the usage, on stdout, exit 0 |
A window is required on fetch and refused on seed-demo. Mixing the two window forms is an error
rather than a precedence rule: --days 30 --from 2026-01-01T00 has two readable meanings and no
obviously right one, and whichever a rule picked would silently discard half of what was typed. The
same reasoning refuses --days on seed-demo instead of ignoring it — the demo tape is a fixed
synthetic span, and a quietly-ignored --days 30 leaves an operator believing they seeded a month.
What is validated here is the spec's shape — three non-empty :-separated parts — and the
window. The venue and the interval are not: which venues a build can reach is a property of the
engine's own feature set and its collectors, and a roster copied into this crate would be a second
list to keep in step, refusing a venue the engine supports or accepting one it does not with equal
confidence. The engine's own error names what it can do.
--json
Both subcommands take it, because both write to a store and what was written and where is exactly
the question a caller driving this verb has. The document is report_json's, and it carries the
request, the engine and the engine's own report:
| field | what it holds |
|---|---|
subcommand | fetch or seed-demo |
store | what --store named, or null when the flag was absent — not a resolved path |
series | the spec split into venue / symbol / interval, plus the spec as typed; null for seed-demo |
window | {days} or {from,to}; null for seed-demo |
engine | the engine binary this process actually ran |
engine_argv | the argv it ran with |
report | the engine's own stdout, line by line, verbatim |
Two of those are honest about a limit rather than convenient. store is null rather than a path
when no --store was given, because with the flag absent the engine resolves the root, in a
different process, and this side would be guessing. And report is left as lines: backtest --fetch
prints N bars returned … M rows written and --seed-demo prints a line per slice, and neither has
a machine mode of its own — so fielding those counts would mean re-implementing another crate's
output format in a crate that cannot see it change, which would start reporting a wrong count
rather than failing the day a word moves.
Under --json the engine's report moves to stderr and stdout carries the document and nothing
else. The lines are not lost: they are echoed to stderr as they arrive and appear again in report.
A failure emits no document — read the exit code
The document is printed on success only, which is the shape every sibling in this crate already
has (secrets list, init,
backtest): a failure is a sentence on stderr plus a rung on the
exit ladder, and stdout carries nothing at all. It is deliberately not an
{"ok": false} document — matching every sibling beats being cleverer than them in one, and a
caller already has to read the exit code, which is the field such a document would duplicate.
The rung is the same one the human path gives. A --json that folded the child's status
differently would tell a wrapper to retry, or not to, on the strength of an output format; both paths
call the one fold_status in crates/vike-cli/src/cmd/engine.rs. A bad command line is 2, an
engine that ran and failed is 1, and an engine that could not be started at all is 3 — the rung a
wrapper may back off and retry on.
Where the engine comes from
--engine PATH wins and is not probed for existence: a named path that is not there must fail
with the name the operator typed, never by falling through to a different engine they did not ask
for. Otherwise engine::locate looks in <project>/bin (the directory
vike_model::state_path::PROJECT_BIN_DIR names), then beside this executable, then leaves the bare
name for PATH to resolve. A spawn failure is one message either way, so the two --json and human
paths cannot describe the same failure differently.
Examples
vike-cli data seed-demo # the synthetic tape, no network
vike-cli data fetch binance:BTCUSDT:1h --days 180 # real public bars
vike-cli data fetch okx:BTC-USDT:1h --from 2026-01-01T00 --to 2026-02-01T00 --json- The
backtestbinary — what--fetchand--seed-demobelong to, and the store precedence they use. - Running a backtest — what to do with the data once it is there.