From 7206287b001d561a2e32ee412bdd294501d9dd58 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 2 Dec 2018 15:57:49 +0100 Subject: [PATCH] Use Dataprovider --- freqtrade/dataprovider.py | 7 ++++--- freqtrade/freqtradebot.py | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/freqtrade/dataprovider.py b/freqtrade/dataprovider.py index 4b924bd9a..035e9852a 100644 --- a/freqtrade/dataprovider.py +++ b/freqtrade/dataprovider.py @@ -5,6 +5,7 @@ including Klines, tickers, historic data Common Interface for bot and strategy to access data. """ import logging +from typing import List, Dict from pandas import DataFrame @@ -19,13 +20,13 @@ class DataProvider(object): self._config = config self._exchange = exchange - def refresh() -> None: + def refresh(self, pairlist: List[str]) -> None: """ Refresh data, called with each cycle """ - pass + self._exchange.refresh_tickers(pairlist, self._config['ticker_interval']) - def ohlcv(self, pair: str) -> DataFrame: + def ohlcv(self, pair: str) -> List[str]: """ get ohlcv data for the given pair as DataFrame """ diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 2e09cf116..9bcc3f86b 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -16,6 +16,7 @@ from freqtrade import (DependencyException, OperationalException, TemporaryError, __version__, constants, persistence) from freqtrade.data.converter import order_book_to_dataframe from freqtrade.edge import Edge +from freqtrade.dataprovider import DataProvider from freqtrade.exchange import Exchange from freqtrade.persistence import Trade from freqtrade.rpc import RPCManager, RPCMessageType @@ -57,6 +58,8 @@ class FreqtradeBot(object): self.persistence = None self.exchange = Exchange(self.config) self.wallets = Wallets(self.exchange) + + self.dataprovider = DataProvider(self.config, self.exchange) pairlistname = self.config.get('pairlist', {}).get('method', 'StaticPairList') self.pairlists = PairListResolver(pairlistname, self, self.config).pairlist @@ -167,7 +170,7 @@ class FreqtradeBot(object): if trade.pair not in self.active_pair_whitelist]) # Refreshing candles - self.exchange.refresh_tickers(self.active_pair_whitelist, self.strategy.ticker_interval) + self.dataprovider.refresh(self.active_pair_whitelist) # First process current opened trades for trade in trades: @@ -317,7 +320,7 @@ class FreqtradeBot(object): # running get_signal on historical data fetched for _pair in whitelist: - (buy, sell) = self.strategy.get_signal(_pair, interval, self.exchange.klines(_pair)) + (buy, sell) = self.strategy.get_signal(_pair, interval, self.dataprovider.ohlcv(_pair)) if buy and not sell: stake_amount = self._get_trade_stake_amount(_pair) if not stake_amount: @@ -579,7 +582,7 @@ class FreqtradeBot(object): experimental = self.config.get('experimental', {}) if experimental.get('use_sell_signal') or experimental.get('ignore_roi_if_buy_signal'): (buy, sell) = self.strategy.get_signal(trade.pair, self.strategy.ticker_interval, - self.exchange.klines(trade.pair)) + self.dataprovider.ohlcv(trade.pair)) config_ask_strategy = self.config.get('ask_strategy', {}) if config_ask_strategy.get('use_order_book', False):