Revert "Make get_signals async. This should speed up create_trade calls by at least 10x. (#223)" (#275)

This reverts commit 6768658300.
See details in #PR266
This commit is contained in:
Samuel Husso 2018-01-01 20:32:58 +02:00 committed by Michael Egger
parent 59546b623e
commit de68209f3b
3 changed files with 3 additions and 19 deletions

View File

@ -144,9 +144,6 @@ def get_signal(pair: str, signal: SignalType) -> bool:
except ValueError as ex: except ValueError as ex:
logger.warning('Unable to analyze ticker for pair %s: %s', pair, str(ex)) logger.warning('Unable to analyze ticker for pair %s: %s', pair, str(ex))
return False return False
except Exception:
logger.exception('Unexpected error when analyzing ticker for pair %s.', pair)
return False
if dataframe.empty: if dataframe.empty:
return False return False

View File

@ -3,7 +3,6 @@
import enum import enum
import logging import logging
from random import randint from random import randint
from threading import RLock
from typing import List, Dict, Any, Optional from typing import List, Dict, Any, Optional
import arrow import arrow
@ -15,7 +14,6 @@ from freqtrade.exchange.bittrex import Bittrex
from freqtrade.exchange.interface import Exchange from freqtrade.exchange.interface import Exchange
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
lock = RLock()
# Current selected exchange # Current selected exchange
_API: Exchange = None _API: Exchange = None
@ -140,7 +138,7 @@ def get_ticker(pair: str) -> dict:
return _API.get_ticker(pair) 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]: def get_ticker_history(pair: str, tick_interval: Optional[int] = 5) -> List[Dict]:
return _API.get_ticker_history(pair, tick_interval) return _API.get_ticker_history(pair, tick_interval)

View File

@ -1,12 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import asyncio
import copy import copy
import json import json
import logging import logging
import sys import sys
import time import time
import traceback import traceback
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime from datetime import datetime
from typing import Dict, Optional, List from typing import Dict, Optional, List
@ -243,17 +241,8 @@ def create_trade(stake_amount: float) -> bool:
raise DependencyException('No pair in whitelist') raise DependencyException('No pair in whitelist')
# Pick pair based on StochRSI buy signals # Pick pair based on StochRSI buy signals
with ThreadPoolExecutor() as pool: for _pair in whitelist:
awaitable_signals = [ if get_signal(_pair, SignalType.BUY):
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]:
pair = _pair pair = _pair
break break
else: else: