简体   繁体   English

下订单后如何在盈透证券新API(9.73)中获得交易价格和佣金?

[英]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.

相关问题 如何从交互式经纪人API获取历史股价数据? - How to get historical stock price data from interactive brokers API? 互动经纪人 API 执行细节,我如何获得我得到的期货的入场价格? - interactive brokers API execute details, how I get the entry price of a Future that i got? 盈透证券 - TWS API - 最低价格增量 - Interactive Brokers - TWS API - Minimum Price Increment 盈透证券自动交易 - Interactive Brokers automated trading 使用本机TWS Python APi(交互式经纪人API),如何在变量中获得证券清单的价格快照? - Using the native TWS Python APi (Interactive Brokers API), how do I get in a variable the price snapshot of a list of securities? ibpy如何使用交互式经纪人的API获得佣金? - ibpy how to get commission using interactive broker's API? 下期权订单时出现错误 201 交互式经纪人 tws - Error 201 interactive brokers tws while placing options order 5秒后如何在Interactive Brokers上关闭未结订单 - How can I close an opened order on Interactive brokers after 5 seconds 盈透证券API客户端/ Python将LMT价格设置为当前价格 - Interactive brokers API Client /Python setting LMT price as current price 如何在 Interactive brokers python api 的括号订单中设置和应用偏移量到父订单设置? - How to set and apply offset to parent order setting in bracket order for Interactive brokers python api?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM