Documentos de Académico
Documentos de Profesional
Documentos de Cultura
statement
# flake8: noqa: F401
# --------------------------------
# Add your lib to import here
import talib.abstract as ta
import pandas_ta as pd_ta
import technical.indicators as tec
#from technical.util import resample_to_interval, resampled_merge
class NNSTSSLltbot(IStrategy):
# Strategy interface version
INTERFACE_VERSION = 2
buy_params = {
"buy_nn": 0.37
}
sell_params = {
"sell_nn": 0.39,
"days": 4
}
# ROI table:
minimal_roi = {
"0": 0.25
}
# Stoploss:
stoploss = -0.3
# Trailing stop:
trailing_stop = True
trailing_stop_positive = 0.015
trailing_stop_positive_offset = 0.107
trailing_only_offset_is_reached = True
#Buy parameters
buy_nn = DecimalParameter(0.1, 1, decimals=2, default=0.37, space="buy")
#Sell parameters
sell_nn = DecimalParameter(0.1, 1, decimals=2, default=0.39, space="sell")
days = IntParameter(1, 5, default=4 , space="sell")
plot_config = {
# Main plot indicators
'main_plot': {
'sslUp':{'color': 'green'},
'sslDown':{'color': 'red'},
'ST':{'color': 'green'}
},
'subplots': {
# Subplots
"RSI": {
'rsi': {'color': 'blue'},
}
}
}
# Indicators
def populate_indicators(self, dataframe: DataFrame, metadata: dict) ->
DataFrame:
# RSI
dataframe['rsi'] = ta.RSI(dataframe)
# SSL
dataframe['sslDown'], dataframe['sslUp'] = tec.SSLChannels(dataframe,10)
# SuperTrend
dataframe['ST'] =
pd_ta.supertrend(dataframe['high'],dataframe['low'],dataframe['close'],lenght=7,mul
tiplier=3.2)[f'SUPERT_7_3.2']
# ANN
dataframe['Ynn'] = self.RedFun(dataframe)['Ynn']
return dataframe
a='Trade'
b='datetime'
def custom_sell(self, pair: str, trade: a, current_time: b, current_rate:
float,
current_profit: float, **kwargs):
# Sell any positions at a loss if they are held for more than 4 days
if current_profit < 0.0 and (current_time - trade.open_date_utc).days >=
self.days.value:
return 'unclog'