# Kronos

> Open-source family of decoder-only foundation models pre-trained on financial candlestick (K-line) sequences for market forecasting.

Kronos is an open-source foundation model family for financial candlestick (K-line) data, published in the shiyu-coder GitHub repository. It tokenizes OHLCV sequences and uses an autoregressive Transformer to forecast future market data. Pre-trained models are distributed through the Hugging Face Hub, and the repository includes forecasting examples and a fine-tuning pipeline.

## What It Is

Kronos is a set of decoder-only models pre-trained on the "language" of financial markets. The README states it is the first open-source foundation model for K-lines, trained on data from over 45 global exchanges. Unlike general-purpose time-series foundation models, it is designed for the high-noise characteristics of financial data.

It uses a two-stage framework: a specialized tokenizer quantizes continuous multi-dimensional OHLCV data into hierarchical discrete tokens, and a large autoregressive Transformer is pre-trained on those tokens to serve as a unified model for quantitative tasks.

## Forecasting Workflow

Users load a tokenizer and a model from Hugging Face, then wrap them in the `KronosPredictor` class, which handles preprocessing, normalization, prediction, and inverse normalization. Input is a pandas DataFrame with open, high, low and close columns (volume and amount are optional), plus historical and future timestamps. Sampling parameters such as temperature, top-p, and sample count control probabilistic forecasts. The output is a DataFrame of forecasted open, high, low, close, volume, and amount values. A `predict_batch` method forecasts multiple series in parallel, provided they share the same lookback and prediction length. Example scripts produce plots comparing forecasts with ground truth.

## Model Zoo

The released models are Kronos-mini (4.1M parameters, 2048 context), Kronos-small (24.7M, 512), and Kronos-base (102.3M, 512), all open on Hugging Face. Kronos-large (499.2M) is listed as not open-source. A live demo shows a 24-hour BTC/USDT forecast.

## Fine-tuning and Backtesting

The repository provides a pipeline that uses Qlib to prepare Chinese A-share data, fine-tunes the tokenizer and then the predictor with multi-GPU torchrun, and runs a simple top-K strategy backtest. The README describes it as a demonstration, not a production-ready trading system. Kronos has been accepted by AAAI 2026, and a paper is available on arXiv. The project is released under the MIT License.

## Features
- Decoder-only foundation models for financial K-line sequences
- Hierarchical discrete tokenizer for OHLCV data
- KronosPredictor class handling normalization and inverse normalization
- Probabilistic forecasting with temperature, top-p and sample count controls
- Batch prediction across multiple series
- Pre-trained models on Hugging Face Hub
- Fine-tuning pipeline for tokenizer and predictor with Qlib data
- Simple top-K backtesting script
- Live BTC/USDT forecast demo

## Integrations
Hugging Face Hub, Qlib, PyTorch, pandas, Comet.ml

## Platforms
LINUX, API, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Links
- Website: https://github.com/shiyu-coder/Kronos
- Repository: https://github.com/shiyu-coder/Kronos
- EveryDev.ai: https://www.everydev.ai/tools/kronos
