# Default Rolling Window Sizes in CloddsBot's Feature Engine: Complete Configuration Guide

> Discover CloddsBot's default rolling window sizes: 100-tick for price momentum, 50-spread for liquidity, and 50-return for volatility. Learn how to configure them.

- Repository: [AL/CloddsBot](https://github.com/alsk1992/CloddsBot)
- Tags: configuration-guide
- Published: 2026-09-13

---

**TLDR:** CloddsBot's feature engine uses three default rolling window sizes: a **100-tick buffer** for price momentum calculations, a **50-spread buffer** for order-book liquidity signals, and a **50-return buffer** for volatility statistics, all defined as constants in the service initialization layer and overrideable via configuration parameters.

The feature engineering service in the **alsk1992/CloddsBot** repository maintains circular buffers to preserve recent market data for real-time technical analysis. Understanding the default rolling window sizes in CloddsBot's feature engine allows traders to tune the responsiveness of momentum, velocity, and volatility indicators without modifying core library code.

## The Three Default Rolling Window Buffers

The system implements three distinct rolling windows to isolate specific data streams for statistical calculations.

### Tick Price Window: 100 Ticks

The **tick price window** retains the most recent **100 price and timestamp pairs**. This buffer feeds calculations for momentum, velocity, and short-term volatility metrics. In [`src/services/feature-engineering/index.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/index.ts), this default is declared as `DEFAULT_TICK_WINDOW = 100`.

### Order-Book Spread Window: 50 Spreads

The **order-book spread window** stores **50 recent spread values** (calculated as ask minus bid). This window size determines the lookback period for spread-change detection and liquidity signal generation. The constant `DEFAULT_ORDERBOOK_WINDOW = 50` controls this behavior.

### Return Statistics Window: 50 Returns

The **return-statistics window** (volatility lookback) maintains **50 recent return values** used specifically for rolling standard deviation calculations. Defined as `DEFAULT_VOLATILITY_LOOKBACK = 50`, this parameter is passed directly to the `RollingStats` constructor during feature engine initialization.

## Source Code Location and Constant Definitions

These defaults are hardcoded as module-level constants in the factory function located at [`src/services/feature-engineering/index.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/index.ts). The `createFeatureEngineering()` function imports these values and applies them when no explicit override is provided in the configuration object.

The constants appear near the top of the file (lines 20–24), ensuring they are easily discoverable for developers auditing the system's memory footprint or statistical sensitivity:

- `DEFAULT_TICK_WINDOW = 100`
- `DEFAULT_ORDERBOOK_WINDOW = 50`
- `DEFAULT_VOLATILITY_LOOKBACK = 50`

## Overriding Default Window Sizes

You can override any default by passing a configuration object to `createFeatureEngineering()`. The function accepts a `FeatureConfig` interface that exposes `tickWindowSize`, `orderbookWindowSize`, and `volatilityLookback` parameters.

```typescript
import { createFeatureEngineering } from '@/services/feature-engineering';

// Use system defaults (100-tick, 50-spread, 50-return windows)
const fe = createFeatureEngineering();

// Override defaults for high-frequency trading scenarios
const customFE = createFeatureEngineering({
  tickWindowSize: 200,          // Retain 200 recent ticks
  orderbookWindowSize: 80,      // Retain 80 recent spreads
  volatilityLookback: 30,       // Use 30-return window for faster volatility response
});

```

At runtime, you can inspect the active window sizes through the `getStats()` method:

```typescript
console.log('Tick window size:', fe.getStats().tickWindowSize ?? 100);
console.log('Order-book window size:', fe.getStats().orderbookWindowSize ?? 50);

```

## Rolling Window Implementation Architecture

The buffers themselves are implemented by two specialized classes in [`src/services/feature-engineering/rolling-window.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/rolling-window.ts):

- **`RollingWindow`**: Manages circular storage for raw tick and spread data, handling buffer overflows by overwriting the oldest entries.
- **`RollingStats`**: Computes incremental statistics (mean, variance, standard deviation) over the return buffer without requiring full array recalculation.

When `createFeatureEngineering()` instantiates the service, it passes `DEFAULT_VOLATILITY_LOOKBACK` (or your custom value) to the `RollingStats` constructor, while `RollingWindow` instances receive the tick and order-book window sizes directly.

## Summary

- **100 ticks**: Default buffer size for price data used in momentum and velocity calculations.
- **50 spreads**: Default buffer size for order-book spread analysis and liquidity signals.
- **50 returns**: Default lookback period for rolling volatility (standard deviation) statistics.
- **Configuration**: Override via `createFeatureEngineering({ tickWindowSize, orderbookWindowSize, volatilityLookback })`.
- **Source files**: Defaults defined in [`src/services/feature-engineering/index.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/index.ts); implementation in [`src/services/feature-engineering/rolling-window.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/rolling-window.ts).

## Frequently Asked Questions

### What are the default window sizes for tick data in CloddsBot?

CloddsBot uses a **100-tick** default window for price data, stored in the `DEFAULT_TICK_WINDOW` constant. This provides a balance between statistical stability and memory efficiency for real-time feature calculations.

### How do I customize the rolling window sizes when initializing the feature engine?

Pass a configuration object to `createFeatureEngineering()` with the properties `tickWindowSize`, `orderbookWindowSize`, and `volatilityLookback`. These values override the internal defaults of 100, 50, and 50 respectively without requiring changes to the source constants.

### Which source file contains the default window size constants?

The constants `DEFAULT_TICK_WINDOW`, `DEFAULT_ORDERBOOK_WINDOW`, and `DEFAULT_VOLATILITY_LOOKBACK` are defined in [`src/services/feature-engineering/index.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/index.ts) at lines 20–24, within the module scope of the feature engineering service.

### What classes manage the rolling window buffers internally?

The `RollingWindow` class manages the circular storage buffers for ticks and spreads, while `RollingStats` handles the statistical calculations over the return window. Both are implemented in [`src/services/feature-engineering/rolling-window.ts`](https://github.com/alsk1992/CloddsBot/blob/main/src/services/feature-engineering/rolling-window.ts) and instantiated by the factory function in [`index.ts`](https://github.com/alsk1992/CloddsBot/blob/main/index.ts).