API Reference
Package Modules
import vibetrading # vibe decorator
import vibetrading.strategy # generate, validate, analyze strategies
import vibetrading.backtest # backtest engine (BacktestEngine, run())
import vibetrading.tools # data download & CSV loadingStrategy API (vibetrading.strategy)
generate(prompt, model, ...)
Generate strategy code from natural language
validate(code)
Static analysis — catches errors before execution
analyze(results, ...)
LLM evaluates backtest results (score + feedback)
StrategyGenerator
Full generation + validation pipeline (class)
BacktestAnalyzer
LLM-powered backtest analysis (class)
BacktestAnalysisResult
Structured analysis result dataclass
StrategyValidationResult
Validation result dataclass
build_generation_prompt()
Build message list for chat completion
STRATEGY_SYSTEM_PROMPT
Complete system prompt for LLM generation
VIBETRADING_API_REFERENCE
API documentation string for prompts
STRATEGY_CONSTRAINTS
Code generation rules for prompts
Backtest API (vibetrading.backtest)
run(code, data, interval, ...)
Quick backtest — returns results dict
BacktestEngine
Full engine with custom configuration (class)
Tools API (vibetrading.tools)
download_data(assets, ...)
Download OHLCV data via CCXT
load_csv(path)
Load local CSV data
The Sandbox Interface
All trading operations inside strategy code go through a unified interface. Whether backtesting or live trading, the API is identical:
Account
get_spot_summary(), get_perp_summary(), get_perp_position(asset)
Trading
buy(asset, qty, price), sell(asset, qty, price)
Futures
long(asset, qty, price), short(asset, qty, price), reduce_position(asset, qty)
Leverage
set_leverage(asset, leverage)
Price
get_perp_price(asset), get_spot_price(asset)
OHLCV
get_spot_ohlcv(asset, interval, limit), get_futures_ohlcv(asset, interval, limit)
Funding
get_funding_rate(asset), get_funding_rate_history(asset, limit)
OI
get_open_interest(asset), get_open_interest_history(asset, limit)
Orders
get_perp_open_orders(), get_spot_open_orders(), cancel_perp_orders(asset, ids)
Time
get_current_time()
These functions are injected at runtime by the backtest engine or live runner. In strategy code, import them with
from vibetrading import vibe, get_perp_price, long, ....
Architecture
Project Structure
Last updated
