コード例 #1
0
    def execDetails(self, reqId, contract, execution):
        """
        This is called if

        a) we have submitted an order and a fill has come back
        b) We have asked for recent fills to be given to us

        We populate the filldata object and also call action_ib_fill in case we
          need to do something with the fill data

        See API docs, C++, SocketClient Properties, Contract and Execution for
        more details
        """
        reqId = int(reqId)

        execid = execution.execId
        exectime = execution.time
        thisorderid = int(execution.orderId)
        account = execution.acctNumber
        exchange = execution.exchange
        permid = execution.permId
        avgprice = execution.price
        cumQty = execution.cumQty
        clientid = execution.clientId
        symbol = contract.symbol
        expiry = contract.expiry
        side = execution.side

        execdetails = dict(side=str(side),
                           times=str(exectime),
                           orderid=str(thisorderid),
                           qty=int(cumQty),
                           price=float(avgprice),
                           symbol=str(symbol),
                           expiry=str(expiry),
                           clientid=str(clientid),
                           execid=str(execid),
                           account=str(account),
                           exchange=str(exchange),
                           permid=int(permid))

        if reqId == FILL_CODE:
            # This is a fill from a trade we've just done
            action_ib_fill(execdetails)

        else:
            # This is just execution data we've asked for
            self.add_fill_data(reqId, execdetails)
コード例 #2
0
    def execDetails(self, reqId, contract, execution):
        """
        This is called if

        a) we have submitted an order and a fill has come back
        b) We have asked for recent fills to be given to us

        We populate the filldata object and also call action_ib_fill in case we
          need to do something with the fill data

        See API docs, C++, SocketClient Properties, Contract and Execution for
        more details
        """
        reqId = int(reqId)

        execid = execution.execId
        exectime = execution.time
        thisorderid = int(execution.orderId)
        account = execution.acctNumber
        exchange = execution.exchange
        permid = execution.permId
        avgprice = execution.price
        cumQty = execution.cumQty
        clientid = execution.clientId
        symbol = contract.symbol
        expiry = contract.expiry
        side = execution.side

        execdetails = dict(side=str(side),
                           times=str(exectime),
                           orderid=str(thisorderid),
                           qty=int(cumQty),
                           price=float(avgprice),
                           symbol=str(symbol),
                           expiry=str(expiry),
                           clientid=str(clientid),
                           execid=str(execid),
                           account=str(account),
                           exchange=str(exchange),
                           permid=int(permid))

        if reqId == FILL_CODE:
            # This is a fill from a trade we've just done
            action_ib_fill(execdetails)

        else:
            # This is just execution data we've asked for
            self.add_fill_data(reqId, execdetails)
コード例 #3
0
    def execDetails(self, reqId, contract, execution):
        """
        This is called if 
        
        a) we have submitted an order and a fill has come back (in which case getting_executions is False)
        b) We have asked for recent fills to be given to us (in which case it is True)
        
        In case (a) we call action_ib_fill with the fill details; and for case (b) we add the fill to a list 
        
        See API docs, C++, SocketClient Properties, Contract and Execution for more details 
        """

        global execlist
        global getting_executions

        execid = execution.execId
        exectime = execution.time
        thisorderid = execution.orderId
        account = execution.acctNumber
        exchange = execution.exchange
        permid = execution.permId
        avgprice = execution.price
        cumQty = execution.cumQty
        clientid = execution.clientId
        symbol = contract.symbol
        expiry = contract.expiry
        side = execution.side

        execdetails = dict(side=str(side),
                           times=str(exectime),
                           orderid=str(thisorderid),
                           qty=int(cumQty),
                           price=float(avgprice),
                           symbol=str(symbol),
                           expiry=str(expiry),
                           clientid=str(clientid),
                           execid=str(execid),
                           account=str(account),
                           exchange=str(exchange),
                           permid=int(permid))

        if getting_executions:
            execlist.append(execdetails)
        else:
            ## one off fill
            action_ib_fill(execdetails)
コード例 #4
0
    def execDetails(self, reqId, contract, execution):
    
        """
        This is called if 
        
        a) we have submitted an order and a fill has come back (in which case getting_executions is False)
        b) We have asked for recent fills to be given to us (in which case it is True)
        
        In case (a) we call action_ib_fill with the fill details; and for case (b) we add the fill to a list 
        
        See API docs, C++, SocketClient Properties, Contract and Execution for more details 
        """
        
        global execlist
        global getting_executions    
            
        
        execid=execution.execId
        exectime=execution.time
        thisorderid=execution.orderId
        account=execution.acctNumber
        exchange=execution.exchange
        permid=execution.permId
        avgprice=execution.price
        cumQty=execution.cumQty
        clientid=execution.clientId
        symbol=contract.symbol
        expiry=contract.expiry
        side=execution.side
        
        execdetails=dict(side=str(side), times=str(exectime), orderid=str(thisorderid), qty=int(cumQty), price=float(avgprice), symbol=str(symbol), expiry=str(expiry), clientid=str(clientid), execid=str(execid), account=str(account), exchange=str(exchange), permid=int(permid))

        if getting_executions:        
            execlist.append(execdetails)
        else:
            ## one off fill
            action_ib_fill(execdetails)