簡體   English   中英

盈透證券API客戶端/ Python將LMT價格設置為當前價格

[英]Interactive brokers API Client /Python setting LMT price as current price

使用Python和IB API,如何將lmt價格設置為當前市場價格。 下面是一個示例,當您調用make_order並傳遞帶有操作和數量的價格時。 如何將價格定義為MarketPrice?

def make_order(action, quantity,price):
    if price is not None:
        order = Order()
        order.m_orderType = 'LMT'
        order.m_totalQuantity = 2
        order.m_action = action
        order.m_lmtPrice = price
        order.m_outsideRth = True

您需要通過調用諸如reqTickByTickDatareqMktData類的函數來訪問當前價格。 然后,您可以將lmtPrice字段設置為當前價格。

如果您想以當前價格下訂單,那么創建市場訂單會更好嗎?

如果您要一步一步完成操作,我建議使用其他訂單類型,例如“按市定單”或“按定單中點”:

捕捉市場訂單

order = Order()
order.action = action
order.orderType = "SNAP MKT"
order.totalQuantity = quantity
order.auxPrice = offset

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM