Trading Strategy API Reference¶
financelib.trading.strategy.CompositeStrategy(strategies: List[tuple])
¶
Bases: BaseStrategy
Combine multiple strategies with weighted voting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategies
|
List[tuple]
|
List of (strategy, weight) tuples. |
required |
Example
composite = CompositeStrategy([ ... (MomentumStrategy(), 0.5), ... (MeanReversionStrategy(), 0.3), ... (BreakoutStrategy(), 0.2), ... ]) signal = composite.generate_signal(df)
Source code in financelib/trading/strategy.py
financelib.trading.strategy.MomentumStrategy(short_period: int = 10, long_period: int = 50, rsi_period: int = 14)
¶
Bases: BaseStrategy
Momentum-based trading strategy using SMA crossover and RSI.
Buys when short SMA crosses above long SMA and RSI is not overbought. Sells on the reverse crossover or RSI overbought.
Source code in financelib/trading/strategy.py
financelib.trading.strategy.MeanReversionStrategy(bb_period: int = 20, bb_std: int = 2, rsi_period: int = 14)
¶
Bases: BaseStrategy
Mean reversion strategy using Bollinger Bands and RSI.
Buys when price drops below lower Bollinger Band with RSI oversold. Sells when price rises above upper Bollinger Band with RSI overbought.
Source code in financelib/trading/strategy.py
financelib.trading.strategy.BreakoutStrategy(lookback: int = 20)
¶
Bases: BaseStrategy
Breakout strategy based on N-period high/low channels.
Buys when price breaks above N-period high. Sells when price breaks below N-period low.