通过ibpy

提交LOO或MOO订单盈透证券与下面的标准代码,我已经能够提交使用免费模拟账户通过ibpy

from ib.opt import Connection, message 

from ib.ext.Contract import Contract

from ib.ext.Order import Order

def make_contract(symbol, sec_type, exch, prim_exch, curr):

Contract.m_symbol = symbol

Contract.m_secType = sec_type

Contract.m_exchange = exch

Contract.m_primaryExch = prim_exch

Contract.m_currency = curr

return Contract

def make_order(action, quantity, price=None):

if price is not None:

order = Order()

order.m_orderType = 'LMT'

order.m_totalQuantity = quantity

order.m_action = action

order.m_lmtPrice = price

else:

order = Order()

order.m_orderType = 'MKT'

order.m_totalQuantity = quantity

order.m_action = action

return order

def main():

conn = Connection.create(port=7496, clientId=999)

conn.connect()

oid = 100001

cont = make_contract('TSLA', 'STK', 'SMART', 'SMART', 'USD')

offer = make_order('BUY', 100, 315)

conn.placeOrder(oid, cont, offer)

conn.disconnect()

main()

没有任何人有市场(MKT)和限价单(LMT)体验提交LOO或MOO命令?当我改变时:

order.m_orderType = 'LOO' 

我没有得到例外,但是,在IB TWS(演示)中没有显示挂单。

回答:

根据文档你照常LMT或MKT类型,但改变tif OPG(打开我猜)。

order.tif = "OPG" 

order.orderType = "LMT"

http://interactivebrokers.github.io/tws-api/basic_orders.html#limitonopen

说明,字段名使用IB的新的Python API,你可能想看看。

以上是 通过ibpy 的全部内容, 来源链接: utcz.com/qa/265725.html

回到顶部