![](/img/trans.png)
[英]Using IBrokers and R, what is the appropriate way to retrieve last traded price during live trading session?
[英]Using IBrokers for option trading
我可以將使用R(使用盈透證券股票交易 IBrokers API ),但我不能為期權交易做。
我將在此處發布示例代碼,也許社區中的某人可以提供幫助。
library('IBrokers')
tws <- twsConnect(port=7497)
orderid = reqIds( tws, numIds=1)
neworder = twsOrder( orderid, action='BUY', totalQuantity='4', orderType='LMT', lmtPrice='.1')
opt <- twsOption("AAPL",expiry="281707", strike="10.0", right="C")
placeOrder( tws, opt, neworder )
twsDisconnect(tws)
您沒有輸入正確的到期日期,請嘗試:
opt <- twsOption("AAPL", expiry="20180315", strike="170", right="C")
格式為yyyymmdd
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.