kronos-finance 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. kronos_finance-0.1.0/CHANGELOG.md +48 -0
  2. kronos_finance-0.1.0/LICENSE +21 -0
  3. kronos_finance-0.1.0/MANIFEST.in +4 -0
  4. kronos_finance-0.1.0/PKG-INFO +363 -0
  5. kronos_finance-0.1.0/README.md +283 -0
  6. kronos_finance-0.1.0/docs/API.md +201 -0
  7. kronos_finance-0.1.0/docs/CLI.md +194 -0
  8. kronos_finance-0.1.0/docs/CONTRIBUTING.md +141 -0
  9. kronos_finance-0.1.0/docs/DASHBOARD.md +125 -0
  10. kronos_finance-0.1.0/docs/DATA_SOURCES.md +118 -0
  11. kronos_finance-0.1.0/docs/DEPLOY.md +157 -0
  12. kronos_finance-0.1.0/docs/INSTALL.md +147 -0
  13. kronos_finance-0.1.0/docs/MODEL.md +118 -0
  14. kronos_finance-0.1.0/docs/QUICKSTART.md +87 -0
  15. kronos_finance-0.1.0/docs/TROUBLESHOOTING.md +199 -0
  16. kronos_finance-0.1.0/examples/01_quickstart_predict.py +44 -0
  17. kronos_finance-0.1.0/examples/02_us_stock_yfinance.py +30 -0
  18. kronos_finance-0.1.0/examples/03_cn_a_share_akshare.py +30 -0
  19. kronos_finance-0.1.0/examples/04_crypto_ccxt.py +28 -0
  20. kronos_finance-0.1.0/examples/05_batch_predict.py +31 -0
  21. kronos_finance-0.1.0/examples/06_indicators_and_tearsheet.py +36 -0
  22. kronos_finance-0.1.0/examples/07_cli_predict.sh +15 -0
  23. kronos_finance-0.1.0/examples/08_cli_backtest.sh +15 -0
  24. kronos_finance-0.1.0/examples/09_launch_dashboard.sh +22 -0
  25. kronos_finance-0.1.0/examples/10_save_load_predictions.py +30 -0
  26. kronos_finance-0.1.0/examples/11_qlib_finetune_smoke.py +24 -0
  27. kronos_finance-0.1.0/examples/12_custom_model_local.py +26 -0
  28. kronos_finance-0.1.0/pyproject.toml +102 -0
  29. kronos_finance-0.1.0/setup.cfg +4 -0
  30. kronos_finance-0.1.0/src/kronos_finance/__init__.py +26 -0
  31. kronos_finance-0.1.0/src/kronos_finance/_vendor/kronos_model/__init__.py +17 -0
  32. kronos_finance-0.1.0/src/kronos_finance/_vendor/kronos_model/kronos.py +660 -0
  33. kronos_finance-0.1.0/src/kronos_finance/_vendor/kronos_model/module.py +570 -0
  34. kronos_finance-0.1.0/src/kronos_finance/_version.py +2 -0
  35. kronos_finance-0.1.0/src/kronos_finance/analysis.py +85 -0
  36. kronos_finance-0.1.0/src/kronos_finance/cli.py +194 -0
  37. kronos_finance-0.1.0/src/kronos_finance/dashboard/__init__.py +1 -0
  38. kronos_finance-0.1.0/src/kronos_finance/dashboard/app.py +205 -0
  39. kronos_finance-0.1.0/src/kronos_finance/data.py +251 -0
  40. kronos_finance-0.1.0/src/kronos_finance/exceptions.py +25 -0
  41. kronos_finance-0.1.0/src/kronos_finance/model.py +156 -0
  42. kronos_finance-0.1.0/src/kronos_finance/py.typed +0 -0
  43. kronos_finance-0.1.0/src/kronos_finance/resources/tickers.json +117 -0
  44. kronos_finance-0.1.0/src/kronos_finance/tickers.py +98 -0
  45. kronos_finance-0.1.0/src/kronos_finance.egg-info/PKG-INFO +363 -0
  46. kronos_finance-0.1.0/src/kronos_finance.egg-info/SOURCES.txt +54 -0
  47. kronos_finance-0.1.0/src/kronos_finance.egg-info/dependency_links.txt +1 -0
  48. kronos_finance-0.1.0/src/kronos_finance.egg-info/entry_points.txt +3 -0
  49. kronos_finance-0.1.0/src/kronos_finance.egg-info/requires.txt +64 -0
  50. kronos_finance-0.1.0/src/kronos_finance.egg-info/top_level.txt +1 -0
  51. kronos_finance-0.1.0/tests/test_analysis.py +128 -0
  52. kronos_finance-0.1.0/tests/test_cli.py +104 -0
  53. kronos_finance-0.1.0/tests/test_data.py +167 -0
  54. kronos_finance-0.1.0/tests/test_exceptions.py +54 -0
  55. kronos_finance-0.1.0/tests/test_model.py +183 -0
  56. kronos_finance-0.1.0/tests/test_tickers.py +135 -0
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ All notable changes to `kronos-finance` are documented here.
4
+ Format follows [Keep a Changelog](https://keepachangelog.com/).
5
+
6
+ ## [0.1.0] - 2026-09-23
7
+
8
+ ### Added
9
+
10
+ - Initial release: Pythonic wrapper around the Kronos foundation model
11
+ (https://github.com/shiyu-coder/Kronos, AAAI 2026, MIT).
12
+ - Public API: `load_kronos()`, `KronosWrapper.predict()`, `KronosWrapper.predict_batch()`.
13
+ - Multi-source OHLCV loaders behind one `load_ohlcv(ticker, source='auto', ...)`:
14
+ AKShare (CN A-shares), yfinance (global equities/ETFs/indices), CCXT
15
+ (crypto exchanges), Qlib (CN quant platform), local CSV.
16
+ - Auto-detection of source from ticker shape (digit/prefix/letter/suffix).
17
+ - `~/.kronos/cache/` parquet cache layer with 24h TTL.
18
+ - Bundled ticker catalog (48 entries, 9 categories) + user-extendable
19
+ `~/.kronos/tickers.json` (overridable via `KRONOS_FINANCE_TICKERS`).
20
+ - CLI: `kronos predict`, `kronos batch`, `kronos backtest`, `kronos ui`,
21
+ `kronos tickers {list,search,add}`. SIGINT handler exits 130 cleanly.
22
+ - Flask dashboard with candlestick chart (Plotly), autocomplete from the
23
+ catalog, model selector, source/interval/pred-len/indicators controls,
24
+ metrics card, recent-predictions history with CSV export, dark/light theme.
25
+ - Analysis layer: `enrich_with_indicators()` (RSI/MACD/BBands),
26
+ `forecast_to_returns()`, `make_tearsheet()` (quantstats HTML).
27
+ - 7 source files under `src/kronos_finance/`:
28
+ `__init__.py`, `_version.py`, `exceptions.py`, `model.py`, `data.py`,
29
+ `tickers.py`, `analysis.py`, `cli.py`, `dashboard/{app.py, templates/, static/}`.
30
+ - Exception hierarchy: `KronosFinanceError` + `TickerNotFoundError`,
31
+ `DataSourceError`, `ModelLoadError`, `PredictionError`, `CatalogError`.
32
+ - Optional extras: `[cn]`, `[global]`, `[crypto]`, `[qlib]`, `[ui]`,
33
+ `[analysis]`, `[finetune]`, `[dev]`, `[test]`, `[all]`.
34
+ - 12 runnable examples under `examples/` (5 .py + 3 .sh + 2 mixed + README).
35
+ - Comprehensive docs (10 files in `docs/` + the README).
36
+ - Test suite: 48 tests across 6 files (exceptions, data, tickers, model,
37
+ analysis, cli) using a stdlib runner so they execute without pytest.
38
+ - Pre-commit config for ruff.
39
+ - Vendored upstream Kronos model code under `src/kronos_finance/_vendor/`
40
+ with the upstream MIT LICENSE preserved alongside.
41
+ - MIT LICENSE for the wrapper.
42
+
43
+ ### Notes
44
+
45
+ - Tested locally with stdlib runner; CI runs pytest on Py 3.10/3.11/3.12.
46
+ - The `workflow` scope on the deploy PAT is required to push the CI
47
+ workflow files (`.github/workflows/ci.yml`, `publish.yml`); they are
48
+ held back at `/tmp/deferred-github/` until the PAT is rotated.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kronos-finance contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE CHANGELOG.md README.md
2
+ recursive-include src/kronos_finance/resources *.json
3
+ recursive-include examples *.py *.sh
4
+ recursive-include docs *.md
@@ -0,0 +1,363 @@
1
+ Metadata-Version: 2.4
2
+ Name: kronos-finance
3
+ Version: 0.1.0
4
+ Summary: Pythonic wrapper around the Kronos foundation model for OHLCV forecasting across any market
5
+ Author-email: lordxmen2k <lordxmen2k@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/lordxmen2k/kronos-finance
8
+ Project-URL: Repository, https://github.com/lordxmen2k/kronos-finance
9
+ Project-URL: Issues, https://github.com/lordxmen2k/kronos-finance/issues
10
+ Project-URL: Changelog, https://github.com/lordxmen2k/kronos-finance/blob/main/CHANGELOG.md
11
+ Project-URL: Citation, https://github.com/lordxmen2k/kronos-finance#citation
12
+ Keywords: kronos,finance,ohlcv,forecasting,foundation-model,time-series,quant
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Topic :: Office/Business :: Financial :: Investment
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: torch>=2.0.0
27
+ Requires-Dist: numpy>=1.26
28
+ Requires-Dist: pandas>=2.2
29
+ Requires-Dist: einops>=0.8.1
30
+ Requires-Dist: huggingface_hub>=0.33.1
31
+ Requires-Dist: safetensors>=0.6.2
32
+ Requires-Dist: tqdm>=4.67.1
33
+ Requires-Dist: matplotlib>=3.9.3
34
+ Provides-Extra: cn
35
+ Requires-Dist: akshare>=1.18.0; extra == "cn"
36
+ Provides-Extra: global
37
+ Requires-Dist: yfinance>=0.2.60; extra == "global"
38
+ Provides-Extra: crypto
39
+ Requires-Dist: ccxt>=4.0.0; extra == "crypto"
40
+ Provides-Extra: qlib
41
+ Requires-Dist: pyqlib>=0.9.7; extra == "qlib"
42
+ Provides-Extra: ui
43
+ Requires-Dist: flask>=2.3; extra == "ui"
44
+ Requires-Dist: flask-cors>=4.0; extra == "ui"
45
+ Requires-Dist: plotly>=5.17; extra == "ui"
46
+ Provides-Extra: analysis
47
+ Requires-Dist: pandas-ta>=0.3.14b; extra == "analysis"
48
+ Requires-Dist: quantstats>=0.0.62; extra == "analysis"
49
+ Provides-Extra: finetune
50
+ Requires-Dist: pyqlib>=0.9.7; extra == "finetune"
51
+ Requires-Dist: pyyaml>=6.0; extra == "finetune"
52
+ Requires-Dist: comet-ml>=3.0; extra == "finetune"
53
+ Provides-Extra: dev
54
+ Requires-Dist: pytest>=8.0; extra == "dev"
55
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
56
+ Requires-Dist: ruff>=0.6; extra == "dev"
57
+ Requires-Dist: mypy>=1.11; extra == "dev"
58
+ Requires-Dist: pre-commit>=4.0; extra == "dev"
59
+ Requires-Dist: ipython>=8.0; extra == "dev"
60
+ Provides-Extra: test
61
+ Requires-Dist: pytest-playwright>=0.5; extra == "test"
62
+ Requires-Dist: playwright>=1.47; extra == "test"
63
+ Provides-Extra: docs
64
+ Requires-Dist: mkdocs>=1.5; extra == "docs"
65
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
66
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
67
+ Provides-Extra: all
68
+ Requires-Dist: akshare>=1.18.0; extra == "all"
69
+ Requires-Dist: yfinance>=0.2.60; extra == "all"
70
+ Requires-Dist: ccxt>=4.0.0; extra == "all"
71
+ Requires-Dist: pyqlib>=0.9.7; extra == "all"
72
+ Requires-Dist: flask>=2.3; extra == "all"
73
+ Requires-Dist: flask-cors>=4.0; extra == "all"
74
+ Requires-Dist: plotly>=5.17; extra == "all"
75
+ Requires-Dist: pandas-ta>=0.3.14b; extra == "all"
76
+ Requires-Dist: quantstats>=0.0.62; extra == "all"
77
+ Requires-Dist: pyyaml>=6.0; extra == "all"
78
+ Requires-Dist: comet-ml>=3.0; extra == "all"
79
+ Dynamic: license-file
80
+
81
+ # kronos-finance
82
+
83
+ [![](https://img.shields.io/pypi/v/kronos-finance.svg)](https://pypi.org/project/kronos-finance/)
84
+ [![](https://img.shields.io/pypi/pyversions/kronos-finance.svg)](https://pypi.org/project/kronos-finance/)
85
+ [![](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
86
+ [![](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
87
+ [![](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue.svg)](#)
88
+
89
+ > Pythonic wrapper around the Kronos foundation model for OHLCV forecasting across any market.
90
+
91
+ ## Built on Kronos
92
+
93
+ Kronos is the first open-source foundation model for financial candlesticks (K-lines),
94
+ by the [NeoQuasar team](https://github.com/shiyu-coder/Kronos), accepted at AAAI 2026,
95
+ MIT-licensed.
96
+
97
+ This package (`kronos-finance`) is a **wrapper** that turns the upstream research codebase
98
+ into a pip-installable library with a CLI, a dashboard, multi-source data loaders, and
99
+ comprehensive tests. All model code comes from the original project — see the
100
+ [Citation](#citation) section.
101
+
102
+ - Original repo: <https://github.com/shiyu-coder/Kronos>
103
+ - Paper: <https://arxiv.org/abs/2508.02739>
104
+ - Model zoo on HuggingFace: <https://huggingface.co/NeoQuasar>
105
+
106
+ ## Use a virtual environment (recommended)
107
+
108
+ A virtual environment keeps your system Python clean and avoids the
109
+ `error: externally-managed-environment` (PEP 668) error on Ubuntu 23.04+,
110
+ macOS Homebrew Python, and Fedora 39+.
111
+
112
+ ```bash
113
+ python -m venv .venv
114
+ source .venv/bin/activate # macOS / Linux
115
+ # .venv\Scripts\activate # Windows PowerShell
116
+ ```
117
+
118
+ Every install command below assumes you've activated a venv first.
119
+
120
+ ## Installation
121
+
122
+ ```bash
123
+ pip install kronos-finance # core (CPU, ~400MB incl. PyTorch)
124
+ pip install kronos-finance[cn] # + AKShare for Chinese A-shares
125
+ pip install kronos-finance[global] # + yfinance for global equities
126
+ pip install kronos-finance[crypto] # + CCXT for crypto exchanges
127
+ pip install kronos-finance[qlib] # + Qlib for CN finetune data
128
+ pip install kronos-finance[ui] # + Flask + Plotly for the dashboard
129
+ pip install kronos-finance[analysis] # + pandas-ta + quantstats
130
+ pip install kronos-finance[all] # everything above
131
+ ```
132
+
133
+ Verify the install:
134
+
135
+ ```bash
136
+ kronos --version
137
+ ```
138
+
139
+ ## Quickstart (60 seconds)
140
+
141
+ ```python
142
+ from kronos_finance import load_kronos
143
+ from kronos_finance.data import load_ohlcv
144
+ import pandas as pd
145
+
146
+ df = load_ohlcv("AAPL", period="2y", interval="1d")
147
+ wrapper = load_kronos(model_id="small")
148
+ y_ts = pd.date_range(df["timestamps"].iloc[-1], periods=31, freq="1D")[1:]
149
+ pred = wrapper.predict(
150
+ df=df[["open", "high", "low", "close", "volume", "amount"]].tail(400),
151
+ x_timestamp=df["timestamps"].tail(400), y_timestamp=y_ts, pred_len=30,
152
+ )
153
+ print(pred.head())
154
+ ```
155
+
156
+ ## Features
157
+
158
+ - One-line predict on any market — US equities, CN A-shares, crypto, HK, JP, EU.
159
+ - Multi-source loaders — AKShare, yfinance, CCXT, Qlib, local CSV.
160
+ - Ticker auto-detection — type `"600519"` and AKShare is picked; type `"BTC/USDT"` and
161
+ CCXT is picked.
162
+ - Bundled ticker catalog + user-extendable `~/.kronos/tickers.json`.
163
+ - CLI: `kronos predict`, `kronos backtest`, `kronos ui`, `kronos tickers`.
164
+ - Flask dashboard with candlestick chart, autocomplete, model selector, indicator overlay.
165
+ - Optional indicators (RSI, MACD, BBands) and HTML tearsheets (quantstats).
166
+ - 12 runnable examples + comprehensive docs + a 35-term glossary.
167
+
168
+ ## How to predict any ticker in the world
169
+
170
+ | Market | Ticker format | Source | Install extra |
171
+ |---|---|---|---|
172
+ | US equity | `AAPL`, `MSFT`, `NVDA` | yfinance | `[global]` |
173
+ | US ETF | `SPY`, `QQQ`, `IWM` | yfinance | `[global]` |
174
+ | US index | `^GSPC`, `^DJI`, `^IXIC` | yfinance | `[global]` |
175
+ | CN A-share | `600519`, `000001`, `002594` | AKShare | `[cn]` |
176
+ | CN index | `000300`, `000905` | AKShare | `[cn]` |
177
+ | Crypto pair | `BTC/USDT`, `ETH/USDT` | CCXT (Binance default) | `[crypto]` |
178
+ | HK stock | `0700.HK`, `9988.HK` | yfinance | `[global]` |
179
+ | JP stock | `7203.T`, `6758.T` | yfinance | `[global]` |
180
+ | EU stock | `ASML.AS`, `SAP.DE` | yfinance | `[global]` |
181
+ | Local CSV | path to `.csv` | `csv_path=` | (core) |
182
+
183
+ The `source="auto"` default routes the ticker to the right loader based on its shape.
184
+
185
+ ## CLI reference
186
+
187
+ ```bash
188
+ kronos predict TICKER [--source auto] [--model small] [--interval 1d]
189
+ [--pred-len 30] [--lookback 400] [--export forecast.csv]
190
+ [--device cpu]
191
+ kronos batch TICKERS_FILE [--output ./out] [--model small] [--pred-len 30]
192
+ kronos backtest TICKER [--period 1y] [--interval 1d] [--source auto]
193
+ [--export tearsheet.html]
194
+ kronos ui [--host 127.0.0.1] [--port 5000] [--debug]
195
+ kronos tickers list
196
+ kronos tickers search QUERY [--market cn|us|crypto|...]
197
+ kronos tickers add SYMBOL NAME SOURCE [--exchange binance]
198
+ kronos --version
199
+ kronos --help
200
+ ```
201
+
202
+ Examples:
203
+
204
+ ```bash
205
+ kronos predict 600519 --source akshare
206
+ kronos predict BTC/USDT --source ccxt --exchange binance
207
+ ```
208
+
209
+ Exit codes: `0` ok, `1` generic error, `2` usage error, `130` SIGINT (clean Ctrl+C).
210
+
211
+ ## Python API
212
+
213
+ ```python
214
+ from kronos_finance import load_kronos # model
215
+ from kronos_finance.data import load_ohlcv # data fetchers
216
+ from kronos_finance.tickers import catalog, search, add_user_ticker
217
+ from kronos_finance.analysis import (
218
+ enrich_with_indicators, forecast_to_returns, make_tearsheet,
219
+ )
220
+ from kronos_finance import ( # errors
221
+ KronosFinanceError, TickerNotFoundError,
222
+ DataSourceError, ModelLoadError, PredictionError, CatalogError,
223
+ )
224
+ ```
225
+
226
+ Full reference: [`docs/API.md`](docs/API.md).
227
+
228
+ ## Dashboard
229
+
230
+ Launch with `kronos ui` (default `http://127.0.0.1:5000`):
231
+
232
+ - Ticker input with autocomplete from the bundled + user catalog.
233
+ - Candlestick chart with historical in green/red and forecast in blue/purple.
234
+ - Model selector (mini / small / base with parameter counts).
235
+ - Source + interval pickers.
236
+ - Indicator overlay (RSI / MACD / BBands).
237
+ - Recent predictions history with CSV export.
238
+ - Dark / light theme toggle.
239
+
240
+ Full tour: [`docs/DASHBOARD.md`](docs/DASHBOARD.md).
241
+
242
+ ## Examples
243
+
244
+ Twelve runnable examples in [`examples/`](examples/). Each starts with the venv setup
245
+ reminder. See [`examples/README.md`](examples/README.md).
246
+
247
+ ## Troubleshooting
248
+
249
+ The most common pitfalls — full list in [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md):
250
+
251
+ - **`error: externally-managed-environment`** — you're trying to `pip install` into
252
+ system Python. Use a venv (see the section at the top of this README).
253
+ - **Model download stalls / 401 from HuggingFace** — set `HF_TOKEN` or run
254
+ `huggingface-cli login`.
255
+ - **CUDA version mismatch** — install PyTorch from the matching CUDA index URL.
256
+ - **yfinance rate limit** — switch to `auto` source or add `period=` to limit.
257
+ - **AKShare returns empty** — the ticker may have delisted. Try yfinance with
258
+ `600519.SS`.
259
+ - **Playwright browser missing** — `playwright install --with-deps chromium`.
260
+ - **`max_context` exceeded** — reduce `lookback` or use `Kronos-mini` (2048 context).
261
+ - **Tz-aware timestamp warning** — convert to UTC and drop the tz before passing in.
262
+ - **PermissionError on Windows** — run your terminal as Administrator or use a venv.
263
+
264
+ ## How it works
265
+
266
+ ```
267
+ Ticker (e.g. "AAPL")
268
+ │
269
+ ▼ load_ohlcv() auto-detects source -> yfinance
270
+ pd.DataFrame [timestamps, open, high, low, close, volume, amount]
271
+ │
272
+ ▼ load_kronos() downloads Kronos-small from HuggingFace
273
+ KronosWrapper (model + tokenizer + predictor)
274
+ │
275
+ ▼ wrapper.predict() runs autoregressive Transformer
276
+ pd.DataFrame [predicted OHLCV]
277
+ │
278
+ ▼ analysis: indicators + backtest -> HTML tearsheet
279
+ ```
280
+
281
+ ## Performance & limits
282
+
283
+ | Setting | Default | Cap | Note |
284
+ |---|---|---|---|
285
+ | `pred_len` | 30 | 1000 (CLI), no cap in API | Larger = slower inference |
286
+ | `lookback` | 400 | 512 (small/base/large), 2048 (mini) | Auto-truncated |
287
+ | `sample_count` | 1 | 20 | Quantile bands need >1 |
288
+ | Memory (CPU, small) | ~1GB | — | +500MB for base |
289
+ | Memory (CUDA, base) | ~2GB VRAM | — | RTX 3060+ recommended |
290
+ | Latency (CPU, 30-step, 1 ticker) | ~5s | — | ~1s on CUDA |
291
+
292
+ ## Development
293
+
294
+ ```bash
295
+ git clone https://github.com/lordxmen2k/kronos-finance.git
296
+ cd kronos-finance
297
+ python -m venv .venv && source .venv/bin/activate
298
+ pip install -e ".[dev,test,ui]"
299
+ pytest # unit + CLI tests
300
+ ruff check src/ # lint
301
+ ```
302
+
303
+ See [`docs/CONTRIBUTING.md`](docs/CONTRIBUTING.md).
304
+
305
+ ## Citation
306
+
307
+ If you use this in research, please cite the original Kronos paper:
308
+
309
+ ```bibtex
310
+ @inproceedings{kronos2026,
311
+ title = {Kronos: A Foundation Model for the Language of Financial Markets},
312
+ author = {Shi, Yu and others},
313
+ booktitle = {AAAI},
314
+ year = {2026},
315
+ }
316
+ ```
317
+
318
+ And this wrapper:
319
+
320
+ ```bibtex
321
+ @software{kronos_finance,
322
+ author = {lordxmen2k},
323
+ title = {kronos-finance: A Python wrapper for Kronos},
324
+ year = {2026},
325
+ url = {https://github.com/lordxmen2k/kronos-finance}
326
+ }
327
+ ```
328
+
329
+ ## License
330
+
331
+ MIT — see [`LICENSE`](LICENSE) for the full text. The original Kronos project is also
332
+ MIT; see `src/kronos_finance/_vendor/LICENSE_KRONOS` for the vendored upstream license.
333
+
334
+ ## Acknowledgements
335
+
336
+ - The [NeoQuasar team](https://github.com/shiyu-coder/Kronos) for the Kronos
337
+ foundation model.
338
+ - [HuggingFace](https://huggingface.co/) for model hosting.
339
+ - [AKShare](https://github.com/akfamily/akshare), [yfinance](https://github.com/ranaroussi/yfinance),
340
+ [CCXT](https://github.com/ccxt/ccxt), [Qlib](https://github.com/microsoft/qlib) — the
341
+ data layer.
342
+ - [pandas-ta](https://github.com/twopirllc/pandas-ta), [quantstats](https://github.com/ranaroussi/quantstats) — analysis.
343
+ - [Plotly](https://plotly.com/), [Flask](https://flask.palletsprojects.com/) — the dashboard.
344
+
345
+ ## Glossary
346
+
347
+ See [`docs/INSTALL.md#glossary`](docs/INSTALL.md#glossary) for the full 35-term glossary.
348
+ A quick index of the most important ones:
349
+
350
+ - **OHLCV** — Open, High, Low, Close, Volume. The five columns Kronos expects.
351
+ - **K-line** — Chinese term for candlestick; same thing.
352
+ - **Context length / max_context** — maximum past bars the model can see (512 for
353
+ small/base/large; 2048 for mini).
354
+ - **AR / autoregressive** — generates outputs one step at a time.
355
+ - **Tokenizer** — converts continuous OHLCV to discrete tokens before the Transformer.
356
+ - **Sample count** — number of forecast paths to draw; more = smoother quantile band.
357
+ - **Tearsheet** — one-page performance report; quantstats generates HTML.
358
+ - **Nucleus sampling (top-p)** — sampling from smallest token set whose cumulative prob ≥ p.
359
+ - **Temperature (T)** — sampling temperature; T<1 conservative, T>1 exploratory.
360
+ - **Quantile band** — uncertainty interval drawn when `sample_count > 1`.
361
+ - **PEP 668** — Python spec marking system Python as externally managed; use venv.
362
+ - **Twine** — `twine upload dist/*` publishes to PyPI.
363
+ - **Wheel (.whl)** — built distribution format.