跳轉到

儲存、計算與存取

儲存層

資料平台不應只有一個資料庫,通常要分成多層。

冷資料儲存

建議用途:

  • raw archive
  • historical replay
  • 大規模 research
  • 補資料與重算

建議形式:

  • object storage
  • parquet
  • 依日期、source、channel 分區

串流層

建議用途:

  • 即時策略
  • 即時 aggregation
  • data quality checks
  • event-driven services

建議形式:

  • Kafka
  • Redpanda

查詢層

建議用途:

  • dashboard
  • recent analytics
  • research query
  • PnL attribution

可考慮:

  • QuestDB
  • ClickHouse

狀態層

建議用途:

  • instrument master
  • strategy config
  • account config
  • latest state cache
  • order state

可考慮:

  • Postgres
  • Redis

計算層

這層負責把 canonical event 轉成更可交易、更可分析的資料。

聚合

例如:

  • tick -> 1s
  • 1s -> 1m
  • 1m -> 5m / 15m / 1h

指標與特徵

例如:

  • MA
  • EMA
  • RSI
  • ATR
  • returns
  • realized volatility
  • spread

資料品質

至少應該監控:

  • gap detection
  • duplicate detection
  • stale feed detection
  • outlier detection
  • cross-source divergence

存取層

上層服務應該透過內部資料介面存取平台能力,而不是直接打外部 API。

建議存取方式:

  • internal query API
  • streaming consumer
  • backtest loader
  • replay feeder
  • feature service
  • execution gateway

實務原則

strategy 不應知道自己吃的是 live 還是 replay;這應由 runtime 與 access layer 負責抽象掉。