From 58f1abf28712cb3f3c8aa3d4ff05b26f0c5dc5dc Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 26 Dec 2018 14:32:17 +0100 Subject: [PATCH] Add dp / wallets to strategy interface --- freqtrade/freqtradebot.py | 7 ++++++- freqtrade/strategy/interface.py | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 4d0369849..a096a37da 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -58,8 +58,13 @@ class FreqtradeBot(object): self.persistence = None self.exchange = Exchange(self.config) self.wallets = Wallets(self.exchange) - self.dataprovider = DataProvider(self.config, self.exchange) + + # Attach Dataprovider to Strategy baseclass + IStrategy.dp = self.dataprovider + # Attach Wallets to Strategy baseclass + IStrategy.wallets = self.wallets + pairlistname = self.config.get('pairlist', {}).get('method', 'StaticPairList') self.pairlists = PairListResolver(pairlistname, self, self.config).pairlist diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 08a5cf1cd..7210f5c78 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -13,7 +13,9 @@ import arrow from pandas import DataFrame from freqtrade import constants +from freqtrade.data.dataprovider import DataProvider from freqtrade.persistence import Trade +from freqtrade.wallets import Wallets logger = logging.getLogger(__name__) @@ -96,6 +98,12 @@ class IStrategy(ABC): # Dict to determine if analysis is necessary _last_candle_seen_per_pair: Dict[str, datetime] = {} + # Class level variables (intentional) containing + # the dataprovider (dp) (access to other candles, historic data, ...) + # and wallets - access to the current balance. + dp: DataProvider + wallets: Wallets + def __init__(self, config: dict) -> None: self.config = config self._last_candle_seen_per_pair = {}