Learn how to build, optimize, and combine trading strategies using the RLX framework.
Create complex tactical strategies by extending the base Strategy class. Vectorized by default.
import pandas as pd
from rlxbt import Strategy
class TrendReversal(Strategy):
def __init__(self, window=20):
self.window = window
def generate_signals(self, data):
# Fast vectorized indicators
rsi = data['rsi']
signals = pd.Series(0, index=data.index)
# Entry logic
signals.loc[rsi < 30] = 1 # Long
signals.loc[rsi > 70] = -1 # Short
return signalsCombine multiple independent strategies into a single portfolio. RLX manages cross-margin and weight distribution automatically.
engine.run_multi_strategy(
strategies=[trend_strat, reversal_strat],
weights=[0.6, 0.4], # 60% / 40% capital split
strategy_names=["Trend", "Reversal"]
)