From 5295723532d4341dd478f47ee8eaa8f2a4f8237e Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Sat, 10 Feb 2018 11:01:00 +0200 Subject: [PATCH] get markets without exchange specific methods --- freqtrade/exchange/__init__.py | 17 ++++++++--------- freqtrade/main.py | 10 ++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index ec80dfb80..2af4674b4 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -149,8 +149,13 @@ def get_ticker(pair: str, refresh: Optional[bool] = True) -> dict: @cached(TTLCache(maxsize=100, ttl=30)) def get_ticker_history(pair: str, tick_interval) -> List[Dict]: - ## implement https://github.com/ccxt/ccxt/blob/master/python/ccxt/bittrex.py#L394-L400 - return _API.get_ticker_history(pair, tick_interval) + # TODO: tickers need to be in format 1m,5m + # fetch_ohlcv returns an [[datetime,o,h,l,c,v]] + _API.load_markets() + # if not _API.markets.get(pair): + # logger.warning('Pair {} doesnt exist in exchange' % pair) + # return [] + return _API.fetch_ohlcv(pair, str(tick_interval)+'m') def cancel_order(order_id: str) -> None: @@ -180,13 +185,7 @@ def get_markets() -> List[str]: def get_market_summaries() -> List[Dict]: - # TODO: check other exchanges how they implement market summaries - summaries = _API.public_get_marketsummaries()['result'] - for market in summaries: - name = market['MarketName'].split('-') - market['MarketName'] = name[-1] + '/' + name[0] - return summaries - + return _API.fetch_tickers() def get_name() -> str: diff --git a/freqtrade/main.py b/freqtrade/main.py index b3d40311b..3461a3fa5 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -377,8 +377,7 @@ def create_trade(stake_amount: float, interval: int) -> bool: ) whitelist = copy.deepcopy(_CONF['exchange']['pair_whitelist']) - print('*******whitelist {}*****'.format(whitelist)) - + # Check if stake_amount is fulfilled if exchange.get_balance(_CONF['stake_currency']) < stake_amount: raise DependencyException( @@ -393,7 +392,6 @@ def create_trade(stake_amount: float, interval: int) -> bool: if not whitelist: raise DependencyException('No pair in whitelist') - # Pick pair based on StochRSI buy signals for _pair in whitelist: (buy, sell) = get_signal(_pair, interval) if buy and not sell: @@ -471,11 +469,11 @@ def gen_pair_whitelist(base_currency: str, key: str = 'BaseVolume') -> List[str] :return: List of pairs """ summaries = sorted( - (s for s in exchange.get_market_summaries() if s['MarketName'].endswith(base_currency)), - key=lambda s: s.get(key) or 0.0, + (v for s,v in exchange.get_market_summaries().items() if v['symbol'].endswith(base_currency)), + key=lambda v: v.get('info').get(key) or 0.0, reverse=True ) - return [s['MarketName'] for s in summaries] + return [s['symbol'] for s in summaries] def cleanup() -> None: