2018-01-28 05:26:57 +00:00
|
|
|
"""
|
|
|
|
IStrategy interface
|
|
|
|
This module defines the interface to apply for strategies
|
|
|
|
"""
|
2018-01-15 08:35:11 +00:00
|
|
|
from abc import ABC, abstractmethod
|
2018-07-04 07:31:35 +00:00
|
|
|
from typing import Dict
|
2018-03-17 21:44:47 +00:00
|
|
|
|
2018-01-15 08:35:11 +00:00
|
|
|
from pandas import DataFrame
|
|
|
|
|
|
|
|
|
|
|
|
class IStrategy(ABC):
|
2018-01-28 05:26:57 +00:00
|
|
|
"""
|
|
|
|
Interface for freqtrade strategies
|
|
|
|
Defines the mandatory structure must follow any custom strategies
|
|
|
|
|
|
|
|
Attributes you can use:
|
|
|
|
minimal_roi -> Dict: Minimal ROI designed for the strategy
|
|
|
|
stoploss -> float: optimal stoploss designed for the strategy
|
2018-05-31 19:59:22 +00:00
|
|
|
ticker_interval -> str: value of the ticker interval to use for the strategy
|
2018-01-28 05:26:57 +00:00
|
|
|
"""
|
2018-01-15 08:35:11 +00:00
|
|
|
|
2018-05-31 19:59:22 +00:00
|
|
|
minimal_roi: Dict
|
|
|
|
stoploss: float
|
|
|
|
ticker_interval: str
|
|
|
|
|
2018-01-15 08:35:11 +00:00
|
|
|
@abstractmethod
|
|
|
|
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
|
|
|
"""
|
|
|
|
Populate indicators that will be used in the Buy and Sell strategy
|
|
|
|
:param dataframe: Raw data from the exchange and parsed by parse_ticker_dataframe()
|
|
|
|
:return: a Dataframe with all mandatory indicators for the strategies
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
|
|
|
|
"""
|
|
|
|
Based on TA indicators, populates the buy signal for the given dataframe
|
|
|
|
:param dataframe: DataFrame
|
|
|
|
:return: DataFrame with buy column
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
|
|
|
|
"""
|
|
|
|
Based on TA indicators, populates the sell signal for the given dataframe
|
|
|
|
:param dataframe: DataFrame
|
2018-03-25 18:24:56 +00:00
|
|
|
:return: DataFrame with sell column
|
2018-01-15 08:35:11 +00:00
|
|
|
"""
|