From 4e9e4636b123b0f112eb1ffbc4376e72e46dbf26 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sun, 17 Dec 2017 14:33:01 +0200 Subject: [PATCH] autopep fixes --- freqtrade/optimize/__init__.py | 7 ++++--- freqtrade/optimize/backtesting.py | 3 ++- freqtrade/optimize/hyperopt.py | 7 ++++--- freqtrade/rpc/telegram.py | 6 +++--- freqtrade/tests/conftest.py | 8 ++++---- freqtrade/tests/test_optimize_backtesting.py | 7 ++++--- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index dccc18093..28abe11a3 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -13,7 +13,8 @@ from freqtrade.analyze import populate_indicators, parse_ticker_dataframe logger = logging.getLogger(__name__) -def load_data(pairs: List[str], ticker_interval: int = 5, refresh_pairs: Optional[bool] = False) -> Dict[str, List]: +def load_data(pairs: List[str], ticker_interval: int = 5, + refresh_pairs: Optional[bool] = False) -> Dict[str, List]: """ Loads ticker history data for the given parameters :param ticker_interval: ticker interval in minutes @@ -61,7 +62,7 @@ def download_pairs(pairs: List[str]) -> bool: """For each pairs passed in parameters, download 1 and 5 ticker intervals""" for pair in pairs: try: - for interval in [1,5]: + for interval in [1, 5]: download_backtesting_testdata(pair=pair, interval=interval) except BaseException: logger.info('Impossible to download the pair: "{pair}", Interval: {interval} min'.format( @@ -103,7 +104,7 @@ def download_backtesting_testdata(pair: str, interval: int = 5) -> bool: logger.debug("Current Start: None") logger.debug("Current End: None") - new_data = get_ticker_history(pair = pair, tick_interval = int(interval)) + new_data = get_ticker_history(pair=pair, tick_interval=int(interval)) for row in new_data: if row not in data: data.append(row) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index dd7bf160c..c281d439e 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -140,7 +140,8 @@ def start(args): data[pair] = exchange.get_ticker_history(pair, args.ticker_interval) else: logger.info('Using local backtesting data (using whitelist in given config) ...') - data = load_data(pairs=pairs, ticker_interval=args.ticker_interval, refresh_pairs=args.refresh_pairs) + data = load_data(pairs=pairs, ticker_interval=args.ticker_interval, + refresh_pairs=args.refresh_pairs) logger.info('Using stake_currency: %s ...', config['stake_currency']) logger.info('Using stake_amount: %s ...', config['stake_amount']) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 8603f7d8c..07e988a91 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -150,7 +150,7 @@ def optimizer(params): 'total_tries': TOTAL_TRIES, 'result': result, 'results': results - } + } # logger.info('{:5d}/{}: {}'.format(_CURRENT_TRIES, TOTAL_TRIES, result)) log_results(result_data) @@ -169,7 +169,7 @@ def format_results(results: DataFrame): results.profit.mean() * 100.0, results.profit.sum(), results.duration.mean() * 5, - ) + ) def buy_strategy_generator(params): @@ -232,7 +232,8 @@ def start(args): logger.info('Using config: %s ...', args.config) config = load_config(args.config) pairs = config['exchange']['pair_whitelist'] - PROCESSED = optimize.preprocess(optimize.load_data(pairs=pairs, ticker_interval=args.ticker_interval)) + PROCESSED = optimize.preprocess(optimize.load_data( + pairs=pairs, ticker_interval=args.ticker_interval)) if args.mongodb: logger.info('Using mongodb ...') diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index a097e45f4..f6d6ce234 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -232,11 +232,11 @@ def _daily(bot: Bot, update: Update) -> None: for day in range(0, timescale): # need to query between day+1 and day-1 - nextdate = date.fromordinal(today-day+1) - prevdate = date.fromordinal(today-day-1) + nextdate = date.fromordinal(today - day + 1) + prevdate = date.fromordinal(today - day - 1) trades = Trade.query.filter(between(Trade.close_date, prevdate, nextdate)).all() curdayprofit = sum(trade.close_profit * trade.stake_amount for trade in trades) - profit_days[date.fromordinal(today-day)] = format(curdayprofit, '.8f') + profit_days[date.fromordinal(today - day)] = format(curdayprofit, '.8f') stats = [[key, str(value) + ' BTC'] for key, value in profit_days.items()] stats = tabulate(stats, headers=['Day', 'Profit'], tablefmt='simple') diff --git a/freqtrade/tests/conftest.py b/freqtrade/tests/conftest.py index c711f3953..7e7908748 100644 --- a/freqtrade/tests/conftest.py +++ b/freqtrade/tests/conftest.py @@ -128,7 +128,7 @@ def limit_sell_order(): @pytest.fixture def ticker_history(): return [ - { + { "O": 8.794e-05, "H": 8.948e-05, "L": 8.794e-05, @@ -137,7 +137,7 @@ def ticker_history(): "T": "2017-11-26T08:50:00", "BV": 0.0877869 }, - { + { "O": 8.88e-05, "H": 8.942e-05, "L": 8.88e-05, @@ -146,7 +146,7 @@ def ticker_history(): "T": "2017-11-26T08:55:00", "BV": 0.05874751 }, - { + { "O": 8.891e-05, "H": 8.893e-05, "L": 8.875e-05, @@ -155,4 +155,4 @@ def ticker_history(): "T": "2017-11-26T09:00:00", "BV": 0.7039405 } - ] \ No newline at end of file + ] diff --git a/freqtrade/tests/test_optimize_backtesting.py b/freqtrade/tests/test_optimize_backtesting.py index c43bcede5..06d86d0d6 100644 --- a/freqtrade/tests/test_optimize_backtesting.py +++ b/freqtrade/tests/test_optimize_backtesting.py @@ -30,6 +30,7 @@ def test_1min_ticker_interval(default_conf, mocker): results = backtest(default_conf, optimize.preprocess(data), 1, True) assert len(results) > 0 + def test_backtest_with_new_pair(default_conf, ticker_history, mocker): mocker.patch('freqtrade.optimize.get_ticker_history', return_value=ticker_history) mocker.patch.dict('freqtrade.main._CONF', default_conf) @@ -59,7 +60,7 @@ def test_download_pairs(default_conf, ticker_history, mocker): file2_1 = 'freqtrade/tests/testdata/BTC_CFI-1.json' file2_5 = 'freqtrade/tests/testdata/BTC_CFI-5.json' - assert download_pairs(pairs = ['BTC-MEME', 'BTC-CFI']) is True + assert download_pairs(pairs=['BTC-MEME', 'BTC-CFI']) is True assert os.path.isfile(file1_1) is True assert os.path.isfile(file1_5) is True @@ -87,7 +88,7 @@ def test_download_backtesting_testdata(default_conf, ticker_history, mocker): # Download a 1 min ticker file file1 = 'freqtrade/tests/testdata/BTC_XEL-1.json' - download_backtesting_testdata(pair = "BTC-XEL", interval = 1) + download_backtesting_testdata(pair="BTC-XEL", interval=1) assert os.path.isfile(file1) is True if os.path.isfile(file1): @@ -95,7 +96,7 @@ def test_download_backtesting_testdata(default_conf, ticker_history, mocker): # Download a 5 min ticker file file2 = 'freqtrade/tests/testdata/BTC_STORJ-5.json' - download_backtesting_testdata(pair = "BTC-STORJ", interval = 5) + download_backtesting_testdata(pair="BTC-STORJ", interval=5) assert os.path.isfile(file2) is True if os.path.isfile(file2):