简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM