Timeframe
1d
Direction
Long & Short
Stoploss
-7.0%
Trailing Stop
No
ROI
N/A
Interface Version
3
Startup Candles
400
Indicators
1
freqtrade/freqtrade-strategies
import numpy as np
import pandas as pd
from freqtrade.strategy import IStrategy
from pandas import DataFrame
class SimpleXGBoostStrategy(IStrategy):
INTERFACE_VERSION = 3
timeframe = "1d"
can_short = True
max_open_trades = 1
stoploss = -0.07
startup_candle_count = 400
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
return dataframe
def feature_engineering_expand_basic(self, dataframe, **kwargs):
c = dataframe["close"]
h = dataframe["high"]
l = dataframe["low"]
v = dataframe["volume"]
dr = c.pct_change()
for n in [5, 10, 20, 30, 60, 120]:
dataframe[f"r_{n}"] = c.pct_change(n)
dataframe[f"z_{n}"] = (c - c.rolling(n).mean()) / (c.rolling(n).std() + 1e-10)
dataframe[f"v_{n}"] = dr.rolling(n).std()
for n in [6, 14, 30]:
g = dr.clip(0).rolling(n).mean()
loss = (-dr).clip(0).rolling(n).mean()
dataframe[f"rsi_{n}"] = 100 - 100 / (1 + g / (loss + 1e-10))
e12 = c.ewm(span=12).mean()
e26 = c.ewm(span=26).mean()
dataframe["macd"] = e12 - e26
dataframe["m100"] = (c - c.rolling(100).mean()) / (c.rolling(100).std() + 1e-10)
return dataframe
def feature_engineering_standard(self, dataframe, **kwargs):
return dataframe
def set_freqai_targets(self, dataframe, **kwargs):
dataframe["&-target"] = (dataframe["close"].shift(-5) > dataframe["close"]).astype(int)
return dataframe
def populate_entry_trend(self, dataframe, metadata):
if "do_predict" not in dataframe.columns:
return dataframe
dataframe.loc[(dataframe["do_predict"] == 1) & (dataframe["prediction"] > 0.3), "enter_long"] = 1
dataframe.loc[(dataframe["do_predict"] == 1) & (dataframe["prediction"] < -0.3), "enter_short"] = 1
return dataframe
def populate_exit_trend(self, dataframe, metadata):
if "do_predict" not in dataframe.columns:
return dataframe
dataframe.loc[(dataframe["do_predict"] == 1) & (dataframe["prediction"].abs() <= 0.3), "exit_long"] = 1
dataframe.loc[(dataframe["do_predict"] == 1) & (dataframe["prediction"].abs() <= 0.3), "exit_short"] = 1
return dataframe