def call(self): apilog.info('calling BDAQ Api GetAccountBalances') result = self.client.service.GetAccountBalances() # accinfo is a dictionary of (_AvailableFunds, _Balance, # _Credit, _Exposure). accinfo = apiparse.ParseGetAccountBalances(result) return accinfo
def call(self, seqnum=None): global ORDER_SEQUENCE_NUMBER # the sequence number should come in the first instance from # the bootstrap, see class ApiListBootstrapOrders if seqnum: self.req.SequenceNumber = seqnum else: self.req.SequenceNumber = ORDER_SEQUENCE_NUMBER apilog.info(('Calling ListOrdersChangedSince with ' 'sequence number: {0}'\ .format(self.req.SequenceNumber))) resp = self.client.service.ListOrdersChangedSince(self.req) data = apiparse.ParseListOrdersChangedSince(resp) if not data: # should be returning an empty dict here, i.e. no orders # changed since last call. return data # if we did get some orders changed, the data consists of the # order information and the new max sequence number. orders, snum = data # set order sequence number to the maximum one returned by Api ORDER_SEQUENCE_NUMBER = snum #apilog.debug('Setting sequence number to: {0}'\ # .format(snum)) return orders
def call(self, order): # order passed should be a dict with keys # see 'ordertest.py' for what the dict should contain self.makeorder(order) self.req.Orders.Order = [self.order] apilog.info('calling BDAQ Api PlaceOrdersWithReceipt') result = self.client.service.PlaceOrdersWithReceipt(self.req) return result
def call(self, ids): self.req.EventClassifierIds = ids self.req._WantPlayMarkets = False apilog.info('calling BDAQ Api GetEventSubTreeWithSelections') response = self.client.service.\ GetEventSubTreeWithSelections(self.req) # I amended parse function to grab selections too allmarkets_with_sels = apiparse.ParseGetEventSubTreeWithSelections( response) return allmarkets_with_sels
def call(self, snum=-1): # the sequence number should come in the first instance from # the bootstrap which is next class global ORDER_SEQUENCE_NUMBER self.req.SequenceNumber = ORDER_SEQUENCE_NUMBER apilog.info('calling BDAQ Api ListBootstrapOrders') result = self.client.service.ListBootstrapOrders(self.req) # assign sequence number we get back to ORDER_SEQUENCE_NUMBER ORDER_SEQUENCE_NUMBER = result._MaximumSequenceNumber allorders = apiparse.ParseListBootstrapOrders(result) return allorders
def call(self, ids, direct = False): """ Return list of markets for events. ids should be a list of event ids e.g. calling with ids = [100004, 100005] will give all markets for 'Horse Racing' and 'Tennis'. """ self.req.EventClassifierIds = ids self.req._WantDirectDescendentsOnly = direct self.req._WantPlayMarkets = False apilog.info('calling BDAQ Api GetEventSubTreeNoSelections') response = self.client.service.\ GetEventSubTreeNoSelections(self.req) allmarkets = apiparse.ParseGetEventSubTreeNoSelections(response) return allmarkets
def call(self, orderlist): assert isinstance(orderlist, list) orders = {} MAXORDERS = 50 for ol in util.chunks(orderlist, MAXORDERS): # make BDAQ representation of orders from orderlist past self.req.Orders.Order = self.makeorderlist(ol) apilog.info('calling BDAQ Api PlaceOrdersNoReceipt') result = self.client.service.PlaceOrdersNoReceipt(self.req) ors = apiparse.ParsePlaceOrdersNoReceipt(result, orderlist) orders.update(ors) # note: could put result.Timestamp in order object so that we # are saving the BDAQ time. return orders
def call(self, ids, direct=False): """ Return list of markets for events. ids should be a list of event ids e.g. calling with ids = [100004, 100005] will give all markets for 'Horse Racing' and 'Tennis'. """ self.req.EventClassifierIds = ids self.req._WantDirectDescendentsOnly = direct self.req._WantPlayMarkets = False apilog.info('calling BDAQ Api GetEventSubTreeNoSelections') response = self.client.service.\ GetEventSubTreeNoSelections(self.req) allmarkets = apiparse.ParseGetEventSubTreeNoSelections(response) return allmarkets
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) apilog.info('calling BDAQ Api GetPrices') result = self.client.service.GetPrices(self.req) selections = apiparse.ParseGetPrices(ids, result) allselections = allselections + selections return allselections
def call(self): """Return list of events.""" apilog.info('calling BDAQ Api ListTopLevelEvents') response = self.client.service.ListTopLevelEvents(self.req) events = apiparse.ParseListTopLevelEvents(response) return events
def call(self): apilog.info('calling BDAQ Api ListBlacklistInformation') result = self.client.service.ListBlacklistInformation() return result
def call(self, olist): self.req.OrderHandle = [o.oref for o in olist] apilog.info('calling BDAQ Api CancelOrders') result = self.client.service.CancelOrders(self.req) ol = apiparse.ParseCancelOrders(result, olist) return ol