Skip to main content

Agent-first trading framework: describe strategies in natural language, generate executable code, backtest and deploy across exchanges.

Project description

VibeTrading

PyPI version Python >= 3.10 License: MIT

Agent-first trading framework for cryptocurrency. Describe strategies in natural language, generate executable Python code, backtest on historical data, and iteratively improve with LLM-powered analysis.

Installation

pip install vibetrading

Quick Start

Setup

Set your LLM API key (at least one) and optional proxy:

export OPENAI_API_KEY=sk-...        # or ANTHROPIC_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY
export HTTPS_PROXY=http://127.0.0.1:7890   # optional

Or put them in a .env file — the package loads it automatically.

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",
)

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)

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 score performance and get actionable improvement suggestions:

report = vibetrading.strategy.analyze(results, strategy_code=code, model="gpt-4o")

print(f"Score: {report.score}/10")
print(report.summary)
for s in report.suggestions:
    print(f"  → {s}")

Evolve

One call to iteratively improve a strategy through generate → backtest → analyze feedback loops:

import vibetrading

result = vibetrading.evolve(
    "BTC momentum strategy with RSI and SMA crossover, 3x leverage",
    iterations=3,
    model="gpt-4o",
    interval="1h",
)

print(f"Best score: {result.best_score}/10")
print(f"Improved: {result.improved}")
print(result.best_code)

How It Works

Describe  ──▶  Generate  ──▶  Backtest  ──▶  Analyze  ──▶  Evolve
(prompt)       (LLM)          (engine)       (LLM)         (loop)
                  ▲                                           │
                  └──────────── feedback ──────────────────────┘
  1. Describe — Write what you want in plain English.
  2. Generate — An LLM produces framework-compatible strategy code with risk management.
  3. Backtest — Run against historical data from any CCXT-supported exchange.
  4. Analyze — An LLM evaluates backtest results: scores performance, finds weaknesses, suggests fixes.
  5. Evolve — Repeat the loop. Each iteration feeds analysis back to the generator.

Features

  • Any LLM — Works with OpenAI, Anthropic, Google, DeepSeek, or any OpenAI-compatible API via litellm.
  • Built-in validator — Static analysis catches common errors before execution.
  • LLM backtest analysis — Structured scoring (1-10), strengths/weaknesses, and actionable suggestions.
  • Strategy evolutionvibetrading.evolve() runs the full generate → backtest → analyze → regenerate loop.
  • CCXT data — Download and cache OHLCV data from Binance, Bybit, OKX, and 100+ exchanges.
  • Realistic simulation — Limit/market orders, margin, leverage, funding rates, fees, and liquidation detection.

Modules

Module Purpose
vibetrading vibe decorator, evolve()
vibetrading.strategy generate(), validate(), analyze(), prompt templates
vibetrading.backtest BacktestEngine, run()
vibetrading.evolution StrategyEvolver, evolve()
vibetrading.tools download_data(), load_csv()

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vibetrading-0.1.6.tar.gz (66.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vibetrading-0.1.6-py3-none-any.whl (81.7 kB view details)

Uploaded Python 3

File details

Details for the file vibetrading-0.1.6.tar.gz.

File metadata

  • Download URL: vibetrading-0.1.6.tar.gz
  • Upload date:
  • Size: 66.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for vibetrading-0.1.6.tar.gz
Algorithm Hash digest
SHA256 3bec53407f724a7efbefd93994148d4297594a044b62186987b2246a0e8f12fd
MD5 fb9c017e1e19df5a32ad3d7029c963ac
BLAKE2b-256 c8b5ddc3085ef264ebb31ea9f340035112f68e099def78580fe8b8ed794d9415

See more details on using hashes here.

File details

Details for the file vibetrading-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: vibetrading-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 81.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for vibetrading-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9ddca9f28608b1f86dfcab92faa60b496052e6e3d0abde64835c8d0e7693b390
MD5 325b6ce7e40164642ad321f4e15118d4
BLAKE2b-256 0f935de8d29c098442b18d286c7efcd08ce579025acd7e2c972eb4bca5827606

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page