turtle_quant_1.strategies.mean_reversion.mfi_divergence¶
turtle_quant_1.strategies.mean_reversion.mfi_divergence
¶
Money Flow Index (MFI) Divergence strategy implementation.
MfiDivergence
¶
Bases: BaseStrategy
Initialize the MFI Divergence strategy.
Leading / Lagging: Lagging in construction. Leading in interpretation.
Lag period (in candles): (mfi_period - 1) / 2
Effect: Delay in recognizing that price has deviated far enough from equilibrium.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mfi_period
|
int
|
Number of candles for MFI calculation. |
14
|
local_extrema_window
|
int
|
Window for local maxima/minima detection. |
5
|
Source code in src/turtle_quant_1/strategies/mean_reversion/mfi_divergence.py
generate_historical_scores
¶
Generate historical MFI divergence scores.
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 |
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/mean_reversion/mfi_divergence.py
generate_prediction_score
¶
Generate the prediction score for the latest candle.
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 |
Returns:
| Type | Description |
|---|---|
float
|
Score array with each value between -1.0 and +1.0, indexed by datetime |