Kronos is a decoder-only foundation model built specifically for K-line (OHLCV candlestick) sequences rather than general time series. It's aimed at quant researchers, traders, and ML engineers who want to forecast price and volume behavior using a pre-trained model instead of building a forecasting pipeline from scratch. The model was pre-trained on data from over 45 global exchanges and is distributed as a family of checkpoints on Hugging Face, with code to run inference and finetune on your own data.
The core design uses a two-stage approach: a specialized tokenizer quantizes continuous, multi-dimensional OHLCV data into hierarchical discrete tokens, and an autoregressive Transformer is pre-trained on those tokens. This lets the same architecture serve as a general model for various quantitative finance tasks, rather than a narrow single-purpose predictor.
predict method supports temperature (T), nucleus sampling (top_p), and multi-sample averaging (sample_count) for generating forecast distributions, not just point estimates.predict_batch runs forecasts for multiple series in parallel on GPU, useful when scoring many assets at once.Kronos fits research and prototyping around price/volume forecasting: generating forecast signals for backtesting, exploring foundation-model approaches to K-line data, or finetuning on a specific market (equities, crypto, futures) using your own historical data. It's a reasonable starting point if you want a pre-trained baseline instead of training a time-series model from zero.
It is not a production trading system. The README explicitly flags the included finetuning/backtest pipeline as a simplified demonstration, not a robust quant strategy: it lacks portfolio optimization, risk-factor neutralization, transaction cost modeling, and slippage handling. If you need a deployable trading strategy, treat Kronos's output as a raw signal that still requires a proper strategy and risk layer on top. It's also not designed for general (non-financial) time-series forecasting, since the tokenizer and pre-training are specific to candlestick data.
Kronos requires Python 3.10+ and standard pip-based setup.
pip install -r requirements.txt
Load a pre-trained model and tokenizer directly from Hugging Face Hub:
from model import Kronos, KronosTokenizer, KronosPredictor
tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
model = Kronos.from_pretrained("NeoQuasar/Kronos-small")
predictor = KronosPredictor(model, tokenizer, max_context=512)
Prepare a pandas DataFrame with open, high, low, close columns (volume and amount are optional), plus timestamp series for the historical window and the future periods to predict, then call predictor.predict(...). A full runnable example, including plotting, is in examples/prediction_example.py.
For finetuning on your own data, install pyqlib, set up your Qlib data directory, edit paths and hyperparameters in finetune/config.py, then run the pipeline in order:
pip install pyqlib
python finetune/qlib_data_preprocess.py
torchrun --standalone --nproc_per_node=NUM_GPUS finetune/train_tokenizer.py
torchrun --standalone --nproc_per_node=NUM_GPUS finetune/train_predictor.py
python finetune/qlib_test.py --device cuda:0
This produces a finetuned tokenizer, a finetuned predictor, and a backtest report comparing a simple top-K strategy against a benchmark.