Kronos:金融 K 線基礎模型
Kronos: Foundation Model for Financial Candlesticks
Kronos 是首個只以金融 K 線數據訓練的開源基礎模型,處理來自 45 個全球交易所的序列,輸出供交易智能體使用的嵌入向量或預測。模型採用遮罩預訓練及因果微調,並提供預訓練權重與微調腳本,可用於下一根 K 線預測、波動率預測和市場狀態分類。Kronos 獲 AAAI 2026 接收,GitHub 星數達 42,000。
Kronos is the first open-source foundation model trained exclusively on financial candlestick data. It ingests K-line sequences from 45 global exchanges and outputs embeddings or predictions that trading agents can consume. The project ships pre-trained weights, fine-tuning scripts, and a decoder-only architecture designed to handle high-noise financial time-series.
If you are building trading agents that need to interpret price action across multiple exchanges, Kronos gives you a shared representation layer instead of hand-rolling feature extractors for each market. The model was accepted to AAAI 2026 and has 42,000 GitHub stars, signaling early adoption in quantitative finance infrastructure.
Why Financial Candlesticks Need a Domain Model
General-purpose time-series foundation models train on weather, energy, and sensor data. Financial markets behave differently:
- High noise-to-signal ratio: Intraday price movements contain more noise than trend.
- Non-stationary distributions: Market regimes shift without warning.
- Exchange-specific quirks: Tick sizes, trading hours, and data formats vary across venues.
- Sparse events: Earnings, rate decisions, and liquidity shocks dominate returns.
Kronos addresses these by pre-training on a corpus of K-line sequences (open, high, low, close, volume) from 45 exchanges. The model learns patterns that generalize across asset classes and geographies, then fine-tunes for specific tasks like next-candle prediction or volatility forecasting.
Two-Stage Training Framework
Kronos uses a two-stage approach to handle financial noise:
Stage 1: Masked Pre-Training
The model trains on masked K-line sequences. Random candles are hidden, and the decoder predicts the missing values. This forces the model to learn:
- Intraday volatility patterns
- Volume-price relationships
- Cross-exchange correlations
The training corpus spans equities, futures, forex, and crypto. Each exchange contributes normalized sequences with standardized tick sizes and timestamps.
Stage 2: Causal Fine-Tuning
After masked pre-training, Kronos switches to causal (autoregressive) fine-tuning. The model predicts the next candle given a historical sequence. This stage adapts the model to forecasting tasks and aligns it with agent workflows that consume sequential predictions.
Fine-tuning scripts released in August 2025 let you retrain on proprietary data or adapt the output layer for custom tasks (classification, regression, or embedding extraction).
Architecture and Inference Shape
Kronos is a decoder-only transformer. The input is a sequence of K-line tuples:
# Input shape: (batch, sequence_length, 5)
# Each timestep: [open, high, low, close, volume]
import torch
from transformers import AutoModel
model = AutoModel.from_pretrained("NeoQuasar/Kronos")
input_seq = torch.randn(1, 128, 5) # 128 candles, 5 features
# Forward pass returns embeddings or next-candle logits
output = model(input_seq)
# output.shape: (1, 128, hidden_dim) or (1, 5) depending on task
The model outputs:
- Embeddings: Dense vectors for retrieval or clustering.
- Next-candle predictions: Continuous values for open, high, low, close, volume.
- Logits: Classification scores if fine-tuned for regime detection.
For agent tool boundaries, you have two options:
- Local inference: Load the model in your trading agent and call it directly.
- API wrapper: Deploy Kronos behind a REST or gRPC endpoint and expose prediction or embedding endpoints.
The decoder-only design means the model cannot handle bidirectional context. If your agent needs to analyze a sequence in both directions, you must run two forward passes or use a separate encoder.
Data Normalization Across 45 Exchanges
Kronos trains on data from equity markets (NYSE, NASDAQ, LSE), futures (CME, ICE), forex (OANDA, FXCM), and crypto (Binance, Coinbase, Kraken). Each exchange has different:
- Tick sizes: US equities trade in $0.01 increments, crypto in fractional cents.
- Trading hours: Equities close at 4 PM ET, crypto runs 24/7.
- Volume units: Shares vs. contracts vs. base currency.
The training pipeline normalizes sequences by:
- Z-score scaling: Each feature (open, high, low, close, volume) is standardized per asset.
- Resampling: All sequences are resampled to a common timeframe (1-minute, 5-minute, or hourly).
- Missing data handling: Gaps in trading hours are forward-filled or masked.
This normalization layer is critical. Without it, the model would overfit to exchange-specific artifacts (like Binance's high-frequency noise) and fail to generalize.
Fine-Tuning for Custom Tasks
The August 2025 release includes fine-tuning scripts for three tasks:
- Next-candle prediction: Forecast the next open, high, low, close, volume.
- Volatility forecasting: Predict realized volatility over the next N candles.
- Regime classification: Classify market state (trending, ranging, volatile).
Fine-tuning requires:
- A labeled dataset of K-line sequences and target values.
- A task-specific output layer (regression head, classification head, or embedding projector).
- Hyperparameter tuning for learning rate, batch size, and sequence length.
You can fine-tune on proprietary data (your own exchange feeds, private alpha signals) or public datasets (Yahoo Finance, Polygon.io). The model supports transfer learning, so you can start with Kronos weights and adapt to a narrow domain (e.g., only crypto, only intraday equities).
Agent Integration Patterns
Kronos fits into trading agent workflows in three ways:
1. Embedding Retrieval
Store Kronos embeddings in a vector database (Pinecone, Weaviate, Qdrant). When an agent observes a new K-line sequence, it queries the database for similar historical patterns and retrieves associated outcomes (next-day return, drawdown, volatility spike).
2. Forecasting API
Wrap Kronos in a FastAPI service that accepts K-line sequences and returns next-candle predictions. The agent calls this endpoint before placing trades.
# Agent tool definition
def get_price_forecast(symbol: str, lookback: int) -> dict:
"""Fetch next-candle forecast from Kronos API."""
response = requests.post(
"https://kronos-api.example.com/forecast",
json={"symbol": symbol, "lookback": lookback}
)
return response.json() # {open, high, low, close, volume}
3. Multi-Exchange Normalization
If your agent trades across multiple exchanges, Kronos provides a shared representation. Instead of maintaining separate feature extractors for each venue, you pass all K-line sequences through Kronos and operate on the embeddings.
Trade-Offs and Risks
| Dimension | Kronos | Hand-Rolled Features | Generic TSFMs |
|---|---|---|---|
| Domain fit | High (financial-specific) | High (custom logic) | Low (weather, energy) |
| Generalization | Cross-exchange, cross-asset | Single exchange | Cross-domain |
| Training cost | Pre-trained (free) | Zero (no training) | High (retrain) |
| Customization | Fine-tuning required | Full control | Limited |
| Noise handling | Two-stage training | Manual filtering | Weak |
| Inference latency | 10-50ms (GPU) | <1ms (rules) | 10-50ms (GPU) |
Risks:
- Overfitting to training period: If Kronos trained on 2015-2023 data, it may underperform in new market regimes (2024 rate hikes, 2025 crypto winter).
- Black-box predictions: The model does not explain why it predicts a certain next candle. You cannot audit the logic.
- Deployment complexity: Running a transformer in production requires GPU infrastructure, model versioning, and monitoring.
Observability and Failure Modes
Monitor these metrics when running Kronos in production:
- Prediction error: Track mean absolute error (MAE) or root mean squared error (RMSE) for next-candle predictions.
- Embedding drift: Measure cosine similarity between current embeddings and historical embeddings. Sudden drops indicate distribution shift.
- Inference latency: Log p50, p95, and p99 latency for model calls. Spikes indicate GPU contention or batch size issues.
Failure modes:
- Stale data: If the agent feeds Kronos outdated K-line sequences, predictions will lag reality.
- Exchange downtime: If one exchange in your multi-venue setup goes offline, the model may produce anomalous embeddings.
- Fine-tuning collapse: Aggressive fine-tuning on a small dataset can destroy pre-trained weights and degrade performance.
Technical Verdict
Use Kronos when:
- You are building a trading agent that operates across multiple exchanges or asset classes.
- You need a shared representation layer for price action without hand-rolling features.
- You have GPU infrastructure and can tolerate 10-50ms inference latency.
- You plan to fine-tune on proprietary data or custom forecasting tasks.
Avoid Kronos when:
- You trade a single exchange with hand-tuned alpha signals that already work.
- You need sub-millisecond latency for high-frequency strategies.
- You require explainable predictions for regulatory or risk management purposes.
- Your infrastructure cannot support transformer inference (CPU-only, edge devices).
Kronos is plumbing for agents that need to interpret financial time-series at scale. It does not replace domain expertise or alpha generation, but it reduces the engineering cost of normalizing and featurizing K-line data across venues.
Source Links
來源:DEV Community · dev.to