【问题标题】:interactive brokers api python - fire order during "pre market"交互式经纪人 api python - “上市前”期间的触发订单
【发布时间】:2021-08-07 18:04:14
【问题描述】:

我正在使用IB API 以便在上市前时间自动触发订单。 我无法弄清楚为什么订单在等待开市时间而不是在盘前期间购买。在查看API 文档后,我添加了拍卖订单,但在上市前期间我仍然无法购买。

这是我的代码示例:

from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.order import *
from threading import Timer

class TestApp(EWrapper, EClient):
    def __init__(self):
        EClient.__init__(self, self)

    def error(self, reqId , errorCode, errorString):
        print("Error: ", reqId, " ", errorCode, " ", errorString)

    def nextValidId(self, orderId ):
        self.nextOrderId = orderId
        self.start()

    def orderStatus(self, orderId , status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld, mktCapPrice):
        print("OrderStatus. Id: ", orderId, ", Status: ", status, ", Filled: ", filled, ", Remaining: ", remaining, ", LastFillPrice: ", lastFillPrice)

    def openOrder(self, orderId, contract, order, orderState):
        print("OpenOrder. ID:", orderId, contract.symbol, contract.secType, "@", contract.exchange, ":", order.action, order.orderType, order.totalQuantity, orderState.status)

    def execDetails(self, reqId, contract, execution):
        print("ExecDetails. ", reqId, contract.symbol, contract.secType, contract.currency, execution.execId,
              execution.orderId, execution.shares, execution.lastLiquidity)

    def start(self):
        contract = Contract()
        contract.symbol = "AAPL"
        contract.secType = "STK"
        contract.exchange = "IDEALPRO"
        contract.currency = "USD"
        contract.primaryExchange = "NASDAQ"

        order = Order()
        order.action = "BUY"
        order.tif = "AUC"
        order.totalQuantity = 10
        order.orderType = "MTL"
        order.lmtPrice = 1000
       # order = Order()
       # order.action = "BUY"
       # order.totalQuantity = 10
       # order.orderType = "LMT"
       # order.lmtPrice = 1000



        self.placeOrder(self.nextOrderId, contract, order)

    def stop(self):
        self.done = True
        self.disconnect()

def main():
    app = TestApp()
    app.nextOrderId = 0
    app.connect("127.0.0.1", 7497, 0)

    Timer(3, app.stop).start()
    app.run()

if __name__ == "__main__":
    main()

【问题讨论】:

标签: python api interactive-brokers pyalgotrade ib-api


【解决方案1】:

不确定是否理解您的意思,但在拍卖结束前您无法在拍卖期间执行订单(您只能下订单)。对于开市竞价,这意味着您的订单将在市场开市后执行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多