Command Reference
This document explains each executable command in the ATC project.
Prerequisites
cd /Users/shion/workspace/crypto-auto-trading
uv sync --extra dev
1) atc CLI commands
The package exposes the atc entrypoint via:
uv run atc ...
1.1 atc ingest historical
Purpose:
- Download GMO historical trade CSV gzip files.
- Validate schema and data quality.
- Write raw files + manifests.
- Convert to canonical Parquet events.
- If raw data already exists locally, skip network acquisition and reuse local files.
Command:
uv run atc ingest historical --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31
Arguments:
--symbol(required): Symbol name (e.g.ETH_JPY).--start(required): Start business date inYYYY-MM-DD.--end(required): End business date inYYYY-MM-DD.--data-root(optional, defaultdata): Base directory for raw/canonical/derived data.
Typical output (JSON):
symbolstartendfiles_processedfiles_downloadedrows_processed
Data written:
- Raw gzip:
data/raw/historical_trades/{symbol}/{YYYY}/{MM}/{YYYYMMDD}_{symbol}.csv.gz - Manifest:
data/raw/historical_trades/{symbol}/{YYYY}/{MM}/{YYYYMMDD}_{symbol}.manifest.json - Canonical Parquet:
data/canonical/events/symbol={symbol}/year={YYYY}/month={M}/day={D}/...
1.2 atc backtest
Purpose:
- Load canonical events.
- Run event-driven strategy simulation.
- Apply risk checks and execution simulation.
- Simulate execution as limit-only with configurable order latency.
- Evaluate alpha metrics and save a report.
Command:
uv run atc backtest --symbol ETH_JPY --start 2022-01-01 --end 2022-12-31 --strategy baseline_momentum_micro
With trade overlay chart generation:
uv run atc backtest --symbol ETH_JPY --strategy baseline_momentum_micro --plot --plot-interval 1m
With both HTML and PNG at once:
uv run atc backtest --symbol ETH_JPY --strategy baseline_momentum_micro --plot --plot-format both --plot-interval 1m
With explicit order latency:
uv run atc backtest --symbol ETH_JPY --strategy baseline_momentum_micro --order-latency-sec 0.3
With slower order cadence (5 minutes between submissions):
uv run atc backtest --symbol ETH_JPY --strategy baseline_momentum_micro --min-order-interval-sec 300
Arguments:
--symbol(required)--start(optional, default2021-05-01): business date (JST, 06:00 boundary).--end(optional, default2026-01-31): business date (JST, 06:00 boundary).--strategy(required)--data-root(optional, defaultdata)--plot(optional): Generate an overlay chart (price + order markers).--plot-output(optional): Output chart path (.htmlor.png).--plot-format(optional, defaulthtml):html,png, orboth.--plot-interval(optional, default1m): Derived bar interval for plotting.--order-latency-sec(optional, default0.3): Minimum delay before a submitted limit order becomes eligible for fill checks.--min-order-interval-sec(optional, default300): Minimum interval between new order submissions.--initial-position-eth(optional, default0.0): Starting position for the run. Useful for day-by-day chained analysis.--initial-cash-jpy(optional, default0.0): Starting cash for the run. Pair with--initial-position-ethto carry portfolio state.--target-abs-qty-eth(optional): Override strategy target absolute quantity (for strategies that supporttarget_abs_qty).--max-abs-position-eth(optional): Override risk hard limitmax_abs_position_eth.--benchmark-hold-eth(optional, default10.0): Fixed buy-and-hold benchmark quantity in ETH for alpha comparison.--enforce-session-close(optional, default disabled): Enable05:59-style close constraints.--no-new-entry-minutes(optional, default10): Applied only when--enforce-session-closeis enabled.--force-close-start-jst(optional, default05:55:00): Applied only when--enforce-session-closeis enabled.--close-deadline-jst(optional, default05:59:50): Applied only when--enforce-session-closeis enabled.--allow-market-fallback/--no-market-fallback(default enabled): Applied only when--enforce-session-closeis enabled.
Backtest day boundary:
- A single business date
YYYY-MM-DDmeansYYYY-MM-DD 06:00:00 JSTto next day05:59:59.999 JST. - Overlay chart time axis is displayed in JST.
Execution assumptions:
- Orders are always limit orders.
- Buy limit fill condition: subsequent trade price
<= limit_priceafter latency. - Sell limit fill condition: subsequent trade price
>= limit_priceafter latency. - Limit price selection in trade-only mode: buy uses
bid -> mid -> last, sell usesask -> mid -> last. - New orders are throttled by
min_order_interval_sec; strategy evaluation still runs on every event. - Alpha metrics are computed against fixed benchmark PnL:
benchmark_hold_eth * (mid(t)-mid(t-1)). - Session-close policy:
05:49:00-05:59:59 JST: no new entries.05:55:00-05:59:59 JST: forced close ladder (limit repricing).>=05:59:50 JSTand fallback enabled: force market close to reach flat.
Available baseline strategies:
baseline_flatbaseline_momentum_microbaseline_mean_reversion_microbaseline_inventory_mmbaseline_queue_imbalance_breakoutbaseline_sweep_followbaseline_regime_switch_microbaseline_flow_imbalance_pulsebaseline_technical_hold_overlay(10ETH hold-bias pseudo-technical overlay: de-risk on downside, rebuild on recovery)baseline_technical_hold_overlay_slow(lower-turnover conservative variant of technical hold overlay)ml_direction_linear(requires trained model file)ml_direction_logistic(requires trained logistic model file)ml_direction_logistic_swing(smoothed, lower-frequency ML strategy with cooldown/min-hold)ml_direction_logistic_swing_tokyo(swing model restricted to Tokyo session hours)ml_direction_logistic_swing_europe(swing model restricted to Europe session hours)ml_direction_logistic_swing_europe_conservative(Europe session with stricter signal/cadence controls)ml_direction_logistic_swing_europe_defensive(Europe session, trades only in local bearish micro-regime)ml_direction_logistic_swing_europe_regime2(Europe session tuned for stronger trend-following regime)ml_direction_logistic_swing_europe_regime3(Europe session tuned from expanded segmented search)ml_direction_logistic_swing_europe_robust(Europe session + outlier guard for anomalous feature states)ml_direction_logistic_swing_europe_ultra_conservative(Europe session with very strict low-turnover controls)ml_direction_logistic_swing_us(swing model restricted to US session hours)ml_direction_logistic_hold_overlay(10ETH long-bias overlay: hold by default, flatten/short only on strong downside signal)ml_direction_logistic_hold_overlay_regime_guard(hold overlay with downside/recovery confirmation filters to reduce whipsaw)ml_direction_logistic_hold_overlay_regime_guard_derisk_only(regime guard variant that de-risks to flat and avoids net-short)ml_direction_logistic_hold_overlay_regime_guard_conservative(regime guard variant with smaller/stricter short hedges)
Typical output (JSON):
symbol,strategyevents,intents,fillsfinal_position_eth,final_equity_jpymetrics.alpha_sharpemetrics.alpha_max_ddmetrics.turnover,metrics.fill_rate,metrics.adverse_selectionreport_pathplot_path(present when--plotis enabled)plot_html_path/plot_png_path(present when corresponding format is generated)benchmark_mode,benchmark_hold_ethsession_close_policyforced_close_orders,forced_close_fillsmarket_fallback_countdeadline_breach_flag
Report file:
data/derived/reports/backtest_{symbol}_{start}_{end}_{strategy}.json
1.2b Chart Legend (Daily / Overview)
Daily overlay chart (--plot-format png|both):
| Panel | Line / Marker | Meaning | Formula / Source | Why it matters |
|---|---|---|---|---|
| Price + Orders | Price (1m) candlestick | 1-minute OHLC built from event prices (JST axis) | trade/ticker price aggregated by group_by_dynamic | Market context for each order decision |
| Price + Orders | Buy Orders marker | Buy-side submitted/filled order points | marker on order reference/fill price | Visual check of long entries timing |
| Price + Orders | Sell Orders marker | Sell-side submitted/filled order points | marker on order reference/fill price | Visual check of short/exit timing |
| Price + Orders | Risk Rejected marker | Orders blocked by risk rules | risk gate result | Detects if limits are suppressing strategy actions |
| Position | Position ETH line | Net position over the day | simulated execution state | Confirms exposure control and reset/carry behavior |
| PnL vs Benchmark | Cum Strategy PnL line | Cumulative strategy PnL | cumulative sum of step strategy PnL | Raw strategy monetary result |
| PnL vs Benchmark | Cum Benchmark PnL line | Cumulative fixed benchmark PnL | benchmark_hold_eth * (mid(t)-mid(t-1)) cumulative | Baseline from passive hold (e.g. 10 ETH) |
| PnL vs Benchmark | Cum Alpha PnL line | Strategy excess PnL over benchmark | Cum Strategy PnL - Cum Benchmark PnL | Core metric: trading skill vs market drift |
Overview chart (monthly summary PNG generated from daily CSV):
| Panel | Line / Bar | Meaning | Formula / Source | Why it matters |
|---|---|---|---|---|
| Daily PnL | Daily Strategy PnL bar | Strategy PnL per business day | from each day backtest result | Day-by-day profitability distribution |
| Daily PnL | Daily Benchmark PnL (10ETH Hold) bar | Passive-hold daily PnL | fixed hold benchmark for same day | Market regime effect without strategy skill |
| Daily PnL | Daily Alpha PnL line | Daily excess over benchmark | Daily Strategy PnL - Daily Benchmark PnL | Direct daily skill score |
| Cumulative PnL | Cum Strategy PnL line | Running total strategy PnL | cumulative daily strategy PnL | Long-run monetary trajectory |
| Cumulative PnL | Cum Benchmark PnL line | Running total benchmark PnL | cumulative daily benchmark PnL | Drift-only baseline trajectory |
| Cumulative PnL | Cum Alpha PnL line | Running total excess PnL | cumulative daily alpha PnL | Whether edge accumulates over month |
| Orders/Fills | Orders bar | Submitted orders per day | daily backtest report | Activity/turnover intensity |
| Orders/Fills | Fills bar | Filled orders per day | daily backtest report | Execution efficiency with limit-only model |
1.3 atc replay
Purpose:
- Replay canonical events from a path.
- Run the same event-driven backtest pipeline.
Command:
uv run atc replay --from data/canonical/events/symbol=ETH_JPY --strategy baseline_flat
Arguments:
--from(required): Path to canonical event root or symbol partition path.--strategy(required)--symbol(optional): Explicit symbol override.
Typical output:
- Same JSON shape as
atc backtest(exceptreport_pathis not added here).
1.4 atc dataset
Purpose:
- Build derived feature datasets from canonical events.
- Reuse cached feature results when available.
- Support Rust or Python feature-generation backend.
Command:
uv run atc dataset --symbol ETH_JPY --start 2022-01-01 --end 2022-01-31 --name features_jan
Arguments:
--symbol(required)--start(required)--end(required)--name(optional, defaultfeatures)--data-root(optional, defaultdata)--feature-backend(optional, defaultrust):rustorpython.--workers(optional, default0): Rust backend worker count (0= auto).--no-cache(optional): force rebuild instead of cache reuse.
Typical output (JSON):
dataset_path
Dataset file:
data/derived/datasets/{name}.parquet
1.5 atc features cache
Purpose:
- Build a reusable feature cache from canonical events.
- Cache is stored as Parquet and can be reused by
atc dataset.
Command:
uv run atc features cache --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31 --feature-backend rust
Arguments:
--symbol(required)--start(required)--end(required)--data-root(optional, defaultdata)--feature-backend(optional, defaultrust):rustorpython.--workers(optional, default0): Rust backend worker count (0= auto).--no-cache(optional): force rebuild.
Typical output (JSON):
cache_pathmanifest_pathbackendcache_hiteventsrowsworkers
Cache file:
data/derived/features/cache/symbol={symbol}/backend={backend}/features_{start}_{end}_v1.parquet
1.6 atc ml
Purpose:
- Train machine-learning direction model from event-derived features.
atc ml train-direction
uv run atc ml train-direction --symbol ETH_JPY --start 2025-01-01 --end 2025-12-31 --horizon-sec 300
Arguments:
--symbol(required)--start(required)--end(required)--data-root(optional, defaultdata)--horizon-sec(optional, default300)--valid-ratio(optional, default0.2)--ridge-alpha(optional, default1.0)--model-output(optional): explicit model output path--workers(optional, default0): feature-generation workers (0= auto CPU cores minus one, capped at 5)--progress-every(optional, default1): print progress every N chunks--no-progress(optional): disable intermediate progress lines--no-update-latest(optional): do not overwrite latest model alias
Outputs:
- Model JSON at:
data/derived/models/ml_direction_linear_{symbol}_{start}_{end}.json- Latest alias (default):
data/derived/models/ml_direction_linear_latest.json- Metrics JSON:
{model_path}.metrics.json
atc ml train-direction-logistic
uv run atc ml train-direction-logistic --symbol ETH_JPY --start 2025-01-01 --end 2025-12-31 --horizon-sec 300
Arguments:
--symbol(required)--start(required)--end(required)--data-root(optional, defaultdata)--horizon-sec(optional, default300)--valid-ratio(optional, default0.2)--learning-rate(optional, default0.05)--l2-alpha(optional, default1e-4)--epochs(optional, default40)--target-mode(optional, defaultdirection):directionorhold10_oracle--oracle-sell-threshold-bps(optional, default25.0): forhold10_oracle, sell label threshold in bps--model-output(optional): explicit model output path--workers(optional, default0): feature-generation workers (0= auto CPU cores minus one, capped at 5)--progress-every(optional, default1): print progress every N chunks--no-progress(optional): disable intermediate progress lines
Outputs:
- Model JSON at:
data/derived/models/ml_direction_logistic_{symbol}_{start}_{end}.json- Metrics JSON:
{model_path}.metrics.json
atc ml build-image-dataset
uv run atc ml build-image-dataset --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31 --output-name image_alpha
Purpose:
- Build a multichannel image dataset for shadow comparison (
4 x H x W). - Apply session-aware drops:
- drop anchors in no-new-entry window.
- optionally drop cross-day horizon samples.
Arguments:
--symbol(required)--start(required)--end(required)--data-root(optional, defaultdata)--output-name(optional, defaultimage_alpha)--window-minutes(optional, default30)--image-size(optional, default128)--stride-sec(optional, default30)--horizon-sec(optional, default1800)--benchmark-hold-eth(optional, default10.0)--enforce-session-close(optional, default disabled)--no-new-entry-minutes(optional, default10, only when close constraints are enabled)--drop-cross-day/--allow-cross-day(default drop enabled)
Output JSON:
dataset_path,meta_pathrows_totaldropped_cross_daydropped_no_new_entry_windowdrop_ratio
atc ml train-image-alpha
uv run atc ml train-image-alpha --dataset-path data/derived/datasets/image_alpha_ETH_JPY_2026-01-01_2026-01-31.npz
Purpose:
- Train a lightweight image alpha regression model for shadow evaluation.
Arguments:
--dataset-path(required)--model-output(optional): default siblingml_image_alpha_linear_latest.json--valid-ratio(optional, default0.2)--ridge-alpha(optional, default1.0)
Output JSON:
model_pathrows_total,rows_train,rows_validtrain_mse,valid_msemetrics_path
atc ml shadow-compare
uv run atc ml shadow-compare \
--dataset-path data/derived/datasets/image_alpha_ETH_JPY_2026-01-01_2026-01-31.npz \
--output-csv data/derived/reports/shadow_compare_ETH_JPY_2026-01.csv
Purpose:
- Compare Tabular and Image expected-alpha scores on the same event sequence in shadow mode.
Arguments:
--dataset-path(required)--output-csv(required)--image-model-path(optional): default siblingml_image_alpha_linear_latest.json--tabular-model-path(optional): default logistic latest if present, otherwise linear latest--benchmark-hold-eth(optional, default10.0)
Output JSON:
rowstabular_target_corrimage_target_corrimage_better_rowstabular_better_or_equal_rowsoutput_csv_path
1.7 atc report
Purpose:
- Inspect generated report JSON.
- Build multi-strategy leaderboard for a fixed date window.
- Run walk-forward optimization for
baseline_regime_switch_micro.
atc report show
uv run atc report show --path data/derived/reports/backtest_ETH_JPY_2026-01-01_2026-01-01_baseline_momentum_micro.json
Arguments:
--path(required): JSON report path.
atc report leaderboard
uv run atc report leaderboard --symbol ETH_JPY --start 2026-01-01 --end 2026-01-07
Arguments:
--symbol(required)--start(required)--end(required)--data-root(optional, defaultdata)--strategy(optional, repeatable): Evaluate only the specified strategy names.--order-latency-sec(optional, default0.3)--min-order-interval-sec(optional, default300)
Output:
- JSON ranking sorted by
alpha_sharpedescending. - Parquet snapshot at:
data/derived/reports/leaderboard_{symbol}_{start}_{end}.parquet
atc report walk-forward
uv run atc report walk-forward --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31 --train-days 14 --valid-days 7 --step-days 7
Arguments:
--symbol(required)--start(required)--end(required)--data-root(optional, defaultdata)--train-days(optional, default14)--valid-days(optional, default7)--step-days(optional, default7)--session(optional, repeatable):TOKYO,EUROPE,US, orALL.--max-candidates(optional, default64)--workers(optional, default0): parallel workers for candidate evaluation (0= auto CPU cores minus one).--order-latency-sec(optional, default0.3)--min-order-interval-sec(optional, default300)--progress-every(optional, default10): print progress every N train evaluations.--no-progress(optional): disable intermediate progress lines.
Output:
- JSON summary with train/valid split results and best params per split.
- JSON file at:
data/derived/reports/walk_forward_regime_switch_{symbol}_{start}_{end}.json
atc report daily-eval
uv run atc report daily-eval --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31 --strategy baseline_regime_switch_micro
Purpose:
- Run day-by-day backtests with per-day reset (
start_position=0,start_cash=0). - Export daily metrics CSV, overall summary CSV, and overview PNG.
- Enforce fixed benchmark comparison (
10 ETH holddefault).
Arguments:
--symbol(required)--start(required)--end(required)--strategy(required)--data-root(optional, defaultdata)--benchmark-hold-eth(optional, default10.0)--target-abs-qty-eth(optional, default10.0)--max-abs-position-eth(optional, default10.0)--order-latency-sec(optional, default0.3)--min-order-interval-sec(optional, default300)--enforce-session-close(optional, default disabled)--no-new-entry-minutes(optional, default10, only when close constraints are enabled)--force-close-start-jst(optional, default05:55:00, only when close constraints are enabled)--close-deadline-jst(optional, default05:59:50, only when close constraints are enabled)--allow-market-fallback/--no-market-fallback(default enabled, only when close constraints are enabled)--plot-interval(optional, default1m)--plot-format(optional, defaultpng):png,html, orbothfor each daily overlay.--plot/--no-plot(default plot enabled): skip per-day overlay generation for faster iteration.
Generated outputs:
- Daily CSV:
strategy_total_pnl_jpybenchmark_total_pnl_jpyalpha_total_pnl_jpyorders,fills,fill_rate,turnoverforced_close_orders,forced_close_fillsmarket_fallback_countdeadline_breach_flag
- Overall CSV:
- totals, means, daily win-rate, max drawdown
- Overview PNG:
- daily Strategy/Benchmark/Alpha
- cumulative Strategy/Benchmark/Alpha
- orders/fills
2) just wrapper commands
just provides convenient wrappers around the atc CLI.
2.1 just sync
just sync
- Runs
uv sync --extra dev.
2.2 just test
just test
- Runs
uv run pytest -q.
2.3 just lint
just lint
- Runs
uv run ruff check src tests.
2.4 just typecheck
just typecheck
- Runs
uv run mypy src.
2.5 just ingest symbol start end
just ingest ETH_JPY 2026-01-01 2026-01-31
Equivalent to:
uv run atc ingest historical --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31
2.6 just backtest symbol start end strategy
just backtest ETH_JPY 2022-01-01 2022-12-31 baseline_momentum_micro
Equivalent to:
uv run atc backtest --symbol ETH_JPY --start 2022-01-01 --end 2022-12-31 --strategy baseline_momentum_micro
2.7 just features-cache symbol start end [backend]
just features-cache ETH_JPY 2026-01-01 2026-01-31 rust
Equivalent to:
uv run atc features cache --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31 --feature-backend rust
2.6b just backtest-default symbol strategy
just backtest-default ETH_JPY baseline_momentum_micro
Equivalent to:
uv run atc backtest --symbol ETH_JPY --strategy baseline_momentum_micro
2.7 just replay path strategy
just replay data/canonical/events/symbol=ETH_JPY baseline_flat
Equivalent to:
uv run atc replay --from data/canonical/events/symbol=ETH_JPY --strategy baseline_flat
2.7b just backtest-plot symbol strategy
just backtest-plot ETH_JPY baseline_momentum_micro
Equivalent to:
uv run atc backtest --symbol ETH_JPY --strategy baseline_momentum_micro --plot --plot-interval 1m
2.8 just compare-baselines symbol start end
just compare-baselines ETH_JPY 2022-01-01 2022-12-31
- 複数 baseline 戦略を同条件で順番に backtest します。
- 実行対象:
baseline_flatbaseline_momentum_microbaseline_mean_reversion_microbaseline_inventory_mmbaseline_queue_imbalance_breakoutbaseline_sweep_followbaseline_regime_switch_microbaseline_flow_imbalance_pulse
2.9 just leaderboard symbol start end
just leaderboard ETH_JPY 2026-01-01 2026-01-07
Equivalent to:
uv run atc report leaderboard --symbol ETH_JPY --start 2026-01-01 --end 2026-01-07
Output:
- Ranked strategy table in JSON (sorted by
alpha_sharpedescending). - Parquet snapshot at:
data/derived/reports/leaderboard_{symbol}_{start}_{end}.parquet
2.10 just walk-forward symbol start end
just walk-forward ETH_JPY 2026-01-01 2026-01-31
Equivalent to:
uv run atc report walk-forward --symbol ETH_JPY --start 2026-01-01 --end 2026-01-31
2.11 just ml-train-direction symbol start end
just ml-train-direction ETH_JPY 2025-01-01 2025-12-31
Equivalent to:
uv run atc ml train-direction --symbol ETH_JPY --start 2025-01-01 --end 2025-12-31
2.12 just ml-train-direction-logistic symbol start end
just ml-train-direction-logistic ETH_JPY 2025-01-01 2025-12-31
Equivalent to:
uv run atc ml train-direction-logistic --symbol ETH_JPY --start 2025-01-01 --end 2025-12-31
3) Built-in help
To confirm current options from source of truth:
uv run atc --help
uv run atc ingest historical --help
uv run atc backtest --help
uv run atc replay --help
uv run atc dataset --help
uv run atc ml --help
uv run atc ml train-direction --help
uv run atc ml train-direction-logistic --help
uv run atc ml build-image-dataset --help
uv run atc ml train-image-alpha --help
uv run atc ml shadow-compare --help
uv run atc report --help
uv run atc report leaderboard --help
uv run atc report walk-forward --help
uv run atc report daily-eval --help
just --list
4) Website and report article workflow
4.1 Install and run docs website
cd website
pnpm install
pnpm start
Build static site:
cd website
pnpm build
4.2 Convert backtest report JSON to website article
Command:
uv run python scripts/report_to_article.py \
--report data/derived/reports/backtest_ETH_JPY_2025-10-01_2026-02-11_ml_direction_logistic_hold_overlay_regime_guard.json
Useful options:
--output-dir(default:website/blog)--date(default: today,YYYY-MM-DD)--decision(default:保留)--note(optional free text)--overwrite(replace existing markdown)
Generated file:
website/blog/{YYYY-MM-DD}-{symbol}-{strategy}.md