Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions kronos_studio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/

parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Jupyter Notebook
.ipynb_checkpoints

# PyCharm
.idea/

# VS Code
.vscode/

# macOS
.DS_Store
.AppleDouble
.LSOverride

# Windows
Thumbs.db
ehthumbs.db
Desktop.ini

# Linux
*~

# Data files (large files)
*.feather
*.parquet
*.h5
*.hdf5

# Model files (large files)
*.pth
*.pt
*.ckpt
*.bin

# Logs
*.log
logs/

# Environment
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Temporary files
*.tmp
*.temp
temp/
tmp/
.python-version

# SQLite database
*.db
*.db-shm
*.db-wal

# Uploaded local data
web/server/uploads/
175 changes: 175 additions & 0 deletions kronos_studio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Kronos Studio

A clean, interactive UI for testing and exploring **Kronos** the first open-source foundation model for financial candlestick (K-line) data, pre-trained on data from 45+ global exchanges.

Kronos Studio gives you a no-code interface to run Kronos models, visualize OHLCV forecasts, and manage results. If you want to quickly test what the models can do without writing any Python, this is the easiest way to do it.

> Kronos paper: [arXiv 2508.02739](https://arxiv.org/abs/2508.02739) · Accepted at **AAAI 2026** </br>
> Kronos repository: https://github.com/shiyu-coder/Kronos

## What You Can Do

- **Run price predictions** on any crypto or stock ticker using Kronos transformer models
- **Choose your data source** — Binance (crypto), yFinance (stocks), or upload your own CSV
- **Single or Batch mode** — predict one asset or many at once
- **Interactive OHLCV charts** — history transitions smoothly into the forecast region
- **Export results** — download charts as SVG/PNG or raw data as CSV
- **Save & revisit** — store prediction results in a local SQLite database and browse them later

[Watch Demo](https://www.youtube.com/watch?v=z7dYEWtH8ro)

## Screenshots

### 1. Single Prediction — ETHUSDT (Binance, 1h)

Configure your model, data source, and sampling parameters on the left. The forecast appears instantly on the right as an interactive chart showing historical candles blending into the predicted region.

![Single prediction view showing ETHUSDT price forecast](./docs/screenshots/single.png)

### 2. Batch Prediction — Multiple Assets

Add up to 20 symbol/source combinations. Run them all at once and switch between results using the dropdown. A **Download All** button exports every chart as a ZIP.

![Batch prediction view with AAPL and ETHUSDT](./docs/screenshots/batch.png)

### 3. Saved Results

All saved predictions are stored locally and accessible from the **Saved Results** page. Each entry shows the market, model, interval, and forecast length — along with a full chart replay.

![Saved results page with SOLUSDT forecast](./docs/screenshots/saved.png)

## Project Structure

```
Kronos-Studio/
├── server/ # FastAPI prediction server (Python 3.13)
│ ├── model/ # Kronos model definitions (PyTorch)
│ ├── routers/ # API route handlers
│ ├── schemas/ # Pydantic request/response models
│ ├── services/ # Business logic (prediction, data, results)
│ ├── db/ # SQLite connection & migrations
│ ├── errors/ # Custom exception classes
│ ├── constants/ # Shared constants
│ ├── tests/ # Pytest test suite
│ └── main.py # Application entry point
└── frontend/ # Next.js 16 web UI (TypeScript)
└── src/
├── app/ # Next.js App Router pages
├── components/ # Reusable React components
├── hooks/ # Custom React hooks
├── stores/ # Zustand global state
├── schemas/ # Zod validation schemas
├── lib/ # API client & utilities
└── utils/ # Download & export helpers
```

## Prerequisites

| Tool | Minimum Version | Purpose |
| -------------------------------- | --------------- | ------------------------ |
| Python | **3.13+** | Server runtime |
| [uv](https://docs.astral.sh/uv/) | latest | Python package manager |
| Node.js | **18+** | Frontend runtime |
| npm | **9+** | Frontend package manager |

### Install `uv` (Python package manager)

```bash
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Or via pip
pip install uv
```

## Getting Started

### 1. Install dependencies

```bash
# Backend
cd server && uv sync

# Frontend
cd frontend && npm install
```

### 2. Run

Open two terminals:

```bash
# Terminal 1 — Backend
cd server
uv run .\start_server.py

# Terminal 2 — Frontend
cd frontend
npm run build && npm run start
```

Then open **[http://localhost:3000](http://localhost:3000)**.

## How to Use

### Single Prediction

1. Open the app and select the **Single** tab.
2. Pick a **Kronos model** (`mini`, `small`, or `base`).
3. Choose a **data source**: Binance, yFinance, or Local CSV.
4. Enter a **ticker symbol** — e.g. `ETHUSDT`, `AAPL`, `TSLA`.
5. Set your lookback window, prediction length, and sampling parameters.
6. Click **Predict** — the chart renders history + forecast in seconds.
7. Use the toolbar to **Save**, export as **SVG/PNG**, or download raw **CSV**.

### Batch Predictions

1. Switch to the **Batch** tab.
2. Click **+ Add** to add symbol entries (up to 20).
3. Each symbol can have its own source, interval, limit, and sampling params.
4. Click **Predict Batch** — all predictions run in parallel.
5. Use the dropdown to switch between results; hit **Download All** to get a ZIP of all charts.

### Saved Results

1. After any prediction, click **Save** to store it with an optional label.
2. Navigate to **Saved Results** (top-right) to browse stored predictions.
3. Each result shows market info, model used, forecast length, and a full chart.
4. Results are stored locally in `server/db/kronos.db`.

### Local CSV Upload

Your CSV must include OHLCV columns (auto-normalized):

```
Date, Open, High, Low, Close, Volume
```

1. Select **Local** as the data source and upload your file.
2. The server stores it and returns a path this is used automatically for prediction.

## Available Kronos Models

| Model | Params | Context Length | Best For |
| -------------- | ------ | -------------- | --------------------------------- |
| `kronos-mini` | 4.1M | 2048 tokens | Fast inference, quick prototyping |
| `kronos-small` | 24.7M | 512 tokens | Balanced speed vs. accuracy |
| `kronos-base` | 102.3M | 512 tokens | Best accuracy, more compute |

> **First run:** Models download automatically from Hugging Face Hub on first use. An internet connection is required.

---

## Troubleshooting

**Model download fails**
Kronos models are pulled from Hugging Face on first use. Check your internet connection and ensure `huggingface_hub` is installed via `uv sync`.

**Frontend can't reach the API**
Confirm the backend is running on port `8000` and CORS middleware allows `*` in `server/main.py`.

**CUDA / GPU not detected**
Set `device` to `"cpu"` in the prediction request, or ensure PyTorch with CUDA support is installed and GPU drivers are up to date.
Binary file added kronos_studio/docs/screenshots/batch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kronos_studio/docs/screenshots/saved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kronos_studio/docs/screenshots/single.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions kronos_studio/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
.npm-cache
5 changes: 5 additions & 0 deletions kronos_studio/frontend/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->
1 change: 1 addition & 0 deletions kronos_studio/frontend/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
36 changes: 36 additions & 0 deletions kronos_studio/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
29 changes: 29 additions & 0 deletions kronos_studio/frontend/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "radix-lyra",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/app/globals.css",
"baseColor": "taupe",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "phosphor",
"rtl": false,
"menuColor": "default",
"menuAccent": "subtle",
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"registries": {
"@reui": "https://reui.io/r/{style}/{name}.json",
"@shadcnblocks": "https://shadcnblocks.com/r/{name}.json",
"@aceternity": "https://ui.aceternity.com/registry/{name}.json"
}
}
18 changes: 18 additions & 0 deletions kronos_studio/frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";

const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);

export default eslintConfig;
Loading