-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add ta_features parameter to PredictTrainFeedset constructor * Add ta_features parameter to PredictTrainFeedset constructor * Add TechnicalIndicator class for calculating technical indicators * formatting * Add MACD technical indicator class * Add RSI technical indicator class * Add get_ta_indicator function for retrieving technical indicator class * Add ta_features parameter to SimEngine constructor * Formatting * Add ta_features parameter to ppss.yaml * Format * Add technical indicator features to AimodelDataFactory The code changes in `aimodel_data_factory.py` introduce the `ta_features` parameter to the `AimodelDataFactory` class. This parameter allows for the calculation of technical indicator features based on the provided feeds. The technical indicators are retrieved using the `get_ta_indicator` function, which has been added in a recent commit. * add ta * assert correct * Typo fix * Refactor TechnicalIndicator constructor parameter names for clarity * linter * linter * Formatting * Add mypy configuration for ta package * Better handling * remove unused import * Readability * formatting * Add MockTechnicalIndicator for testing purposes * Add conftest.py for technical indicators tests * test get_ta_indicator * Add unit test for MACD indicator * test RSI calculation against ta library * test TechnicalIndicator * Linter fixes * Update tests * linter fixes
- Loading branch information
Showing
18 changed files
with
353 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import Optional, Type | ||
from pdr_backend.technical_indicators.indicators.macd import MACD | ||
from pdr_backend.technical_indicators.indicators.rsi import RSI | ||
from pdr_backend.technical_indicators.technical_indicator import TechnicalIndicator | ||
|
||
indicators = { | ||
"rsi": RSI, | ||
"macd": MACD, | ||
} | ||
|
||
|
||
def get_ta_indicator(indicator: str) -> Optional[Type[TechnicalIndicator]]: | ||
""" | ||
Returns the technical indicator class based on the input indicator name. | ||
""" | ||
return indicators.get(indicator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pandas as pd | ||
import ta | ||
from pdr_backend.technical_indicators.technical_indicator import TechnicalIndicator | ||
|
||
|
||
class MACD(TechnicalIndicator): | ||
""" | ||
Moving Average Convergence Divergence (MACD) technical indicator. | ||
""" | ||
|
||
def calculate(self, *args, **kwargs) -> pd.Series: | ||
""" | ||
Calculates the MACD value based on the input data. | ||
@param: | ||
window_fast - The window size for the fast EMA calculation (default=12). | ||
window_slow - The window size for the slow EMA calculation (default=26). | ||
""" | ||
window_fast = kwargs.get("window_fast", 12) | ||
window_slow = kwargs.get("window_slow", 26) | ||
macd = ta.trend.MACD( | ||
close=self._close(), window_fast=window_fast, window_slow=window_slow | ||
) | ||
return macd.macd() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pandas as pd | ||
import ta | ||
from pdr_backend.technical_indicators.technical_indicator import TechnicalIndicator | ||
|
||
|
||
class RSI(TechnicalIndicator): | ||
""" | ||
Relative Strength Index (RSI) technical indicator. | ||
""" | ||
|
||
def calculate(self, *args, **kwargs) -> pd.Series: | ||
""" | ||
Calculates the RSI value based on the input data. | ||
@param: | ||
window - The window size for the RSI calculation (default=14). | ||
""" | ||
window = kwargs.get("window", 14) | ||
rsi = ta.momentum.RSIIndicator(close=self._close(), window=window).rsi() | ||
return rsi |
Oops, something went wrong.