Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-docs/llms.txt

Use this file to discover all available pages before exploring further.

@backtest-kit/signals is a pre-built indicator suite designed specifically for AI-powered strategies. It computes more than 50 technical indicators across four synchronized timeframes and formats the results as markdown tables ready for LLM context injection. Instead of manually calculating RSI, MACD, Bollinger Bands, and order book depth for each timeframe and formatting them for your prompt, a single function call adds the complete analysis to your message context.

Install

npm install @backtest-kit/signals backtest-kit

Supported Indicators

Indicators are computed across four timeframes with settings tuned to each trading horizon:
TimeframeLabelCandlesIndicators
1mMicroTerm60RSI(9,14), MACD(8,21,5), Stochastic, ADX(9), Bollinger(8,2), ATR, CCI, Volume, Squeeze
15mShortTerm144RSI(9), MACD(8,21,5), Stochastic(5,3,3), ADX(14), Bollinger(10,2), Fibonacci
30mSwingTerm96RSI(14), MACD(12,26,9), Stochastic(14,3,3), Bollinger(20,2), Support/Resistance
1hLongTerm100RSI(14), MACD(12,26,9), ADX(14), Bollinger(20,2), SMA(50), DEMA, WMA, Volume Trend
Plus real-time order book analysis: bid/ask depth, spread, liquidity imbalance, and top 20 levels on both sides.

Usage

All-in-One Report

The simplest integration — one call adds the complete technical context to your LLM message array:
import { commitHistorySetup } from '@backtest-kit/signals';
import { addStrategySchema } from 'backtest-kit';

addStrategySchema({
  strategyName: 'llm-strategy',
  interval: '5m',
  riskName: 'demo',
  getSignal: async (symbol) => {
    const messages = [
      {
        role: 'system',
        content: 'You are a trading bot. Analyze technical indicators and generate signals.',
      },
    ];

    // Adds order book + candle history + 50+ indicators for all 4 timeframes
    await commitHistorySetup(symbol, messages);

    messages.push({
      role: 'user',
      content: 'Based on the technical analysis above, generate a trading signal in JSON format.',
    });

    const signal = await llm(messages);
    return signal;
  },
});

Granular Control

For fine-grained control over which data to include:
import {
  commitBookDataReport,
  commitOneMinuteHistory,
  commitFifteenMinuteHistory,
  commitThirtyMinuteHistory,
  commitHourHistory,
  commitMicroTermMath,
  commitShortTermMath,
  commitSwingTermMath,
  commitLongTermMath,
} from '@backtest-kit/signals';

const messages = [];

// Order book analysis (bid/ask depth, spread, imbalance, top 20 levels)
await commitBookDataReport('BTCUSDT', messages);

// Candle histories
await commitOneMinuteHistory('BTCUSDT', messages);      // Last 15 candles
await commitFifteenMinuteHistory('BTCUSDT', messages);  // Last 8 candles
await commitThirtyMinuteHistory('BTCUSDT', messages);   // Last 6 candles
await commitHourHistory('BTCUSDT', messages);           // Last 6 candles

// Technical indicators per timeframe
await commitMicroTermMath('BTCUSDT', messages);   // 1m indicators
await commitShortTermMath('BTCUSDT', messages);   // 15m indicators
await commitSwingTermMath('BTCUSDT', messages);   // 30m indicators
await commitLongTermMath('BTCUSDT', messages);    // 1h indicators

Order Book Analysis

The order book report includes:
  • Best bid and ask prices
  • Mid price and spread
  • Depth imbalance percentage and direction (buy/sell pressure)
  • Top 20 bid and ask levels with volume and percentage of total depth
Imbalance is calculated as:
imbalance = (bid_volume - ask_volume) / (bid_volume + ask_volume)
Positive values indicate buy pressure; negative values indicate sell pressure.

AI-Ready Output

All reports are formatted as markdown tables that inject cleanly into LLM context windows. The indicator report for each timeframe includes a Data Sources section that documents the exact parameters used — giving the model the context it needs to interpret the numbers correctly. Generated output for a timeframe looks like:
## MicroTerm Analysis (1-Minute Timeframe)

| Time  | Price | RSI(9) | RSI(14) | MACD  | Signal | ... |
|-------|-------|--------|---------|-------|--------|-----|
| 10:00 | 50020 | 55.2   | 52.8    | 12.5  | 8.3    | ... |
...

**Data Sources:**
- RSI periods: 9, 14
- MACD: Fast=8, Slow=21, Signal=5
...

Performance and Caching

Reports are cached to avoid redundant calculations across ticks:
TimeframeCache Duration
1-minute data1 minute
15-minute data5 minutes
30-minute data15 minutes
1-hour data30 minutes
Order book5 minutes
The cache is cleared automatically on errors, so a failed fetch always triggers a fresh calculation on the next call.
Combine @backtest-kit/signals with @backtest-kit/ollama for a complete AI strategy setup. Use commitHistorySetup() to build the analysis context, then wrap your getSignal with a provider HOF from @backtest-kit/ollama. The two packages are designed to work together — signals prepares the market context, ollama routes it to your preferred LLM and enforces the structured output schema.

Build docs developers (and LLMs) love