turtle_quant_1.strategies.momentum.moving_average_crossover¶
turtle_quant_1.strategies.momentum.moving_average_crossover
¶
Moving average crossover strategy implementation.
MovingAverageCrossover
¶
Bases: BaseStrategy
A strategy that uses moving averages to generate buy and sell signals.
Leading / Lagging: Lagging
Lag period (in candles): (lma_candles - 1) / 2 - (sma_candles - 1) / 2
Effect: Delay in recognizing that a new trend has begun.
Initialize the moving average crossover strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sma_candles
|
int
|
The number of candles to use for the short moving average. |
5
|
lma_candles
|
int
|
The number of candles to use for the long moving average. |
180
|
Source code in src/turtle_quant_1/strategies/momentum/moving_average_crossover.py
generate_historical_scores
¶
Generate a historical score array for a symbol based on market data.
NOTE: Assume that the data is sorted by datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with OHLCV data. |
required |
symbol
|
str
|
The symbol being analyzed. |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Score array with each value between -1.0 and +1.0, indexed by the original data's index. |
Source code in src/turtle_quant_1/strategies/momentum/moving_average_crossover.py
generate_prediction_score
¶
Generate a score for the strategy.
NOTE: Assume that the data is sorted by datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The data to use for the strategy. |
required |
symbol
|
str
|
The symbol to use for the strategy. |
required |