def updatePortfolio(self, contract: Contract, position: float, marketPrice: float, marketValue: float, averageCost: float, unrealizedPNL: float, realizedPNL: float, accountName: str): print('-----------------Portfolio信息-----------------------') print('Contract:', contract.__str__()) print('Position:', position, ' Market Price:', marketPrice, ' MarketValue:', marketPrice, ' Average Cost:', averageCost, ' unRealized PNL:', unrealizedPNL, ' Realized PNL:', realizedPNL, ' Account Name:', accountName)
def openOrder(self, orderId: OrderId, contract: Contract, order: Order, orderState: OrderState): print('OpenOrders信息:') print(orderId) print(order.__str__()) print(contract.__str__()) # print_Order_State(orderState) self.placedorders.append(order_contract_idfy_genarator(order, contract)) self.placedorderIDs.append(orderId) self.placedorderTotalQty.append(order.totalQuantity)
def Place_Order_Singal(self, orderId: int, contract: Contract, order: Order): self.placeOrder(orderId, contract, order) print('提交父订单--', contract.__str__(), '----', order.__str__()) self.control_reqtime_gap() self.reqIds(-1) self.control_reqtime_gap() while True: if orderId < self.NextValidID: break self.ProClient.APIreturnValues = self.NextValidID
def position(self, account:str, contract:Contract, position:float, avgCost:float): print('-----------------Position信息-----------------------') print('Account:', account, ' Position:', position, ' avgCost:', avgCost) print('Contract:', contract.__str__())