257 lines
4.7 KiB
Python
257 lines
4.7 KiB
Python
"""
|
|
RaptorBT - High-performance Rust backtesting engine.
|
|
|
|
Provides Python bindings for a Rust-based backtesting engine built for
|
|
production quantitative trading:
|
|
- Sub-millisecond execution on thousands of bars
|
|
- Disk footprint: <10MB, startup latency: <10ms
|
|
- 100% deterministic execution (no JIT cache)
|
|
- Native parallelism via Rayon + explicit SIMD
|
|
- Full tick-level simulation (no bar resampling required)
|
|
- 80+ technical indicators from ferro-ta (P0 batch: PPO, APO, ADOSC,
|
|
OBV, CMO, ARONOSC, BOP, ULTOSC, and more)
|
|
"""
|
|
|
|
from raptorbt._raptorbt import (
|
|
# Config classes
|
|
PyBacktestConfig,
|
|
PyInstrumentConfig,
|
|
PyStopConfig,
|
|
PyTargetConfig,
|
|
# Result classes
|
|
PyBacktestResult,
|
|
PyBacktestMetrics,
|
|
PyTrade,
|
|
# Backtest functions
|
|
run_single_backtest,
|
|
run_basket_backtest,
|
|
run_options_backtest,
|
|
run_pairs_backtest,
|
|
run_multi_backtest,
|
|
run_spread_backtest,
|
|
run_tick_backtest,
|
|
# Batch backtest
|
|
PyBatchSpreadItem,
|
|
batch_spread_backtest,
|
|
# Monte Carlo simulation
|
|
simulate_portfolio_mc,
|
|
# Tick signal functions
|
|
compute_tick_entry_signals,
|
|
compute_tick_exit_signals,
|
|
# Tick feature functions
|
|
tick_spread_pct,
|
|
buy_sell_imbalance_delta,
|
|
return_window,
|
|
realized_vol_rolling,
|
|
oi_position_pct,
|
|
tick_velocity,
|
|
# Indicator functions
|
|
sma,
|
|
ema,
|
|
rsi,
|
|
macd,
|
|
stochastic,
|
|
atr,
|
|
bollinger_bands,
|
|
adx,
|
|
vwap,
|
|
supertrend,
|
|
rolling_min,
|
|
rolling_max,
|
|
# ferro-ta indicator functions
|
|
cci,
|
|
willr,
|
|
sar,
|
|
plus_di,
|
|
minus_di,
|
|
adx_all,
|
|
adxr,
|
|
roc,
|
|
mfi,
|
|
wma,
|
|
dema,
|
|
tema,
|
|
kama,
|
|
stochrsi,
|
|
aroon,
|
|
trix,
|
|
natr,
|
|
trange,
|
|
stddev,
|
|
var,
|
|
linearreg,
|
|
linearreg_slope,
|
|
linearreg_intercept,
|
|
linearreg_angle,
|
|
tsf,
|
|
beta,
|
|
correl,
|
|
ad,
|
|
adosc,
|
|
obv,
|
|
mom,
|
|
ppo,
|
|
cmo,
|
|
aroonosc,
|
|
bop,
|
|
ultosc,
|
|
typprice,
|
|
medprice,
|
|
avgprice,
|
|
wclprice,
|
|
midpoint,
|
|
midprice,
|
|
t3,
|
|
trima,
|
|
apo,
|
|
# P0 batch
|
|
vwma,
|
|
donchian,
|
|
choppiness_index,
|
|
hull_ma,
|
|
chandelier_exit,
|
|
ichimoku,
|
|
pivot_points,
|
|
# Hilbert Transform (cycle)
|
|
ht_trendline,
|
|
ht_dcperiod,
|
|
ht_dcphase,
|
|
ht_phasor,
|
|
ht_sine,
|
|
ht_trendmode,
|
|
# Market regime detection
|
|
regime_adx,
|
|
regime_combined,
|
|
detect_breaks_cusum,
|
|
rolling_variance_break,
|
|
# Portfolio / cross-series tools
|
|
rolling_beta,
|
|
drawdown_series,
|
|
zscore_series,
|
|
relative_strength,
|
|
spread,
|
|
ratio,
|
|
)
|
|
|
|
__version__ = "0.4.1"
|
|
|
|
__all__ = [
|
|
# Config classes
|
|
"PyBacktestConfig",
|
|
"PyInstrumentConfig",
|
|
"PyStopConfig",
|
|
"PyTargetConfig",
|
|
# Result classes
|
|
"PyBacktestResult",
|
|
"PyBacktestMetrics",
|
|
"PyTrade",
|
|
# Backtest functions
|
|
"run_single_backtest",
|
|
"run_basket_backtest",
|
|
"run_options_backtest",
|
|
"run_pairs_backtest",
|
|
"run_multi_backtest",
|
|
"run_spread_backtest",
|
|
"run_tick_backtest",
|
|
# Batch backtest
|
|
"PyBatchSpreadItem",
|
|
"batch_spread_backtest",
|
|
# Monte Carlo simulation
|
|
"simulate_portfolio_mc",
|
|
# Tick signal functions
|
|
"compute_tick_entry_signals",
|
|
"compute_tick_exit_signals",
|
|
# Tick feature functions
|
|
"tick_spread_pct",
|
|
"buy_sell_imbalance_delta",
|
|
"return_window",
|
|
"realized_vol_rolling",
|
|
"oi_position_pct",
|
|
"tick_velocity",
|
|
# Indicator functions
|
|
"sma",
|
|
"ema",
|
|
"rsi",
|
|
"macd",
|
|
"stochastic",
|
|
"atr",
|
|
"bollinger_bands",
|
|
"adx",
|
|
"vwap",
|
|
"supertrend",
|
|
"rolling_min",
|
|
"rolling_max",
|
|
# ferro-ta indicator functions
|
|
"cci",
|
|
"willr",
|
|
"sar",
|
|
"plus_di",
|
|
"minus_di",
|
|
"adx_all",
|
|
"adxr",
|
|
"roc",
|
|
"mfi",
|
|
"wma",
|
|
"dema",
|
|
"tema",
|
|
"kama",
|
|
"stochrsi",
|
|
"aroon",
|
|
"trix",
|
|
"natr",
|
|
"trange",
|
|
"stddev",
|
|
"var",
|
|
"linearreg",
|
|
"linearreg_slope",
|
|
"linearreg_intercept",
|
|
"linearreg_angle",
|
|
"tsf",
|
|
"beta",
|
|
"correl",
|
|
"ad",
|
|
"adosc",
|
|
"obv",
|
|
"mom",
|
|
"ppo",
|
|
"cmo",
|
|
"aroonosc",
|
|
"bop",
|
|
"ultosc",
|
|
"typprice",
|
|
"medprice",
|
|
"avgprice",
|
|
"wclprice",
|
|
"midpoint",
|
|
"midprice",
|
|
"t3",
|
|
"trima",
|
|
"apo",
|
|
# P0 batch
|
|
"vwma",
|
|
"donchian",
|
|
"choppiness_index",
|
|
"hull_ma",
|
|
"chandelier_exit",
|
|
"ichimoku",
|
|
"pivot_points",
|
|
# Hilbert Transform (cycle)
|
|
"ht_trendline",
|
|
"ht_dcperiod",
|
|
"ht_dcphase",
|
|
"ht_phasor",
|
|
"ht_sine",
|
|
"ht_trendmode",
|
|
# Market regime detection
|
|
"regime_adx",
|
|
"regime_combined",
|
|
"detect_breaks_cusum",
|
|
"rolling_variance_break",
|
|
# Portfolio / cross-series tools
|
|
"rolling_beta",
|
|
"drawdown_series",
|
|
"zscore_series",
|
|
"relative_strength",
|
|
"spread",
|
|
"ratio",
|
|
] |