April 2019
Intermediate to advanced
426 pages
11h 13m
English
Write the following OandaBroker class, which is specific to our broker, extending the generic Broker class:
import v20class OandaBroker(Broker):
PRACTICE_API_HOST = 'api-fxpractice.oanda.com'
PRACTICE_STREAM_HOST = 'stream-fxpractice.oanda.com'
LIVE_API_HOST = 'api-fxtrade.oanda.com'
LIVE_STREAM_HOST = 'stream-fxtrade.oanda.com'
PORT = '443'
def __init__(self, accountid, token, is_live=False):
if is_live: host = self.LIVE_API_HOST stream_host = self.LIVE_STREAM_HOST else: host = self.PRACTICE_API_HOST stream_host = self.PRACTICE_STREAM_HOST super(OandaBroker, self).__init__(host, self.PORT) self.accountid = accountid self.token = token self.api = v20.Context(host, self.port, token=token) self.stream_api = v20.Context(stream_host, ...