124 lines
3.6 KiB
Python
124 lines
3.6 KiB
Python
# pr#agma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
|
# isort: skip_file
|
|
# --- Do not remove these libs ---
|
|
from datetime import datetime
|
|
|
|
import numpy as np # noqa
|
|
import pandas as pd # noqa
|
|
from pandas import DataFrame
|
|
|
|
from freqtrade.strategy.interface import IStrategy
|
|
|
|
# --------------------------------
|
|
# Add your lib to import here
|
|
import talib.abstract as ta
|
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
|
|
|
# This class is a sample. Feel free to customize it.
|
|
class Empty(IStrategy):
|
|
|
|
# Strategy interface version - allow new iterations of the strategy interface.
|
|
# Check the documentation or the Sample strategy to get the latest version.
|
|
INTERFACE_VERSION = 2
|
|
|
|
# ROI table:
|
|
minimal_roi = {
|
|
#"0": 0.015
|
|
"0": 0.5
|
|
}
|
|
|
|
# Stoploss:
|
|
stoploss = -1
|
|
trailing_stop = True
|
|
trailing_stop_positive = 0.001
|
|
trailing_stop_positive_offset = 0.0175 #0.015
|
|
trailing_only_offset_is_reached = True
|
|
|
|
#max_open_trades = 3
|
|
|
|
# Optimal ticker interval for the strategy.
|
|
timeframe = '5m'
|
|
|
|
# Run "populate_indicators()" only for new candle.
|
|
process_only_new_candles = False
|
|
|
|
# These values can be overridden in the "ask_strategy" section in the config.
|
|
use_sell_signal = True
|
|
sell_profit_only = False
|
|
ignore_roi_if_buy_signal = False
|
|
|
|
# Number of candles the strategy requires before producing valid signals
|
|
startup_candle_count: int = 30
|
|
|
|
plot_config = {
|
|
# Main plot indicators (Moving averages, ...)
|
|
'main_plot': {
|
|
'bb_lowerband': {'color': 'white'},
|
|
'bb_upperband': {'color': 'white'},
|
|
},
|
|
'subplots': {
|
|
# Subplots - each dict defines one additional plot
|
|
"BB": {
|
|
'bb_width': {'color': 'white'},
|
|
},
|
|
"Aaron": {
|
|
'aroonup': {'color': 'blue'},
|
|
'aroondown': {'color': 'red'}
|
|
}
|
|
}
|
|
}
|
|
|
|
def informative_pairs(self):
|
|
|
|
return []
|
|
|
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
|
|
# MACD
|
|
#macd = ta.MACD(dataframe)
|
|
#dataframe['macd'] = macd['macd']
|
|
#dataframe['macdsignal'] = macd['macdsignal']
|
|
#dataframe['macdhist'] = macd['macdhist']
|
|
|
|
# RSI
|
|
#dataframe['rsi'] = ta.RSI(dataframe)
|
|
|
|
# Bollinger Bands
|
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
|
dataframe['bb_lowerband'] = bollinger['lower']
|
|
dataframe['bb_middleband'] = bollinger['mid']
|
|
dataframe['bb_upperband'] = bollinger['upper']
|
|
dataframe["bb_percent"] = (
|
|
(dataframe["close"] - dataframe["bb_lowerband"]) /
|
|
(dataframe["bb_upperband"] - dataframe["bb_lowerband"])
|
|
)
|
|
dataframe["bb_width"] = (
|
|
(dataframe["bb_upperband"] - dataframe["bb_lowerband"]) / dataframe["bb_middleband"]
|
|
)
|
|
|
|
return dataframe
|
|
|
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
|
|
dataframe.loc[
|
|
(
|
|
# (
|
|
# (dataframe['close'] < dataframe['bb_lowerband'])
|
|
# & (dataframe['bb_width'] >= 0.065)
|
|
# #& (dataframe['rsi'] < 45)
|
|
# & (dataframe['volume'] > 0)
|
|
# )
|
|
),
|
|
'buy'] = 1
|
|
return dataframe
|
|
|
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
|
|
dataframe.loc[
|
|
(
|
|
|
|
),
|
|
'sell'] = 1
|
|
return dataframe
|
|
|