Kronos: The First Open-Source Foundation Model for Financial Markets — 33,283 GitHub Stars and Counting
Discover Kronos, the groundbreaking open-source AI foundation model that speaks the language of financial markets. Learn how to use it for stock prediction, backtesting, and building your own quantitative strategies with Python.
What if an AI model could read financial charts the way GPT reads text? That's exactly what Kronos does — and it's just been accepted at AAAI 2026, one of the most prestigious AI conferences in the world.
Kronos is an open-source family of decoder-only foundation models pre-trained on financial candlestick data from over 45 global exchanges. With 33,283 GitHub stars and 5,662 forks, it has rapidly become the go-to tool for developers and researchers working at the intersection of AI and finance.
Unlike general-purpose time-series models, Kronos was built from scratch to handle the unique challenges of financial data: high noise, non-stationarity, and complex multi-dimensional signals. Whether you're building a trading bot, doing academic research, or just exploring what foundation models can do beyond text — Kronos is worth a serious look.
What Makes Kronos Different from Other AI Models?
Most foundation models focus on text, images, or code. Kronos tackles something entirely different: the language of financial markets. Here's what sets it apart:
1. A Novel Two-Stage Architecture
Kronos uses a two-stage framework that mirrors how large language models work — but adapted for financial data:
- Stage 1 — Specialized Tokenizer: Converts continuous, multi-dimensional K-line data (Open, High, Low, Close, Volume, Amount) into hierarchical discrete tokens. Think of it as translating market movements into a "financial vocabulary" the model can understand.
- Stage 2 — Autoregressive Transformer: A large Transformer model is pre-trained on these tokens, learning patterns across 45+ exchanges. This enables unified forecasting, prediction, and analysis.
2. Built for High-Noise Financial Data
Financial time series are notoriously noisy. Kronos handles this through:
- Quantization-based tokenization that captures essential market patterns while filtering noise
- Multi-scale context windows (up to 2048 tokens for the mini model) for capturing both short-term and long-term patterns
- Probabilistic forecasting via temperature-controlled sampling and nucleus (top-p) sampling
3. A Family of Models for Every Need
Kronos offers three model sizes, each targeting different computational budgets:
| Model | Tokenizer | Context Length | Parameters | Best For |
|---|---|---|---|---|
| Kronos-mini | Kronos-Tokenizer-2k | 2048 | 4.1M | Edge devices, quick experiments |
| Kronos-small | Kronos-Tokenizer-base | 512 | 24.7M | Research, prototyping |
| Kronos-base | Kronos-Tokenizer-base | 512 | 102.3M | Production, high-accuracy forecasting |
All models are freely available on the Hugging Face Hub under the MIT license.
How to Use Kronos: A Step-by-Step Guide
Getting started with Kronos is remarkably straightforward. Here's a complete walkthrough from installation to your first prediction.
Step 1: Installation
# Clone the repository
git clone https://github.com/shiyu-coder/Kronos.git
cd Kronos
# Install dependencies (requires Python 3.10+)
pip install -r requirements.txt
Step 2: Load the Model and Tokenizer
from model import Kronos, KronosTokenizer, KronosPredictor
# Load from Hugging Face Hub
tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
model = Kronos.from_pretrained("NeoQuasar/Kronos-small")
# Initialize the predictor with max context length
predictor = KronosPredictor(model, tokenizer, max_context=512)
Step 3: Prepare Your Data and Predict
import pandas as pd
# Load your K-line data (CSV with OHLCV columns)
df = pd.read_csv("./data/XSHG_5min_600977.csv")
df['timestamps'] = pd.to_datetime(df['timestamps'])
# Define your context window and prediction horizon
lookback = 400 # How much history to feed the model
pred_len = 120 # How many future candles to predict
# Prepare inputs
x_df = df.loc[:lookback-1, ['open', 'high', 'low', 'close', 'volume', 'amount']]
x_timestamp = df.loc[:lookback-1, 'timestamps']
y_timestamp = df.loc[lookback:lookback+pred_len-1, 'timestamps']
# Generate predictions with probabilistic sampling
pred_df = predictor.predict(
df=x_df,
x_timestamp=x_timestamp,
y_timestamp=y_timestamp,
pred_len=pred_len,
T=1.0, # Temperature for sampling
top_p=0.9, # Nucleus sampling probability
sample_count=1 # Number of forecast paths
)
print("Forecasted OHLCV Data:")
print(pred_df.head())
Step 4: Batch Prediction for Multiple Assets
Need to forecast multiple assets at once? Kronos supports efficient batch prediction with GPU parallelism:
# Prepare multiple datasets
df_list = [btc_df, eth_df, sol_df]
x_timestamp_list = [btc_ts, eth_ts, sol_ts]
y_timestamp_list = [btc_yts, eth_yts, sol_yts]
# Batch predict all at once
pred_df_list = predictor.predict_batch(
df_list=df_list,
x_timestamp_list=x_timestamp_list,
y_timestamp_list=y_timestamp_list,
pred_len=120,
T=1.0,
top_p=0.9,
sample_count=1,
verbose=True
)
for name, pred_df in zip(['BTC', 'ETH', 'SOL'], pred_df_list):
print(f"\n{name} Forecast:")
print(pred_df.head())
Fine-Tuning Kronos for Your Own Market
One of Kronos's most powerful features is the complete fine-tuning pipeline. You can adapt the pre-trained model to your specific market, asset class, or trading strategy using Microsoft's Qlib framework.
The Four-Step Fine-Tuning Process
- Configuration: Set up paths, hyperparameters, and training ranges in
finetune/config.py - Data Preparation: Process and split your market data using Qlib
- Model Fine-Tuning: Fine-tune both the tokenizer and the predictor using
torchrunfor multi-GPU training - Backtesting: Evaluate performance with a built-in top-K strategy backtest
# Step 1: Preprocess your data
python finetune/qlib_data_preprocess.py
# Step 2: Fine-tune the tokenizer (multi-GPU)
torchrun --standalone --nproc_per_node=2 finetune/train_tokenizer.py
# Step 3: Fine-tune the predictor (multi-GPU)
torchrun --standalone --nproc_per_node=2 finetune/train_predictor.py
# Step 4: Backtest your fine-tuned model
python finetune/qlib_test.py --device cuda:0
The backtesting script generates a comprehensive performance analysis including cumulative return curves comparing your strategy against market benchmarks.
Real-World Example: Building a Crypto Forecasting Dashboard
Let's build a practical example: a BTC/USDT 24-hour forecasting pipeline that you could integrate into a trading dashboard.
import pandas as pd
import numpy as np
from model import Kronos, KronosTokenizer, KronosPredictor
# Load the model
tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
model = Kronos.from_pretrained("NeoQuasar/Kronos-base")
predictor = KronosPredictor(model, tokenizer, max_context=512)
# Fetch BTC/USDT hourly data (from your preferred data source)
# For this example, assume we have a CSV with 500 hourly candles
btc_data = pd.read_csv("btc_usdt_1h.csv")
btc_data['timestamps'] = pd.to_datetime(btc_data['timestamps'])
# Use last 400 candles as context, predict next 24 (hours)
lookback = 400
pred_len = 24
x_df = btc_data.loc[:lookback-1, ['open', 'high', 'low', 'close', 'volume', 'amount']]
x_ts = btc_data.loc[:lookback-1, 'timestamps']
y_ts = btc_data.loc[lookback:lookback+pred_len-1, 'timestamps']
# Run multiple samples for confidence intervals
predictions = []
for i in range(10):
pred = predictor.predict(
df=x_df, x_timestamp=x_ts, y_timestamp=y_ts,
pred_len=pred_len, T=0.8, top_p=0.9, sample_count=1
)
predictions.append(pred)
# Average predictions and compute confidence intervals
avg_prediction = pd.concat(predictions).groupby(level=0).mean()
std_prediction = pd.concat(predictions).groupby(level=0).std()
print("BTC/USDT 24h Forecast:")
print(avg_prediction[['open', 'high', 'low', 'close']].to_string())
Kronos also provides a live demo showcasing BTC/USDT 24-hour forecasts so you can see the model in action before writing a single line of code.
Key Benefits of Using Kronos
- 🆓 Fully Open Source: MIT licensed — use it commercially, modify it, build on top of it
- 🧠 AAAI 2026 Accepted: Peer-reviewed research backing the architecture
- 📊 45+ Exchange Training Data: Trained on diverse global market data for robust generalization
- ⚡ Multiple Model Sizes: From 4.1M to 102.3M parameters — pick what fits your compute budget
- 🔧 Built-in Fine-Tuning: Complete pipeline with Qlib integration for custom market adaptation
- 🚀 Batch Prediction: GPU-parallelized multi-asset forecasting
- 📈 Backtesting Included: Evaluate strategies with built-in performance analysis
- 🎯 Probabilistic Forecasts: Temperature and top-p sampling for uncertainty quantification
Who Should Use Kronos?
- Quantitative Developers: Build AI-powered trading signals and strategies
- Financial Data Scientists: Explore new approaches to market prediction and analysis
- AI Researchers: Study how foundation model architectures transfer to financial domains
- Students & Educators: Learn about both AI and quantitative finance through hands-on code
- Startup Founders: Prototype AI-driven fintech products with a battle-tested foundation model
FAQ
What is Kronos and how does it work?
Kronos is an open-source foundation model for financial candlestick data. It works by first converting OHLCV (Open, High, Low, Close, Volume) market data into discrete tokens using a specialized tokenizer, then using an autoregressive Transformer to learn patterns and generate forecasts — similar to how GPT generates text, but for financial charts.
Is Kronos free to use?
Yes! Kronos is released under the MIT license, which means you can use it freely for personal, academic, and commercial purposes. The models are hosted on Hugging Face and can be downloaded without any cost.
Can Kronos predict stock prices accurately?
Kronos provides probabilistic forecasts of future candlestick patterns, not guaranteed price predictions. It's designed as a research tool and signal generator for quantitative strategies. Real trading systems require additional components like portfolio optimization, risk management, and transaction cost modeling. The authors explicitly note that the fine-tuning pipeline is a demonstration, not a production-ready trading system.
What programming language does Kronos use?
Kronos is built with Python (3.10+) and uses PyTorch for model training and inference. The fine-tuning pipeline also integrates with Microsoft's Qlib framework for data preparation and backtesting.
How much GPU memory do I need to run Kronos?
It depends on the model size. Kronos-mini (4.1M parameters) can run on a standard GPU with 4-6GB VRAM. Kronos-small (24.7M params) needs around 6-8GB. Kronos-base (102.3M params) typically requires 12-16GB VRAM for inference, and more for fine-tuning with multi-GPU support via torchrun.
What markets and assets does Kronos support?
Kronos was pre-trained on data from 45+ global exchanges, covering stocks, cryptocurrencies, forex, and commodities. The fine-tuning pipeline allows you to adapt it to any market with OHLCV candlestick data, including custom or proprietary datasets.
How does Kronos compare to traditional technical analysis?
Traditional technical analysis relies on hand-crafted indicators (RSI, MACD, Bollinger Bands) and pattern recognition rules. Kronos takes a fundamentally different approach — it learns patterns directly from raw market data through self-supervised pre-training. Instead of predefined rules, the model discovers its own representations of market dynamics, potentially capturing patterns that traditional methods miss.
🚀 Want to build AI-powered apps like this?
Master Python, machine learning, and AI development with CoddyKit's interactive courses.
From beginner to advanced — learn by doing, not just watching. Explore courses →