Update strategy imports

This commit is contained in:
Matthias
2022-05-31 06:45:10 +02:00
parent 7955ac2eaf
commit 393b94a249
43 changed files with 68 additions and 82 deletions
+5 -4
View File
@@ -1,6 +1,7 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
@@ -12,13 +13,13 @@ class BreakEven(IStrategy):
I can "/stopbuy" and wait for the positions to get closed by the bot rules, which is
waiting for some profit, etc -- this usually takes too long...
What I would prefer is to close everything that is over 0% profit to avoid the losses.
Here's a simple strategy with empty buy/sell signals and "minimal_roi = { 0 : 0 }" that
sells everything already at profit and wait until the positions at loss will come to break
even point (or the small profit you provide in ROI table).
You may restart the bot with the new strategy as a command-line parameter.
Another way would be to specify the original strategy in the config file, then change to
@@ -29,7 +30,7 @@ class BreakEven(IStrategy):
# This attribute will be overridden if the config file contains "minimal_roi"
minimal_roi = {
"0": 0.01, # at least 1% at first
"10": 0 # after 10min, everything goes
"10": 0 # after 10min, everything goes
}
# This is more radical version that sells everything above the profit level
+1 -2
View File
@@ -40,8 +40,7 @@
# * 7/10: 117 trades. 74/41/2 Wins/Draws/Losses. Avg profit 1.91%. Median profit 1.50%. Total profit 0.07370921 BTC ( 73.71%). Avg duration 9:26:00 min. Objective: -0.07371
# --- Do not remove these libs ---
from freqtrade.strategy.hyper import CategoricalParameter, DecimalParameter, IntParameter
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import CategoricalParameter, DecimalParameter, IntParameter, IStrategy
from pandas import DataFrame
# --------------------------------
+9 -8
View File
@@ -11,21 +11,22 @@
# --- Do not remove these libs ---
import logging
from functools import reduce
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
# --------------------------------
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy as np
# Add your lib to import here
# import talib.abstract as ta
import pandas as pd
from freqtrade.strategy import IStrategy
from numpy.lib import math
from pandas import DataFrame
# import talib.abstract as ta
from ta import add_all_ta_features
from ta.utils import dropna
import freqtrade.vendor.qtpylib.indicators as qtpylib
from functools import reduce
import numpy as np
# --------------------------------
class GodStra(IStrategy):
+1 -2
View File
@@ -12,8 +12,7 @@
# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces roi buy --strategy Heracles
# ######################################################################
# --- Do not remove these libs ---
from freqtrade.strategy.hyper import IntParameter, DecimalParameter
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IntParameter, DecimalParameter, IStrategy
from pandas import DataFrame
# --------------------------------
# Add your lib to import here
+1 -2
View File
@@ -3,8 +3,7 @@
# github: https://github.com/mablue/
# --- Do not remove these libs ---
from freqtrade.strategy.hyper import IntParameter
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IntParameter, IStrategy
from pandas import DataFrame
# --------------------------------
@@ -1,6 +1,6 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -88,7 +88,7 @@ class Strategy001_custom_sell(IStrategy):
dataframe['ha_close'] = heikinashi['close']
dataframe['rsi'] = ta.RSI(dataframe, 14)
return dataframe
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
@@ -129,13 +129,13 @@ class Strategy001_custom_sell(IStrategy):
"""
# get dataframe
dataframe, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe)
# get the current candle
current_candle = dataframe.iloc[-1].squeeze()
# if RSI greater than 70 and profit is positive, then sell
if (current_candle['rsi'] > 70) and (current_profit > 0):
return "rsi_profit_sell"
# else, hold
return None
return None
+1 -1
View File
@@ -1,6 +1,6 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
+1 -2
View File
@@ -14,8 +14,7 @@ Supertrend strategy:
import logging
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy.hyper import IntParameter
from freqtrade.strategy import IStrategy, IntParameter
from pandas import DataFrame
import talib.abstract as ta
import numpy as np
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
@@ -1,6 +1,6 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
@@ -1,4 +1,4 @@
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame, Series, DatetimeIndex, merge
@@ -1,6 +1,6 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,7 +1,7 @@
# --- Do not remove these libs ---
import freqtrade.vendor.qtpylib.indicators as qtpylib
import talib.abstract as ta
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from freqtrade.strategy import IntParameter
from pandas import DataFrame
@@ -3,7 +3,7 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy as np
# --------------------------------
import talib.abstract as ta
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
@@ -1,4 +1,4 @@
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -4,7 +4,7 @@
# The purpose is to test Freqtrade backtest provides like results to a known industry platform.
#
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
+1 -1
View File
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,6 +1,6 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
import talib.abstract as ta
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame, merge, DatetimeIndex
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
+1 -1
View File
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
+1 -1
View File
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -1,5 +1,5 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
@@ -2,7 +2,7 @@ import talib.abstract as ta
from pandas import DataFrame
import scipy.signal
import freqtrade.vendor.qtpylib.indicators as qtpylib
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
class TDSequentialStrategy(IStrategy):
@@ -1,7 +1,7 @@
from pandas import DataFrame
from technical.indicators import cmf
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
class TechnicalExampleStrategy(IStrategy):
@@ -5,7 +5,7 @@ import numpy as np # noqa
import pandas as pd # noqa
from pandas import DataFrame
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
# --------------------------------
# Add your lib to import here
@@ -5,7 +5,7 @@ import numpy as np # noqa
import pandas as pd # noqa
from pandas import DataFrame
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
# --------------------------------
# Add your lib to import here
@@ -1,7 +1,6 @@
import logging
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy.hyper import IntParameter
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import numpy as np
@@ -5,7 +5,7 @@ Supertrend strategy:
Sells if the 3 'sell' indicators are 'down'
* Author: @juankysoriano (Juan Carlos Soriano)
* github: https://github.com/juankysoriano/
*** NOTE: This Supertrend strategy is just one of many possible strategies using `Supertrend` as indicator. It should on any case used at your own risk.
*** NOTE: This Supertrend strategy is just one of many possible strategies using `Supertrend` as indicator. It should on any case used at your own risk.
It comes with at least a couple of caveats:
1. The implementation for the `supertrend` indicator is based on the following discussion: https://github.com/freqtrade/freqtrade-strategies/issues/30 . Concretelly https://github.com/freqtrade/freqtrade-strategies/issues/30#issuecomment-853042401
2. The implementation for `supertrend` on this strategy is not validated; meaning this that is not proven to match the results by the paper where it was originally introduced or any other trusted academic resources
@@ -13,8 +13,7 @@ Supertrend strategy:
import logging
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy.hyper import IntParameter
from freqtrade.strategy import IStrategy, IntParameter
from pandas import DataFrame
import talib.abstract as ta
import numpy as np
@@ -20,10 +20,9 @@ from functools import reduce
import freqtrade.vendor.qtpylib.indicators as qtpylib
import talib.abstract as ta
import random
from freqtrade.strategy.hyper import CategoricalParameter, DecimalParameter, IntParameter
from freqtrade.strategy import CategoricalParameter, IStrategy
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
# ########################## SETTINGS ##############################
@@ -4,10 +4,10 @@
# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces buy roi trailing sell --strategy GodStraNew
# --- Do not remove these libs ---
from freqtrade import data
from freqtrade.strategy.hyper import CategoricalParameter, DecimalParameter
from freqtrade.strategy import CategoricalParameter, DecimalParameter
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
+2 -2
View File
@@ -6,10 +6,10 @@
# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces buy sell roi --strategy Zeus
# --- Do not remove these libs ---
import logging
from freqtrade.strategy.hyper import CategoricalParameter, DecimalParameter
from freqtrade.strategy import CategoricalParameter, DecimalParameter
from numpy.lib import math
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IStrategy
from pandas import DataFrame
# --------------------------------
+1 -2
View File
@@ -4,8 +4,7 @@
# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces all --strategy mabStra --config config.json -e 100
# --- Do not remove these libs ---
from freqtrade.strategy.hyper import IntParameter, DecimalParameter
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import IntParameter, DecimalParameter, IStrategy
from pandas import DataFrame
# --------------------------------
+6 -14
View File
@@ -1,22 +1,14 @@
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy as np
import talib.abstract as ta
from freqtrade.strategy import IStrategy, informative
DecimalParameter, IntParameter, BooleanParameter, CategoricalParameter, stoploss_from_open)
from freqtrade.strategy import (IStrategy, informative)
from pandas import DataFrame, Series
from typing import Dict, List, Optional, Tuple
from functools import reduce
from freqtrade.persistence import Trade
from datetime import datetime, timedelta, timezone
from freqtrade.exchange import timeframe_to_prev_date
from freqtrade_strategies.custom_indicators import zema, tv_hma, pmax
import talib.abstract as ta
import math
import pandas_ta as pta
# from finta import TA as fta
import logging
from logging import FATAL
import time
logger = logging.getLogger(__name__)
@@ -54,10 +46,10 @@ class multi_tf (IStrategy):
process_only_new_candles = True
startup_candle_count = 100
# This method is not required.
# This method is not required.
# def informative_pairs(self): ...
# Define informative upper timeframe for each pair. Decorators can be stacked on same
# Define informative upper timeframe for each pair. Decorators can be stacked on same
# method. Available in populate_indicators as 'rsi_30m' and 'rsi_1h'.
@informative('30m')
@informative('1h')
@@ -66,8 +58,8 @@ class multi_tf (IStrategy):
return dataframe
# Define BTC/STAKE informative pair. Available in populate_indicators and other methods as
# 'btc_rsi_1h'. Current stake currency should be specified as {stake} format variable
# instead of hard-coding actual stake currency. Available in populate_indicators and other
# 'btc_rsi_1h'. Current stake currency should be specified as {stake} format variable
# instead of hard-coding actual stake currency. Available in populate_indicators and other
# methods as 'btc_usdt_rsi_1h' (when stake currency is USDT).
@informative('1h', 'BTC/{stake}')
def populate_indicators_btc_1h(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
@@ -103,7 +95,7 @@ class multi_tf (IStrategy):
# Informative pairs are available in this method.
dataframe['rsi_less'] = dataframe['rsi'] < dataframe['rsi_1h']
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
stake = self.config['stake_currency']
dataframe.loc[