Files
2nd/10_Wiki/Topics/Computer_Science_and_Theory/High-Frequency-Trading-Models.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

5.3 KiB
Raw Blame History

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-high-frequency-trading-models High Frequency Trading Models 10_Wiki/Topics verified self
HFT
Algorithmic Trading
Market Making
none A 0.9 applied
hft
trading
latency
market-microstructure
2026-05-10 pending
language framework
cpp kdb+/qpython

High Frequency Trading Models

매 한 줄

"매 microsecond 매 alpha". HFT 매 nanosecond-scale latency 매 statistical arbitrage 의 결합 — 매 2026 quantum-resistant signature 매 co-located FPGA 매 standard. Renaissance, Citadel, Jump 매 dominant; 매 average holding period 매 sub-second.

매 핵심

매 latency hierarchy

  • L1 (sub-µs): FPGA tick-to-trade, kernel bypass NICs (Solarflare, Mellanox).
  • L2 (1-10µs): 매 C++ hot path, lock-free queues, busy-spin threads.
  • L3 (10-100µs): 매 Python/kdb+ 매 signal generation.
  • L4 (ms+): 매 ML inference (XGBoost, transformer order-flow).

매 strategy taxonomy

  • Market Making: 매 bid-ask spread capture, inventory risk hedge.
  • Statistical Arbitrage: 매 cointegration, mean reversion (Ornstein-Uhlenbeck).
  • Latency Arbitrage: 매 venue-to-venue price lag exploit.
  • Order-Flow Prediction: 매 LOB imbalance → micro-price drift.
  • Index Arbitrage: 매 ETF NAV vs constituent basket.

매 응용

  1. 매 NYSE/NASDAQ co-location.
  2. 매 crypto MEV (Flashbots, Jito).
  3. 매 forex ECN aggregation.

💻 패턴

1. Order Book Imbalance (LOB micro-price)

def micro_price(bid_px, bid_sz, ask_px, ask_sz):
    # 매 imbalance-weighted mid — predicts 100ms drift
    imb = bid_sz / (bid_sz + ask_sz)
    return ask_px * (1 - imb) + bid_px * imb

# 매 signal: micro_price - mid_price → directional alpha

2. Cointegration Pair Trade (Engle-Granger)

import statsmodels.api as sm
import numpy as np

def find_pairs(prices_a, prices_b):
    beta = sm.OLS(prices_a, sm.add_constant(prices_b)).fit().params[1]
    spread = prices_a - beta * prices_b
    adf = sm.tsa.adfuller(spread)
    return beta, adf[1]  # p-value < 0.05 → tradeable

# 매 entry: spread > 2σ, exit: spread → 0

3. Lock-Free Order Book (C++)

struct Level { std::atomic<int64_t> qty; int64_t px; };
struct Book { Level bids[1024]; Level asks[1024]; };

void on_tick(Book& b, int side, int idx, int64_t qty) {
    // 매 single-writer SPMC — no mutex
    auto& lvl = (side == 0) ? b.bids[idx] : b.asks[idx];
    lvl.qty.store(qty, std::memory_order_release);
}

4. Kalman Filter Spread Tracking

# 매 dynamic hedge ratio — beta drifts over time
from pykalman import KalmanFilter
kf = KalmanFilter(transition_matrices=[1], observation_matrices=[1],
                  initial_state_mean=0, initial_state_covariance=1,
                  observation_covariance=1, transition_covariance=0.01)
state_means, _ = kf.filter(spread_series)

5. FPGA Tick-to-Trade (Verilog sketch)

// 매 200ns tick parse → order send
always @(posedge clk) begin
    if (md_valid && (bid_px > threshold)) begin
        ord_send <= 1; ord_px <= bid_px; ord_qty <= 100;
    end
end

6. Almgren-Chriss Optimal Execution

def almgren_chriss(X, T, sigma, eta, gamma, lam):
    # 매 minimize: variance + market impact
    kappa = np.sqrt(lam * sigma**2 / eta)
    n_steps = int(T / dt)
    schedule = [X * np.sinh(kappa*(T-t)) / np.sinh(kappa*T) for t in times]
    return schedule  # 매 hyperbolic decay

7. ML Order-Flow (LightGBM)

import lightgbm as lgb
features = ['lob_imb_1','lob_imb_5','vwap_dev','trade_intensity']
model = lgb.train({'objective':'regression','num_leaves':31},
                  lgb.Dataset(X[features], y_future_return),
                  num_boost_round=500)

매 결정 기준

상황 Approach
Sub-µs critical FPGA + kernel bypass
Stat arb medium freq Python + kdb+
Crypto MEV Rust + Flashbots bundle
Backtest vectorbt, Nautilus Trader

기본값: C++ hot path + Python research, 매 co-location 매 essential.

🔗 Graph

🤖 LLM 활용

언제: research signal hypothesis 생성, 매 backtest code scaffolding, 매 strategy documentation. 언제 X: 매 production hot path (latency budget violated), 매 real-time risk decision.

안티패턴

  • Garbage Collection in Hot Path: 매 Java/Python GC pause → 100µs jitter. 매 C++/Rust 사용.
  • Overfit Backtest: 매 in-sample Sharpe 5 → live -2. 매 walk-forward + transaction cost.
  • No Inventory Limit: 매 market-maker blow-up (Knight Capital 2012, $440M loss in 45min).
  • Survivorship Bias: 매 delisted ticker 무시 → inflated returns.

🧪 검증 / 중복

  • Verified (Aldridge, High-Frequency Trading; Cartea et al., Algorithmic and HFT).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — full FULL spec, 7 patterns + decision matrix