From de68209f3bf8b3b1f0ad0836ec8c0205e987d672 Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Mon, 1 Jan 2018 20:32:58 +0200 Subject: [PATCH] Revert "Make get_signals async. This should speed up create_trade calls by at least 10x. (#223)" (#275) This reverts commit 67686583007e0a8260d84f525e3a76eef665dcfd. See details in #PR266 --- freqtrade/analyze.py | 3 --- freqtrade/exchange/__init__.py | 4 +--- freqtrade/main.py | 15 ++------------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/freqtrade/analyze.py b/freqtrade/analyze.py index 887fc0282..d586077db 100644 --- a/freqtrade/analyze.py +++ b/freqtrade/analyze.py @@ -144,9 +144,6 @@ def get_signal(pair: str, signal: SignalType) -> bool: except ValueError as ex: logger.warning('Unable to analyze ticker for pair %s: %s', pair, str(ex)) return False - except Exception: - logger.exception('Unexpected error when analyzing ticker for pair %s.', pair) - return False if dataframe.empty: return False diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index 8e87cfc8b..7b5c0c753 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -3,7 +3,6 @@ import enum import logging from random import randint -from threading import RLock from typing import List, Dict, Any, Optional import arrow @@ -15,7 +14,6 @@ from freqtrade.exchange.bittrex import Bittrex from freqtrade.exchange.interface import Exchange logger = logging.getLogger(__name__) -lock = RLock() # Current selected exchange _API: Exchange = None @@ -140,7 +138,7 @@ def get_ticker(pair: str) -> dict: return _API.get_ticker(pair) -@cached(TTLCache(maxsize=100, ttl=30), lock=lock) +@cached(TTLCache(maxsize=100, ttl=30)) def get_ticker_history(pair: str, tick_interval: Optional[int] = 5) -> List[Dict]: return _API.get_ticker_history(pair, tick_interval) diff --git a/freqtrade/main.py b/freqtrade/main.py index afbb84ec4..36dc97aac 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -1,12 +1,10 @@ #!/usr/bin/env python3 -import asyncio import copy import json import logging import sys import time import traceback -from concurrent.futures import ThreadPoolExecutor from datetime import datetime from typing import Dict, Optional, List @@ -243,17 +241,8 @@ def create_trade(stake_amount: float) -> bool: raise DependencyException('No pair in whitelist') # Pick pair based on StochRSI buy signals - with ThreadPoolExecutor() as pool: - awaitable_signals = [ - asyncio.wrap_future(pool.submit(get_signal, pair, SignalType.BUY)) - for pair in whitelist - ] - - loop = asyncio.get_event_loop() - signals = loop.run_until_complete(asyncio.gather(*awaitable_signals)) - - for idx, _pair in enumerate(whitelist): - if signals[idx]: + for _pair in whitelist: + if get_signal(_pair, SignalType.BUY): pair = _pair break else: