From d20e3f79be2ed7f3a8f4df270b165fe8b6c2e3b1 Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Wed, 21 Mar 2018 19:57:58 +0200 Subject: [PATCH] analyze to use the ccxt OHLCV format setup: remove bittrex and add requirement to ccxt freqtradebot: update market summaries to ccxt format --- freqtrade/analyze.py | 13 +++++++------ freqtrade/freqtradebot.py | 15 +++++++-------- scripts/plot_dataframe.py | 2 +- setup.py | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/freqtrade/analyze.py b/freqtrade/analyze.py index 8bc552d74..decb73628 100644 --- a/freqtrade/analyze.py +++ b/freqtrade/analyze.py @@ -44,12 +44,13 @@ class Analyze(object): :param ticker: See exchange.get_ticker_history :return: DataFrame """ - columns = {'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'} - frame = DataFrame(ticker) \ - .rename(columns=columns) - if 'BV' in frame: - frame.drop('BV', 1, inplace=True) - frame['date'] = to_datetime(frame['date'], utc=True, infer_datetime_format=True) + cols = ['date', 'open', 'high', 'low', 'close', 'volume'] + frame = DataFrame(ticker, columns=cols) + + frame['date'] = to_datetime(frame['date'], + unit='ms', + utc=True, + infer_datetime_format=True) frame.sort_values('date', inplace=True) return frame diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index e57f177e9..ef9bd593b 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -208,13 +208,12 @@ class FreqtradeBot(object): :return: List of pairs """ summaries = sorted( - (s for s in exchange.get_market_summaries() if - s['MarketName'].startswith(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'].replace('-', '_') for s in summaries] + return [s['symbol'] for s in summaries] def _refresh_whitelist(self, whitelist: List[str]) -> List[str]: """ @@ -227,15 +226,15 @@ class FreqtradeBot(object): sanitized_whitelist = whitelist health = exchange.get_wallet_health() known_pairs = set() - for status in health: - pair = '{}_{}'.format(self.config['stake_currency'], status['Currency']) + for symbol, status in health.items(): + pair = f"{status['base']}/{self.config['stake_currency']}" # pair is not int the generated dynamic market, or in the blacklist ... ignore it if pair not in whitelist or pair in self.config['exchange'].get('pair_blacklist', []): continue # else the pair is valid known_pairs.add(pair) # Market is not active - if not status['IsActive']: + if not status['active']: sanitized_whitelist.remove(pair) self.logger.info( 'Ignoring %s from whitelist (reason: %s).', @@ -328,7 +327,7 @@ class FreqtradeBot(object): pair=pair, stake_amount=stake_amount, amount=amount, - fee=exchange.get_fee(), + fee=exchange.get_fee_maker(), open_rate=buy_limit, open_date=datetime.utcnow(), exchange=exchange.get_name().upper(), diff --git a/scripts/plot_dataframe.py b/scripts/plot_dataframe.py index 285ba6d97..5c5e17661 100755 --- a/scripts/plot_dataframe.py +++ b/scripts/plot_dataframe.py @@ -55,7 +55,7 @@ def plot_analyzed_dataframe(args: Namespace) -> None: if args.live: logger.info('Downloading pair.') # Init Bittrex to use public API - exchange._API = exchange.Bittrex({'key': '', 'secret': ''}) + exchange.init({'key': '', 'secret': ''}) tickers[pair] = exchange.get_ticker_history(pair, tick_interval) else: tickers = optimize.load_data( diff --git a/setup.py b/setup.py index 4b0635efa..856a47181 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ setup(name='freqtrade', setup_requires=['pytest-runner'], tests_require=['pytest', 'pytest-mock', 'pytest-cov'], install_requires=[ - 'python-bittrex', + 'ccxt', 'SQLAlchemy', 'python-telegram-bot', 'arrow',