メインコンテンツまでスキップ

実行ダッシュボード(Next.js)

dashboard/ は、Postgres をバックエンドに使う ATC の統合UIです。
教師データ(期待ポジション)作成と、戦略比較・実験実行を1画面で扱います。

主な機能

  • 戦略比較
  • 一覧ページ(/strategies)と詳細ページ(/strategies/{strategy})で比較
  • 比較期間ごとの結果と日次推移を表示
  • 実レートのOHLC + 出来高 + 発注/ポジションのオーバーレイ表示
  • 教師データ作成(アノテーション)
  • annotation_projects でプロジェクト管理
  • annotation_pointsHOLD / FLAT / SHORT と期待ポジションを保存
  • 実験トリガー
  • Dashboard から atc backtest をジョブとして起動
  • experiment_jobs で状態・標準出力/標準エラーを追跡

データソース

  • Postgres
  • market_trade_events
  • backtest_runs
  • backtest_run_daily
  • backtest_order_events
  • strategy_metadata
  • derived_report_rows(可変列は JSONB
  • annotation_projects
  • annotation_points
  • experiment_jobs

事前準備

just db-dev-up
just db-migrate-up
just db-import-postgres

リモートDBを使う場合は .env に接続情報を設定します。 必要なキーは .env.example を参照してください。

起動

just dashboard-install
just dashboard-dev

ブラウザ: http://localhost:3000

API

  • GET /api/strategies/overview
  • GET /api/strategies/runs?strategy=...
  • GET /api/strategies/orders?runId=...
  • GET /api/market/history?...
  • GET|POST /api/annotations/projects
  • GET|POST /api/annotations/points
  • GET /api/experiments/runs
  • POST /api/experiments/trigger

比較データバックフィル(全戦略)

比較用の固定期間(2025-10, 2025-11, 2025-12, 2026-01-01~2026-02-21)と 週次8区間(cmp2026_w01cmp2026_w08)の不足分を補完するには:

uv run python scripts/backfill_compare_runs.py

4並列で実行する場合:

for i in 1 2 3 4; do
args=()
while IFS= read -r strategy; do
[ -n "$strategy" ] && args+=(--strategy "$strategy")
done < "logs/backfill_shards/worker_${i}.txt"
uv run python scripts/backfill_compare_runs.py "${args[@]}" > "logs/backfill_shards/run_worker_${i}.log" 2>&1 &
done

進捗確認:

ps -axo pid,etime,stat,pcpu,command | grep -E 'uv run atc backtest|backfill_compare_runs.py' | grep -v grep

欠損判定の基準:

  • 比較カバレッジ欠損: 全戦略 × 12期間に対して backtest_run_daily 行数が期間日数未満
  • 注文イベント欠損: backtest_order_events が0件
  • baseline_flat は注文0件が自然なので、注文イベント欠損は別指標で扱う

/api/market/history の挙動

  • 指定期間がDB上で空の場合、バックエンドが不足日を atc ingest historical で自動取得して再クエリ
  • それでも空の場合、最新データ時刻に合わせた同幅ウィンドウへフォールバック
  • 追加クエリ: autoFetch=true|false(省略時は有効)

主な追加レスポンス:

  • requested_start, requested_end
  • effective_start, effective_end
  • latest_available_ts
  • auto_fetch_enabled, auto_fetch_triggered, auto_fetch_error
  • fallback_applied

環境変数:

  • ATC_MARKET_HISTORY_AUTO_FETCH(default: true
  • ATC_MARKET_HISTORY_AUTO_FETCH_TIMEOUT_MS(default: 180000