예제 #1
0
    def openOrderEnd(self):
        openOrders, tmpOrders = self.logic.account.openOrders, self.logic.account.tmpOrders
        ledger = self.client.ledger

        for orderId, values in tmpOrders.items():
            symbol, status = values[0].localSymbol, values[2]
            oldStatus = openOrders[orderId][2] if orderId in openOrders.keys(
            ) else None

            logOrder(ledger, orderId, symbol, values[1], status, oldStatus)

        self.logic.account.openOrders = tmpOrders
        self.logic.account.tmpOrders = {}
예제 #2
0
    def orderStatus(self, orderId, status, filled, remaining, avgFillPrice,
                    permId, parentId, lastFillPrice, clientId, whyHeld):

        if clientId != config.CLIENTID:
            return

        openOrders = self.logic.account.openOrders

        if orderId not in openOrders.keys():
            return

        contract, order, oldStatus = openOrders[orderId]
        symbol = contract.localSymbol

        logOrder(self.client.ledger, orderId, symbol, order, status, oldStatus)
        openOrders[orderId] = (contract, order, status)

        if status in ["Cancelled", "Filled"]:
            self.client.reqOpenOrders()