def call(self, mids): """ mids should be list of market ids. """ # unsure what MAXMIDS should be. BDAQ returns HTTP 400 return # code if we ask for too much data, so try limiting to 50 # market ids. MAXMIDS = 50 allselections = {} allemids = [] for ids in util.chunks(mids, MAXMIDS): midstring = '&mid=' + '&mid='.join(['{0}'.format(m) for m in ids]) url = self.client.pricesurl + midstring + '&ccyCode=GBP' betlog.betlog.info('calling BDAQ nonApi GetPrices') # betlog.betlog.debug('BDAQ Selection URL: {0}'.format(url)) # make the HTTP request response = self.client.call(url) # selections for all the market ids selections, emids = bdaqnonapiparse.\ ParseNonApiGetPrices(response.read(), ids) allselections.update(selections) allemids = allemids + emids # return selection dictionary and the list of erroneous market ids return allselections, allemids
def call(self, mids): """ Return all selections for Market ids in mids, where mids is a list of market ids. """ allselections = [] # split up mids into groups of size MAXMIDS for (callnum, ids) in \ enumerate(util.chunks(mids, ApiGetPrices.MAXMIDS)): self.req.MarketIds = ids if callnum > 0: # sleep for some time before calling Api again time.sleep(self.throttl) betlog.betlog.info('calling BDAQ Api GetPrices') result = self.client.service.GetPrices(self.req) selections = bdaqapiparse.ParseGetPrices(ids, result) allselections = allselections + selections #if const.WRITEDB: # collapse list of lists to a flat list # writeselections = [i for sub in allselections for i in sub] # self.dbman.WriteSelections(writeselections, result.Timestamp) return allselections
def call(self, mids): allemids = [] MAXMIDS = 50 allminfo = {} allemids = [] for ids in util.chunks(mids, MAXMIDS): # for AUS markets, need to write 2. rather than 1. midstring = '%2C'.join( ['{0}.{1}'.format(self.client.mprefix, m) for m in ids]) # note also that pricesurl is diferent for UK and AUS markets. url = self.client.pricesurl + ('&types=MARKET_STATE%2C' 'MARKET_DESCRIPTION' '&marketIds={0}'.\ format(midstring)) #betlog.betlog.debug('BF getMarket URL: {0}'.format(url)) # make the HTTP request betlog.betlog.info('calling BF nonApi getMarket') response = self.client.call(url) # selections for all the market ids minfo, emids = bfnonapiparse.ParsenonApigetMarket( response.read(), mids) allminfo.update(minfo) allemids = allemids + emids return allminfo, allemids
def call(self, orderlist): orders = {} for ol in util.chunks(orderlist, self.MAXORDERS): self.req.Orders.Order = self.makeorderlist(ol) betlog.betlog.info('calling BDAQ Api UpdateOrdersNoReceipt') result = self.client.service.UpdateOrdersNoReceipt(self.req) ors = bdaqapiparse.ParseUpdateOrdersNoReceipt(result, orderlist) orders.update(ors) return orders
def call(self, orderlist): assert isinstance(orderlist, list) orders = {} for ol in util.chunks(orderlist, self.MAXORDERS): # make BDAQ representation of orders from orderlist past self.req.Orders.Order = self.makeorderlist(ol) betlog.betlog.info('calling BDAQ Api PlaceOrdersNoReceipt') result = self.client.service.PlaceOrdersNoReceipt(self.req) ors = bdaqapiparse.ParsePlaceOrdersNoReceipt(result, orderlist) orders.update(ors) # note: could put result.Timestamp in order ApiMethod so that we # are saving the BDAQ time. return orders
def call(self, mids): """ mids should be list of market ids. """ # unsure what MAXMIDS should be. BF returns HTTP 400 return # code if we ask for too much data, so try limiting to 50 # market ids for now (seems to work). MAXMIDS = 50 allselections = {} allemids = [] for ids in util.chunks(mids, MAXMIDS): # mprefix is 1 for UK markets and 2 for AUS markets midstring = '%2C'.join( ['{0}.{1}'.format(self.client.mprefix, m) for m in ids]) url = self.client.pricesurl + ('&types=RUNNER_DESCRIPTION%2' 'CRUNNER_EXCHANGE' '_PRICES_BEST' '&marketIds={0}'.format(midstring)) betlog.betlog.debug('BF Selection URL: {0}'.format(url)) # make the HTTP request betlog.betlog.info('calling BF nonApi getPrices') response = self.client.call(url) # selections for all the market ids selections, emids = bfnonapiparse.\ ParseJsonSelections(response.read(), ids) allselections.update(selections) allemids = allemids + emids return allselections, allemids