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.4.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.4-py3-none-any.whl (81.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vibetrading-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 9a49053c824f2ed080fba93a02fb9e238b661073a85f3832b1eabd9d71dd4573
MD5 64b04f6287d070107b38da6b787aa600
BLAKE2b-256 c093046062593bcee94b4f9767d18aada0f9b162cb2a7410ce326e24a9ff9a75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vibetrading-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e5259f650bcde5204df72275fe728f5e5535c195462cf3babc899bbc22346ce5
MD5 e9f71d400fa506962e10c7bd34a6b49d
BLAKE2b-256 118549a394050b9e2aa307f631fd5f9f4a9cdf27c9a8ee226bf7e42ba17d5bdf

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