我怎样才能在ib_ncin sync TW获得执行委托

2024-05-04 11:57:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要一份行刑委托书。 我通过用于python的ib_nsync库连接到它们。在

我知道:

ib = IB()
ib.connect('127.0.0.1', 7497, 1)
ib.placeOrder(contract, order)

for e in ib.executions():
    print(e)

问题是——执行死刑的委员会在哪里?我怎么能把他们都抓起来?在


Tags: inforconnectorderibprintcontract委员会
2条回答

好吧,我找到了一个解决方案:

from ib_insync import IB

class MyTrader:
    def __init__(self):
        self.ib = IB()
        self.ib.setCallback('commissionReport', self.commissionCallback)

    def commissionCallback(self, *args):
        print(args[-1])    # CommissionReport object will be printed when order is filed

    def trulala(self):
        self.ib.connect('127.0.0.1', 7498, 1)
        contract = Contract(...)
        order = Order(...)
        self.ib.placeOrder(contract, order)

最后,还有一种更简单的方法(如果需要访问对象,它很有用),它:

^{pr2}$

将返回一个Fill对象列表,其中包含所有必需对象的元组,如Contract、Order、Execution和CommissionReport。在

你应该在https://groups.io/g/insync询问具体细节。我怀疑这里有人使用这个库。在

在执行死刑时不会返回佣金,而是在commissionReport中返回。http://interactivebrokers.github.io/tws-api/classIBApi_1_1CommissionReport.html

请注意,id是与commission报告匹配的执行id。在

相关问题 更多 >