turtle_quant_1.strategies.mean_reversion.slow_stoch_osc_crossover¶
turtle_quant_1.strategies.mean_reversion.slow_stoch_osc_crossover
¶
Slow Stochastic Oscillator crossover strategy implementation.
SlowStochOscCrossover
¶
Bases: BaseStrategy
A strategy that uses Slow Stochastic Oscillator %K/%D crossovers to generate buy and sell signals.
Can be intuitively interpreted as whether a stock is overbought or oversold. Refer to: https://www.investopedia.com/terms/s/stochasticoscillator.asp
Leading / Lagging: Lagging in construction. Leading in interpretation.
Lag period (in candles): (k_period - 1) / 2 + (d_period - 1) / 2 + (k_smooth - 1) / 2
Effect: Delay in recognizing that price has deviated far enough from equilibrium.
Initialize the Slow Stochastic Oscillator strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k_period
|
int
|
The number of candles to calculate %K. |
14
|
k_smooth
|
int
|
The smoothing period applied to %K to create Slow %K. |
3
|
d_period
|
int
|
The smoothing period applied to Slow %K to create Slow %D. |
3
|
Source code in src/turtle_quant_1/strategies/mean_reversion/slow_stoch_osc_crossover.py
generate_historical_scores
¶
Generate historical scores based on Slow %K/%D crossovers.
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 values between -1.0 and +1.0, indexed by the original data's index. |
Source code in src/turtle_quant_1/strategies/mean_reversion/slow_stoch_osc_crossover.py
generate_prediction_score
¶
Generate the latest prediction score.
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 being analyzed. |
required |
Returns:
| Type | Description |
|---|---|
float
|
A float between -1.0 and +1.0 representing the most recent crossover signal. |