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
|
|
|
|
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
|
|
|
|
ticker_interval -> int: value of the ticker interval to use for the strategy
|
|
|
|
"""
|
2018-01-15 08:35:11 +00:00
|
|
|
|
|
|
|
@abstractmethod
|
2018-01-30 14:03:38 +00:00
|
|
|
def populate_indicators(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
2018-01-15 08:35:11 +00:00
|
|
|
"""
|
|
|
|
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()
|
2018-01-30 16:40:08 +00:00
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
2018-01-15 08:35:11 +00:00
|
|
|
:return: a Dataframe with all mandatory indicators for the strategies
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2018-01-30 14:03:38 +00:00
|
|
|
def populate_buy_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
2018-01-15 08:35:11 +00:00
|
|
|
"""
|
|
|
|
Based on TA indicators, populates the buy signal for the given dataframe
|
|
|
|
:param dataframe: DataFrame
|
2018-01-30 16:40:08 +00:00
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
2018-01-15 08:35:11 +00:00
|
|
|
:return: DataFrame with buy column
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2018-01-30 14:03:38 +00:00
|
|
|
def populate_sell_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
2018-01-15 08:35:11 +00:00
|
|
|
"""
|
|
|
|
Based on TA indicators, populates the sell signal for the given dataframe
|
|
|
|
:param dataframe: DataFrame
|
2018-01-30 16:40:08 +00:00
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
2018-01-15 08:35:11 +00:00
|
|
|
:return: DataFrame with buy column
|
|
|
|
"""
|
2018-01-30 16:56:31 +00:00
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def did_bought(self, pair: str):
|
|
|
|
"""
|
|
|
|
we are notified that a given pair was bought
|
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def did_sold(self, pair: str):
|
|
|
|
"""
|
|
|
|
we are notified that a given pair was sold
|
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
|
|
|
"""
|
2018-01-30 20:34:26 +00:00
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def did_cancel_buy(self, pair: str):
|
|
|
|
"""
|
|
|
|
we are notified that a given buy for a pair was cancelled
|
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def did_cancel_sell(self, pair: str):
|
|
|
|
"""
|
|
|
|
we are notified that a given sell for a pair was cancelled
|
|
|
|
:param pair: the pair that was is concerned by the dataframe
|
|
|
|
"""
|