Quick Start

Setup

Install and set your LLM API key:

pip install vibetrading
export OPENAI_API_KEY=sk-...   # or ANTHROPIC_API_KEY, GEMINI_API_KEY, etc.

Generate a Strategy

import vibetrading.strategy

code = vibetrading.strategy.generate(
    "BTC momentum strategy: RSI(14) oversold entry, SMA crossover confirmation, "
    "3x leverage, 10% position size, 8% take-profit, 4% stop-loss",
    model="gpt-4o",
)

print(code)

Backtest

import vibetrading.backtest
import vibetrading.tools

data = vibetrading.tools.download_data(["BTC"], exchange="binance", interval="1h")

results = vibetrading.backtest.run(code, interval="1h", data=data)

if results:
    metrics = results["metrics"]
    print(f"Return: {metrics['total_return']:.2%}")
    print(f"Sharpe: {metrics['sharpe_ratio']:.2f}")
    print(f"Max Drawdown: {metrics['max_drawdown']:.2%}")
    print(f"Win Rate: {metrics['win_rate']:.2%}")

Analyze Results

Use an LLM to evaluate backtest performance:

See Backtest Analysis for full details.

Use the Prompt Template with Any LLM

Don't want to use the built-in generator? Use the prompt template directly with any LLM client:

OpenAI

Anthropic

Validate Generated Code

Check generated strategy code for common errors before running:

Last updated