ribrokers

Currency (FX) order with IBrokers in TWS


I am able to use IBrokers to submit standard futures and equity orders through the API. When I try the same methodology for spot FX, I don't receive an error message, yet the order doesn't come through the TWS working window as it does with the other contract types.

contract = twsCurrency("EUR.USD")

Order = twsOrder(
  reqIds(tws),
  action = "BUY",
  totalQuantity = 1000000,
  orderType = "LMT",
  lmtPrice = 1.0600
)

placeOrder(tws, 
           Contract = contract, 
           Order)

Solution

  • The problem in the end was the numeric value 1000000 as it was cast to a character string. In that process, the conversion was first to a scientific notation, which is not accepted by the TWS API. To correct this, setting options(scipen = 12) or some very large value in the place of 12.