# Recommended Lookback Window Size for Kronos Predictions: Default Configuration Guide

> Discover the recommended lookback window size for Kronos predictions. Learn why the default 400 time steps is optimal for your inference needs based on the shiyu-coder/Kronos repository.

- Repository: [ShiYu/Kronos](https://github.com/shiyu-coder/Kronos)
- Tags: configuration-guide
- Published: 2026-04-10

---

**The recommended lookback window size for Kronos predictions is 400 time steps, which is the default value hardcoded across the Web UI and all official inference examples in the shiyu-coder/Kronos repository.**

The Kronos time-series forecasting model uses a configurable *lookback* parameter to determine how many historical observations inform each prediction. When running inference via the Web API or Python scripts, the repository consistently defaults to a 400-step window. This value represents the validated configuration that balances historical context with computational efficiency for financial forecasting tasks.

## Where the 400-Step Default Is Defined in Kronos

According to the Kronos source code, the canonical lookback window for prediction is standardized at **400 rows** across multiple entry points. This ensures consistent behavior whether you are using the interactive Web UI or running batch predictions programmatically.

### Web API Endpoint

In [`webui/app.py`](https://github.com/shiyu-coder/Kronos/blob/main/webui/app.py), the prediction endpoint handles incoming JSON requests and applies the default when the parameter is omitted. Lines 410-418 implement the fallback logic:

```python
data = request.get_json()
lookback = int(data.get('lookback', 400))

```

This implementation means API consumers can specify custom values, but the system automatically provides the recommended 400-step baseline when the field is not present in the request payload.

### Inference Examples

All demonstration scripts in the `examples/` directory explicitly initialize the lookback variable to 400. In [`examples/prediction_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_example.py) (lines 52-58), the configuration appears as:

```python
lookback = 400
pred_len = 30

```

Similarly, [`examples/prediction_wo_vol_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_wo_vol_example.py) and [`examples/prediction_batch_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_batch_example.py) adopt this same constant, confirming that 400 steps represents the officially supported configuration for general-purpose forecasting workflows.

## Training vs. Inference Lookback Values

The Kronos repository maintains separate lookback configurations for model training and prediction phases. Configuration files such as [`finetune_csv/config_loader.py`](https://github.com/shiyu-coder/Kronos/blob/main/finetune_csv/config_loader.py) and [`finetune/config.py`](https://github.com/shiyu-coder/Kronos/blob/main/finetune/config.py) may specify alternative window sizes—commonly **512** or **90** steps—for shaping training sequences and optimizing gradient calculations. These training-specific values do not govern inference behavior. When generating actual predictions with a trained model, you should use the **400-step** lookback regardless of the training configuration used to create the model weights.

## Practical Implementation

### Python Script Example

To implement the recommended lookback when running predictions locally, slice your DataFrame to include exactly 400 historical steps:

```python
import pandas as pd

# Load time-series data (must include timestamps column)

df = pd.read_csv('data.csv')

# Recommended lookback for Kronos inference

lookback = 400
pred_len = 30

# Prepare input tensors using the 400-step window

x_df = df.loc[:lookback - 1, ['open', 'high', 'low', 'close', 'volume', 'amount']]
x_timestamp = df.loc[:lookback - 1, 'timestamps']
y_timestamp = df.loc[lookback:lookback + pred_len - 1, 'timestamps']

# Pass to predictor (model-specific implementation)

predictor = KronosPredictor()
pred_df = predictor.predict(x_df, x_timestamp, pred_len)

```

### JSON API Payload

When calling the Kronos Web API, include the lookback parameter in your request body:

```json
{
  "symbol": "AAPL",
  "start": "2023-01-01 09:30",
  "end": "2023-01-31 16:00",
  "lookback": 400,
  "pred_len": 30
}

```

If you omit the `lookback` field, the server automatically applies the default value of 400 as defined in [`webui/app.py`](https://github.com/shiyu-coder/Kronos/blob/main/webui/app.py).

## Summary

- The recommended lookback window size for Kronos predictions is **400 time steps**.
- This default is enforced in [`webui/app.py`](https://github.com/shiyu-coder/Kronos/blob/main/webui/app.py) (lines 410-418) and across all example scripts including [`examples/prediction_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_example.py).
- Training configurations may use different values (such as 512 or 90), but these do not affect inference behavior.
- Use `lookback = 400` when calling the prediction API or running local inference to ensure results match the officially validated configuration.

## Frequently Asked Questions

### What happens if I omit the lookback parameter in API requests?

The Kronos Web API will default to 400 steps. According to [`webui/app.py`](https://github.com/shiyu-coder/Kronos/blob/main/webui/app.py), the code executes `data.get('lookback', 400)`, which returns 400 when the key is missing from the JSON payload.

### Why do training configs use 512 steps while prediction uses 400?

The [`finetune_csv/config_loader.py`](https://github.com/shiyu-coder/Kronos/blob/main/finetune_csv/config_loader.py) file specifies larger windows (such as 512) to accommodate batch processing and gradient optimization during training. During inference, the model utilizes the standardized 400-step window to ensure consistent API behavior and memory usage across different deployment environments.

### Can I adjust the lookback window for different data frequencies?

While the API accepts custom values via the `lookback` parameter in [`webui/app.py`](https://github.com/shiyu-coder/Kronos/blob/main/webui/app.py), the 400-step default assumes minute-level granularity based on the repository's standard datasets. Adjusting this value for hourly or daily data should be done carefully, as reducing the temporal context may degrade forecast accuracy.

### Does the lookback window include the current timestamp or only historical data?

The lookback window consists of the 400 time steps immediately preceding the prediction point. As implemented in the example scripts, the input slicing uses `df.loc[:lookback - 1]` to capture strictly historical observations, with predictions beginning at the next index.