python IB API ib_insync 下单

python IB API ib_insync 下单

from ib_insync import *
# util.startLoop()
 
ib = IB()
ib.connect('127.0.0.1', 7496, clientId=1)
 
 
contract = Stock('AAPL', 'SMART', 'USD')
ib.qualifyContracts(contract)
 
order = MarketOrder('BUY', 1)
 
trade = ib.placeOrder(contract, order)
 
print(trade)
 
ib.sleep(1)
print(trade.log)
 
limitOrder = LimitOrder('BUY', 1, 0.05)
limitTrade = ib.placeOrder(contract, limitOrder)
 
print(limitTrade)
 
ib.cancelOrder(limitOrder)

python IB API ib_insync 下单_第1张图片
https://github.com/erdewit/ib_insync/blob/master/notebooks/ordering.ipynb
http://www.waitingfy.com/archives/5343

你可能感兴趣的:(python,量化投资)