April 2019
Intermediate to advanced
426 pages
11h 13m
English
The following codes implement the parent get_prices() method in the OandaBroker class for getting prices from your broker:
def get_prices(self, symbols=[]):
response = self.api.pricing.get(
self.accountid,
instruments=",".join(symbols),
snapshot=True,
includeUnitsAvailable=False
)
body = response.body
prices = body.get('prices', [])
for price in prices:
self.process_price(price)
The body of the response contains a prices attribute and a list of objects. Each item in the list is processed by the process_price() method. Let's implement this method in the OandaBroker class as well:
def process_price(self, price): symbol = price.instrument if not symbol: print('Price symbol is empty!') return bids = ...Read now
Unlock full access