[英]How to get the trading price and commission in Interactive Brokers new API (9.73) after placing an order?
I'm looking at ib_insync, framework for new Interactive Brokers python API. 我正在查看ib_insync,这是新的Interactive Brokers python API的框架。 One thing I can't figure out is how to get the trading price after placing market order. 我不知道的一件事是如何在下达市价单后获得交易价格。 Has anyone figured it out? 有人知道吗?
I've seen this question , but it's for the old API and IBPY. 我已经看到了这个问题 ,但这是针对旧的API和IBPY的。
If anyone wants to know, here's how to get the price at which you bought/sold: 如果有人想知道,以下是获取购买/出售价格的方法:
from ib_insync.order import MarketOrder
order = MarketOrder(action, quantity)
trade = self.ib.placeOrder(contract, order)
# Wait for the trade to complete
...
filled_quantity = trade.filled()
filled_price = trade.orderStatus.avgFillPrice
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.