예제 #1
0
 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
예제 #2
0
    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
예제 #3
0
 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
예제 #4
0
    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
예제 #5
0
 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
예제 #6
0
 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
예제 #7
0
 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
예제 #8
0
 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
예제 #9
0
 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
예제 #10
0
 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
예제 #11
0
    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
예제 #12
0
    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
예제 #13
0
    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
예제 #14
0
    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
예제 #15
0
    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
예제 #16
0
 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
예제 #17
0
 def call(self):
     apilog.info('calling BDAQ Api ListBlacklistInformation')
     result = self.client.service.ListBlacklistInformation()
     return result
예제 #18
0
 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
예제 #19
0
 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
예제 #20
0
 def call(self):
     apilog.info('calling BDAQ Api ListBlacklistInformation')
     result = self.client.service.ListBlacklistInformation()
     return result
예제 #21
0
 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