From 37f813943228d557aae04481a12d41a593d928b3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Nov 2019 14:47:44 +0100 Subject: [PATCH] Small stylistic fixes --- freqtrade/templates/base_hyperopt.py.j2 | 10 +++++++--- freqtrade/templates/base_strategy.py.j2 | 20 ++++++++++---------- tests/strategy/test_strategy.py | 2 +- tests/test_utils.py | 2 ++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/freqtrade/templates/base_hyperopt.py.j2 b/freqtrade/templates/base_hyperopt.py.j2 index ad30cfe55..75aedbf86 100644 --- a/freqtrade/templates/base_hyperopt.py.j2 +++ b/freqtrade/templates/base_hyperopt.py.j2 @@ -3,14 +3,18 @@ from functools import reduce from typing import Any, Callable, Dict, List -import numpy as np # noqa -import talib.abstract as ta from pandas import DataFrame +import pandas as pd # noqa +import numpy as np # noqa from skopt.space import Categorical, Dimension, Integer, Real # noqa -import freqtrade.vendor.qtpylib.indicators as qtpylib from freqtrade.optimize.hyperopt_interface import IHyperOpt +# -------------------------------- +# Add your lib to import here +import talib.abstract as ta +import freqtrade.vendor.qtpylib.indicators as qtpylib + class {{ hyperopt }}(IHyperOpt): """ diff --git a/freqtrade/templates/base_strategy.py.j2 b/freqtrade/templates/base_strategy.py.j2 index 312aa0f27..46c118383 100644 --- a/freqtrade/templates/base_strategy.py.j2 +++ b/freqtrade/templates/base_strategy.py.j2 @@ -2,18 +2,18 @@ # --- Do not remove these libs --- from freqtrade.strategy.interface import IStrategy from pandas import DataFrame -import pandas as pd +import pandas as pd # noqa +import numpy as np # noqa # -------------------------------- # Add your lib to import here import talib.abstract as ta import freqtrade.vendor.qtpylib.indicators as qtpylib -import numpy as np # noqa class {{ strategy }}(IStrategy): """ - This is a strategy template to get you started.. + This is a strategy template to get you started. More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md You can: @@ -107,16 +107,15 @@ class {{ strategy }}(IStrategy): # RSI dataframe['rsi'] = ta.RSI(dataframe) - """ # ADX dataframe['adx'] = ta.ADX(dataframe) - + """ # Awesome oscillator dataframe['ao'] = qtpylib.awesome_oscillator(dataframe) # Commodity Channel Index: values Oversold:<-100, Overbought:>100 dataframe['cci'] = ta.CCI(dataframe) - + """ # MACD macd = ta.MACD(dataframe) dataframe['macd'] = macd['macd'] @@ -126,6 +125,7 @@ class {{ strategy }}(IStrategy): # MFI dataframe['mfi'] = ta.MFI(dataframe) + """ # Minus Directional Indicator / Movement dataframe['minus_dm'] = ta.MINUS_DM(dataframe) dataframe['minus_di'] = ta.MINUS_DI(dataframe) @@ -149,12 +149,13 @@ class {{ strategy }}(IStrategy): stoch = ta.STOCH(dataframe) dataframe['slowd'] = stoch['slowd'] dataframe['slowk'] = stoch['slowk'] - + """ # Stoch fast stoch_fast = ta.STOCHF(dataframe) dataframe['fastd'] = stoch_fast['fastd'] dataframe['fastk'] = stoch_fast['fastk'] + """ # Stoch RSI stoch_rsi = ta.STOCHRSI(dataframe) dataframe['fastd_rsi'] = stoch_rsi['fastd'] @@ -178,12 +179,11 @@ class {{ strategy }}(IStrategy): dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50) dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100) - # SAR Parabol - dataframe['sar'] = ta.SAR(dataframe) - # SMA - Simple Moving Average dataframe['sma'] = ta.SMA(dataframe, timeperiod=40) """ + # SAR Parabol + dataframe['sar'] = ta.SAR(dataframe) # TEMA - Triple Exponential Moving Average dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9) diff --git a/tests/strategy/test_strategy.py b/tests/strategy/test_strategy.py index 2b84bc6ee..963d36c76 100644 --- a/tests/strategy/test_strategy.py +++ b/tests/strategy/test_strategy.py @@ -56,7 +56,7 @@ def test_load_strategy_base64(result, caplog, default_conf): def test_load_strategy_invalid_directory(result, caplog, default_conf): - default_conf['strategy'] = 'SampleStrategy' + default_conf['strategy'] = 'DefaultStrategy' resolver = StrategyResolver(default_conf) extra_dir = Path.cwd() / 'some/path' resolver._load_strategy('DefaultStrategy', config=default_conf, extra_dir=extra_dir) diff --git a/tests/test_utils.py b/tests/test_utils.py index c64050f38..ce93c328d 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -457,6 +457,8 @@ def test_create_datadir(caplog, mocker): def test_start_new_strategy(mocker, caplog): wt_mock = mocker.patch.object(Path, "write_text", MagicMock()) + mocker.patch.object(Path, "exists", MagicMock(return_value=False)) + args = [ "new-strategy", "--strategy",