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()