TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
@backtest-kit/ollama package provides unified LLM inference across more than 10 providers — OpenAI, Claude, DeepSeek, Grok, Mistral, Perplexity, Cohere, Alibaba, Hugging Face, and local Ollama — through a single API designed from the ground up for trading strategy use cases. It returns structured trading signals with validated TP/SL levels, supports automatic token rotation for Ollama, and works identically in both backtest and live trading modes. The goal is to make it straightforward to build multi-provider fallback chains and ensemble prediction pipelines without managing multiple SDK clients.
Supported Providers
OpenAI
GPT-4o, GPT-4.1, GPT-5
Claude
claude-3-5-sonnet, claude-opus-4
DeepSeek
deepseek-chat, deepseek-reasoner
Grok
grok-3, grok-3-mini
Mistral
mistral-large, codestral
Perplexity
sonar, sonar-pro
Cohere
command-r-plus
Alibaba
qwen-plus, qwen-turbo
Hugging Face
Any hosted model
Ollama
Any local model
Key Features
Token Rotation
Automatic API key rotation for Ollama — cycle through multiple local instances to distribute inference load. Other providers throw clear errors on key exhaustion instead of silently failing.
Structured Output
Enforced JSON schema for trading signals. Every response is validated to contain a position direction, entry price, TP/SL levels, and risk notes before being returned.
Flexible Auth
Pass API keys directly in the call context or use environment variables — whichever fits your project structure. Both modes are supported across all providers.
Unified API
One function signature works across all providers. Switching from DeepSeek to Claude to Ollama requires changing only the provider name — no SDK swaps.
Trading-First Design
Built for
getSignal functions in backtest-kit. The output shape matches addStrategySchema directly — no post-processing of LLM responses required.Getting Started
Structured Output Schema
Everycomplete() call enforces a JSON schema on the LLM response. The returned object is validated before being passed back to your strategy:
long signal with priceTakeProfit < priceOpen is rejected and triggers a retry — the LLM is asked to correct the output rather than returning an invalid signal to your strategy.
Multi-Provider Fallback Chains
The unified API makes it straightforward to build fallback chains where a faster or cheaper primary model handles most calls and a more capable model takes over on failure:The
@backtest-kit/sidekick scaffold pre-configures this exact three-provider fallback chain (DeepSeek → Claude → GPT) out of the box. If you use Sidekick to initialize your project, the fallback chain is ready to run without any additional configuration.Ollama Token Rotation
For local Ollama deployments running multiple model instances,@backtest-kit/ollama supports automatic token rotation to distribute inference requests: