freqtrade / freqtrade-strategies

Free trading strategies for Freqtrade bot
GNU General Public License v3.0
3.24k stars 1.1k forks source link

Fib Error Strategy #84

Closed LightDelphin closed 4 years ago

LightDelphin commented 4 years ago

For requestion a new strategy. Please use the template below.
Any strategy request that does not follow the template will be closed.

Step 1: What indicators are required?

I can’t start the bot on this strategy

Step 2: Explain the Buy Strategy

Trying to run a fibonacci strategy file.

` import numpy as np from numpy.core.records import ndarray from pandas import Series, DataFrame from math import log

class strategy002(IStrategy): """ Strategy 001 """

Minimal ROI designed for the strategy.

# This attribute will be overridden if the config file contains "minimal_roi"
minimal_roi = {
    "60":  0.01,
    "30":  0.03,
    "20":  0.04,
    "0":  0.05
}

# Optimal stoploss designed for the strategy
# This attribute will be overridden if the config file contains "stoploss"
stoploss = -0.10

# Optimal ticker interval for the strategy
ticker_interval = '5m'

# trailing stoploss
trailing_stop = False
trailing_stop_positive = 0.01
trailing_stop_positive_offset = 0.02

# run "populate_indicators" only for new candle
process_only_new_candles = False

# Experimental settings (configuration will overide these if set)
use_sell_signal = True
sell_profit_only = True
ignore_roi_if_buy_signal = False

# Optional order type mapping
order_types = {
    'buy': 'limit',
    'sell': 'limit',
    'stoploss': 'market',
    'stoploss_on_exchange': False
}

def fibonacci_retracements(df, field='close') -> DataFrame:

Общие пороги:

# 1.0, sqrt(F_n / F_{n+1}), F_n / F_{n+1}, 0.5, F_n / F_{n+2}, F_n / F_{n+3}, 0.0
thresholds = [1.0, 0.786, 0.618, 0.5, 0.382, 0.236, 0.0]

window_min, window_max = df[field].min(), df[field].max()
fib_levels = [window_min + t * (window_max - window_min) for t in thresholds]

# Данные в соответсиве с пороговыми данными
# Смортит на уровни и если всев порядке возвращает данные
data = (df[field] - window_min) / (window_max - window_min)

# Возвращаем уровни Фибоначчи
# якшо каждый индикатор перевышает значения                    
return data.apply(lambda x: max(t for t in thresholds if x >= t))
       `

error 2020-05-26 10:08:29,340 - freqtrade.freqtradebot - INFO - Starting freqtrade develop 2020-05-26 10:08:29,362 - freqtrade - ERROR - Fatal exception! Traceback (most recent call last): File "/home/1/freqtrade/freqtrade/main.py", line 36, in main return_code = args['func'](args) File "/home/1/freqtrade/freqtrade/commands/trade_commands.py", line 19, in start_trading worker = Worker(args) File "/home/1/freqtrade/freqtrade/worker.py", line 34, in init self._init(False) File "/home/1/freqtrade/freqtrade/worker.py", line 53, in _init self.freqtrade = FreqtradeBot(self._config) File "/home/1/freqtrade/freqtrade/freqtradebot.py", line 59, in init self.strategy: IStrategy = StrategyResolver.load_strategy(self.config) File "/home/1/freqtrade/freqtrade/resolvers/strategy_resolver.py", line 47, in load_strategy extra_dir=config.get('strategy_path')) File "/home/1/freqtrade/freqtrade/resolvers/strategy_resolver.py", line 165, in _load_strategy kwargs={'config': config}) File "/home/1/freqtrade/freqtrade/resolvers/iresolver.py", line 108, in _load_object object_name=object_name) File "/home/1/freqtrade/freqtrade/resolvers/iresolver.py", line 92, in _search_object obj = next(cls._get_valid_object(module_path, object_name), None) File "/home/1/freqtrade/freqtrade/resolvers/iresolver.py", line 61, in _get_valid_object spec.loader.exec_module(module) # type: ignore # importlib does not use typehints File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/1/freqtrade/user_data/strategies/strategy002.py", line 10, in <module> class strategy002(IStrategy): NameError: name 'IStrategy' is not defined

Tell me what is missing, please?

xmatthias commented 4 years ago

Seems like the imports at the top are missing .

by default, these are the following.

# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
# --------------------------------
LightDelphin commented 4 years ago

Seems like the imports at the top are missing .

by default, these are the following.

# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
# --------------------------------

Thank.

Now the following errors: 2020-05-26 11:33:19,593 - freqtrade.freqtradebot - INFO - Starting freqtrade develop 2020-05-26 11:33:19,617 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy strategy002 from '/home/freqtrade/1/user_data/strategies/strategy002.py'... 2020-05-26 11:33:19,617 - freqtrade - ERROR - Fatal exception! Traceback (most recent call last): File "/home/freqtrade/1/freqtrade/main.py", line 36, in main return_code = args['func'](args) File "/home/freqtrade/1/freqtrade/commands/trade_commands.py", line 19, in start_trading worker = Worker(args) File "/home/freqtrade/1/freqtrade/worker.py", line 34, in init self._init(False) File "/home/freqtrade/1/freqtrade/worker.py", line 53, in _init self.freqtrade = FreqtradeBot(self._config) File "/home/freqtrade/1/freqtrade/freqtradebot.py", line 59, in init self.strategy: IStrategy = StrategyResolver.load_strategy(self.config) File "/home/freqtrade/1/freqtrade/resolvers/strategy_resolver.py", line 47, in load_strategy extra_dir=config.get('strategy_path')) File "/home/freqtrade/1/freqtrade/resolvers/strategy_resolver.py", line 165, in _load_strategy kwargs={'config': config}) File "/home/freqtrade/1/freqtrade/resolvers/iresolver.py", line 113, in _load_object return module(**kwargs) TypeError: Can't instantiate abstract class strategy002 with abstract methods populate_buy_trend, populate_indicators, populate_sell_trend

xmatthias commented 4 years ago

We provide documentation based on a strategy template, which provides you with a raw scaffold (but runnable) where you can add your own strategy indicators and parameters.

Please read the documentation - and best start from the strategy template we provide.

If you're starting from an empty strategy, then the assumption is that you're able to debug such errors yourself. We are not a company providing support, but an open source project, where people donate their time for free to help other people. Such questions can be avoided by reading the documentation - and we expect that people do that. Thanks for your understanding.