Skip to content

Instantly share code, notes, and snippets.

@wlinInspire
Last active August 4, 2019 04:52
Show Gist options
  • Select an option

  • Save wlinInspire/9ceef8a1fb86fe274d22bc21d805a35e to your computer and use it in GitHub Desktop.

Select an option

Save wlinInspire/9ceef8a1fb86fe274d22bc21d805a35e to your computer and use it in GitHub Desktop.
How to Build an Automated Trading System using R
library(IBrokers)
tws <- twsConnect(verbose = FALSE)
symbol <- 'ABC'
quantity <- 100
lmtPrice <- 10
placeOrder(twsconn=tws,
Contract=twsSTK(symbol),
Order=twsOrder(reqIds(tws),
"BUY",
quantity,
"LMT",
lmtPrice = as.character(lmtPrice),
tif = 'GTC'))
twsDisconnect(tws)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment