NeoQuasar commited on
Commit
c28ba6e
·
verified ·
1 Parent(s): cc014e9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -31
README.md CHANGED
@@ -5,51 +5,67 @@ tags:
5
  - Finance
6
  - Candlestick
7
  - K-line
8
- library_name: Kronos
9
  ---
10
 
11
  # Kronos: A Foundation Model for the Language of Financial Markets
12
 
13
- Kronos is the **first open-source foundation model** for financial candlesticks (K-lines), trained on data from over **45 global exchanges**. It was presented in the paper [Kronos: A Foundation Model for the Language of Financial Markets](https://huggingface.co/papers/2508.02739).
 
 
14
 
15
- For full details, including the complete codebase and additional examples, please visit our [GitHub page](https://github.com/shiyu-coder/Kronos).
 
 
 
 
 
 
16
 
17
- Try out our live demo showcasing Kronos's forecasting results for the BTC/USDT trading pair: [Access the Live Demo Here](https://shiyu-coder.github.io/Kronos-demo/)
 
 
18
 
19
  <p align="center">
20
- <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/overview.png" alt="Kronos Overview" width="700px" />
21
  </p>
22
 
23
- ## Abstract
24
- The success of large-scale pre-training paradigm, exemplified by Large Language Models (LLMs), has inspired the development of Time Series Foundation Models (TSFMs). However, their application to financial candlestick (K-line) data remains limited, often underperforming non-pre-trained architectures. Moreover, existing TSFMs often overlook crucial downstream tasks such as volatility prediction and synthetic data generation. To address these limitations, we propose Kronos, a unified, scalable pre-training framework tailored to financial K-line modeling. Kronos introduces a specialized tokenizer that discretizes continuous market information into token sequences, preserving both price dynamics and trade activity patterns. We pre-train Kronos using an autoregressive objective on a massive, multi-market corpus of over 12 billion K-line records from 45 global exchanges, enabling it to learn nuanced temporal and cross-asset representations. Kronos excels in a zero-shot setting across a diverse set of financial tasks. On benchmark datasets, Kronos boosts price series forecasting RankIC by 93% over the leading TSFM and 87% over the best non-pre-trained baseline. It also achieves a 9% lower MAE in volatility forecasting and a 22% improvement in generative fidelity for synthetic K-line sequences. These results establish Kronos as a robust, versatile foundation model for end-to-end financial time series analysis. Our pre-trained model is publicly available at this https URL.
 
 
 
 
 
25
 
26
  ## Model Zoo
 
27
  We release a family of pre-trained models with varying capacities to suit different computational and application needs. All models are readily accessible from the Hugging Face Hub.
28
 
29
- | Model | Tokenizer | Context length | Param | Open-source |
30
- |--------------|---------------------------------------------------------------------------------| -------------- | ------ |---------------------------------------------------------------------------|
31
  | Kronos-mini | [Kronos-Tokenizer-2k](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-2k) | 2048 | 4.1M | ✅ [NeoQuasar/Kronos-mini](https://huggingface.co/NeoQuasar/Kronos-mini) |
32
  | Kronos-small | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 24.7M | ✅ [NeoQuasar/Kronos-small](https://huggingface.co/NeoQuasar/Kronos-small) |
33
  | Kronos-base | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 102.3M | ✅ [NeoQuasar/Kronos-base](https://huggingface.co/NeoQuasar/Kronos-base) |
34
- | Kronos-large | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 499.2M | ❌ |
35
-
36
- ## Getting Started
37
-
38
- ### Installation
39
- 1. Install Python 3.10+, and then install the dependencies:
40
 
41
- ```shell
42
- pip install -r requirements.txt
43
- ```
44
 
45
- ### Making Forecasts
46
  Forecasting with Kronos is straightforward using the `KronosPredictor` class. It handles data preprocessing, normalization, prediction, and inverse normalization, allowing you to get from raw data to forecasts in just a few lines of code.
47
 
48
  **Important Note**: The `max_context` for `Kronos-small` and `Kronos-base` is **512**. This is the maximum sequence length the model can process. For optimal performance, it is recommended that your input data length (i.e., `lookback`) does not exceed this limit. The `KronosPredictor` will automatically handle truncation for longer contexts.
49
 
50
  Here is a step-by-step guide to making your first forecast.
51
 
52
- #### 1. Load the Tokenizer and Model
 
 
 
 
 
 
 
 
 
53
  First, load a pre-trained Kronos model and its corresponding tokenizer from the Hugging Face Hub.
54
 
55
  ```python
@@ -60,7 +76,8 @@ tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
60
  model = Kronos.from_pretrained("NeoQuasar/Kronos-small")
61
  ```
62
 
63
- #### 2. Instantiate the Predictor
 
64
  Create an instance of `KronosPredictor`, passing the model, tokenizer, and desired device.
65
 
66
  ```python
@@ -68,7 +85,8 @@ Create an instance of `KronosPredictor`, passing the model, tokenizer, and desir
68
  predictor = KronosPredictor(model, tokenizer, device="cuda:0", max_context=512)
69
  ```
70
 
71
- #### 3. Prepare Input Data
 
72
  The `predict` method requires three main inputs:
73
  - `df`: A pandas DataFrame containing the historical K-line data. It must include columns `['open', 'high', 'low', 'close']`. `volume` and `amount` are optional.
74
  - `x_timestamp`: A pandas Series of timestamps corresponding to the historical data in `df`.
@@ -77,7 +95,7 @@ The `predict` method requires three main inputs:
77
  ```python
78
  import pandas as pd
79
 
80
- # Load your data
81
  df = pd.read_csv("./data/XSHG_5min_600977.csv")
82
  df['timestamps'] = pd.to_datetime(df['timestamps'])
83
 
@@ -91,7 +109,8 @@ x_timestamp = df.loc[:lookback-1, 'timestamps']
91
  y_timestamp = df.loc[lookback:lookback+pred_len-1, 'timestamps']
92
  ```
93
 
94
- #### 4. Generate Forecasts
 
95
  Call the `predict` method to generate forecasts. You can control the sampling process with parameters like `T`, `top_p`, and `sample_count` for probabilistic forecasting.
96
 
97
  ```python
@@ -112,28 +131,34 @@ print(pred_df.head())
112
 
113
  The `predict` method returns a pandas DataFrame containing the forecasted values for `open`, `high`, `low`, `close`, `volume`, and `amount`, indexed by the `y_timestamp` you provided.
114
 
115
- #### 5. Example and Visualization
116
- For a complete, runnable script that includes data loading, prediction, and plotting, please see [`examples/prediction_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_example.py).
 
117
 
118
  Running this script will generate a plot comparing the ground truth data against the model's forecast, similar to the one shown below:
119
 
120
  <p align="center">
121
- <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/prediction_example.png" alt="Forecast Example" width="600px" />
122
  </p>
123
 
124
- Additionally, we also provide a script that makes predictions without Volume and Amount data, which can be found in [`examples/prediction_wo_vol_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_wo_vol_example.py).
125
 
126
  ## Citation
 
127
  If you use Kronos in your research, we would appreciate a citation to our [paper](https://huggingface.co/papers/2508.02739):
128
 
129
  ```bibtex
130
  @misc{shi2025kronos,
131
- title={Kronos: A Foundation Model for the Language of Financial Markets},
132
  author={Yu Shi and Zongliang Fu and Shuo Chen and Bohan Zhao and Wei Xu and Changshui Zhang and Jian Li},
133
  year={2025},
134
  eprint={2508.02739},
135
  archivePrefix={arXiv},
136
  primaryClass={q-fin.ST},
137
- url={https://arxiv.org/abs/2508.02739},
138
  }
139
- ```
 
 
 
 
 
5
  - Finance
6
  - Candlestick
7
  - K-line
 
8
  ---
9
 
10
  # Kronos: A Foundation Model for the Language of Financial Markets
11
 
12
+ [![Paper](https://img.shields.io/badge/Paper-2508.02739-b31b1b.svg)](https://arxiv.org/abs/2508.02739)
13
+ [![Live Demo](https://img.shields.io/badge/%F0%9F%9A%80-Live_Demo-brightgreen)](https://shiyu-coder.github.io/Kronos-demo/)
14
+ [![GitHub](https://img.shields.io/badge/%F0%9F%92%BB-GitHub-blue?logo=github)](https://github.com/shiyu-coder/Kronos)
15
 
16
+ <p align="center">
17
+ <img src="https://github.com/shiyu-coder/Kronos/blob/master/figures/logo.jpeg?raw=true" alt="Kronos Logo" width="100">
18
+ </p>
19
+
20
+ **Kronos** is the **first open-source foundation model** for financial candlesticks (K-lines), trained on data from over **45 global exchanges**. It is designed to handle the unique, high-noise characteristics of financial data.
21
+
22
+ ## Introduction
23
 
24
+ Kronos is a family of decoder-only foundation models, pre-trained specifically for the "language" of financial markets—K-line sequences. It leverages a novel two-stage framework:
25
+ 1. A specialized tokenizer first quantizes continuous, multi-dimensional K-line data (OHLCV) into **hierarchical discrete tokens**.
26
+ 2. A large, autoregressive Transformer is then pre-trained on these tokens, enabling it to serve as a unified model for diverse quantitative tasks.
27
 
28
  <p align="center">
29
+ <img src="https://github.com/shiyu-coder/Kronos/blob/master/figures/overview.png?raw=true" alt="Kronos Overview" align="center" width="700px" />
30
  </p>
31
 
32
+ The success of large-scale pre-training paradigm, exemplified by Large Language Models (LLMs), has inspired the development of Time Series Foundation Models (TSFMs). Kronos addresses existing limitations by introducing a specialized tokenizer that discretizes continuous market information into token sequences, preserving both price dynamics and trade activity patterns. We pre-train Kronos using an autoregressive objective on a massive, multi-market corpus of over 12 billion K-line records from 45 global exchanges, enabling it to learn nuanced temporal and cross-asset representations. Kronos excels in a zero-shot setting across a diverse set of financial tasks, including price series forecasting, volatility forecasting, and synthetic data generation.
33
+
34
+ ## Live Demo
35
+
36
+ We have set up a live demo to visualize Kronos's forecasting results. The webpage showcases a forecast for the **BTC/USDT** trading pair over the next 24 hours.
37
+
38
+ 👉 [Access the Live Demo Here](https://shiyu-coder.github.io/Kronos-demo/)
39
 
40
  ## Model Zoo
41
+
42
  We release a family of pre-trained models with varying capacities to suit different computational and application needs. All models are readily accessible from the Hugging Face Hub.
43
 
44
+ | Model | Tokenizer | Context length | Param | Hugging Face Model Card |
45
+ |--------------|---------------------------------------------------------------------------------| -------------- | ------ |--------------------------------------------------------------------------|
46
  | Kronos-mini | [Kronos-Tokenizer-2k](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-2k) | 2048 | 4.1M | ✅ [NeoQuasar/Kronos-mini](https://huggingface.co/NeoQuasar/Kronos-mini) |
47
  | Kronos-small | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 24.7M | ✅ [NeoQuasar/Kronos-small](https://huggingface.co/NeoQuasar/Kronos-small) |
48
  | Kronos-base | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 102.3M | ✅ [NeoQuasar/Kronos-base](https://huggingface.co/NeoQuasar/Kronos-base) |
49
+ | Kronos-large | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 499.2M | ❌ Not yet publicly available |
 
 
 
 
 
50
 
51
+ ## Getting Started: Making Forecasts
 
 
52
 
 
53
  Forecasting with Kronos is straightforward using the `KronosPredictor` class. It handles data preprocessing, normalization, prediction, and inverse normalization, allowing you to get from raw data to forecasts in just a few lines of code.
54
 
55
  **Important Note**: The `max_context` for `Kronos-small` and `Kronos-base` is **512**. This is the maximum sequence length the model can process. For optimal performance, it is recommended that your input data length (i.e., `lookback`) does not exceed this limit. The `KronosPredictor` will automatically handle truncation for longer contexts.
56
 
57
  Here is a step-by-step guide to making your first forecast.
58
 
59
+ ### Installation
60
+
61
+ 1. Install Python 3.10+, and then install the dependencies from the [GitHub repository's `requirements.txt`](https://github.com/shiyu-coder/Kronos/blob/main/requirements.txt):
62
+
63
+ ```shell
64
+ pip install -r requirements.txt
65
+ ```
66
+
67
+ ### 1. Load the Tokenizer and Model
68
+
69
  First, load a pre-trained Kronos model and its corresponding tokenizer from the Hugging Face Hub.
70
 
71
  ```python
 
76
  model = Kronos.from_pretrained("NeoQuasar/Kronos-small")
77
  ```
78
 
79
+ ### 2. Instantiate the Predictor
80
+
81
  Create an instance of `KronosPredictor`, passing the model, tokenizer, and desired device.
82
 
83
  ```python
 
85
  predictor = KronosPredictor(model, tokenizer, device="cuda:0", max_context=512)
86
  ```
87
 
88
+ ### 3. Prepare Input Data
89
+
90
  The `predict` method requires three main inputs:
91
  - `df`: A pandas DataFrame containing the historical K-line data. It must include columns `['open', 'high', 'low', 'close']`. `volume` and `amount` are optional.
92
  - `x_timestamp`: A pandas Series of timestamps corresponding to the historical data in `df`.
 
95
  ```python
96
  import pandas as pd
97
 
98
+ # Load your data (example data can be found in the GitHub repo)
99
  df = pd.read_csv("./data/XSHG_5min_600977.csv")
100
  df['timestamps'] = pd.to_datetime(df['timestamps'])
101
 
 
109
  y_timestamp = df.loc[lookback:lookback+pred_len-1, 'timestamps']
110
  ```
111
 
112
+ ### 4. Generate Forecasts
113
+
114
  Call the `predict` method to generate forecasts. You can control the sampling process with parameters like `T`, `top_p`, and `sample_count` for probabilistic forecasting.
115
 
116
  ```python
 
131
 
132
  The `predict` method returns a pandas DataFrame containing the forecasted values for `open`, `high`, `low`, `close`, `volume`, and `amount`, indexed by the `y_timestamp` you provided.
133
 
134
+ ### 5. Example and Visualization
135
+
136
+ For a complete, runnable script that includes data loading, prediction, and plotting, please see [`examples/prediction_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_example.py) in the GitHub repository.
137
 
138
  Running this script will generate a plot comparing the ground truth data against the model's forecast, similar to the one shown below:
139
 
140
  <p align="center">
141
+ <img src="https://github.com/shiyu-coder/Kronos/blob/master/figures/prediction_example.png?raw=true" alt="Forecast Example" align="center" width="600px" />
142
  </p>
143
 
144
+ Additionally, a script that makes predictions without Volume and Amount data can be found in [`examples/prediction_wo_vol_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_wo_vol_example.py).
145
 
146
  ## Citation
147
+
148
  If you use Kronos in your research, we would appreciate a citation to our [paper](https://huggingface.co/papers/2508.02739):
149
 
150
  ```bibtex
151
  @misc{shi2025kronos,
152
+ title={Kronos: A Foundation Model for the Language of Financial Markets},
153
  author={Yu Shi and Zongliang Fu and Shuo Chen and Bohan Zhao and Wei Xu and Changshui Zhang and Jian Li},
154
  year={2025},
155
  eprint={2508.02739},
156
  archivePrefix={arXiv},
157
  primaryClass={q-fin.ST},
158
+ url={https://arxiv.org/abs/2508.02739},
159
  }
160
+ ```
161
+
162
+ ## License
163
+
164
+ This project is licensed under the [MIT License](https://github.com/shiyu-coder/Kronos/blob/main/LICENSE).