Add dp / wallets to strategy interface

This commit is contained in:
Matthias 2018-12-26 14:32:17 +01:00
parent d3a37db79a
commit 58f1abf287
2 changed files with 14 additions and 1 deletions

View File

@ -58,8 +58,13 @@ class FreqtradeBot(object):
self.persistence = None self.persistence = None
self.exchange = Exchange(self.config) self.exchange = Exchange(self.config)
self.wallets = Wallets(self.exchange) self.wallets = Wallets(self.exchange)
self.dataprovider = DataProvider(self.config, 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') pairlistname = self.config.get('pairlist', {}).get('method', 'StaticPairList')
self.pairlists = PairListResolver(pairlistname, self, self.config).pairlist self.pairlists = PairListResolver(pairlistname, self, self.config).pairlist

View File

@ -13,7 +13,9 @@ import arrow
from pandas import DataFrame from pandas import DataFrame
from freqtrade import constants from freqtrade import constants
from freqtrade.data.dataprovider import DataProvider
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.wallets import Wallets
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -96,6 +98,12 @@ class IStrategy(ABC):
# Dict to determine if analysis is necessary # Dict to determine if analysis is necessary
_last_candle_seen_per_pair: Dict[str, datetime] = {} _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: def __init__(self, config: dict) -> None:
self.config = config self.config = config
self._last_candle_seen_per_pair = {} self._last_candle_seen_per_pair = {}