通过IBPY向交互式经纪人提交厕所或MOO订单



使用以下标准代码,我能够使用免费演示帐户提交市场(MKT)和限制订单(LMT)

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

有人有提交厕所或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,您可能想查看。

相关内容

  • 没有找到相关文章

最新更新