Exel VBA commands to place orders with IB

Discussion in 'Trading Software' started by TradingNerd, Apr 16, 2011.

  1. Hello,

    I am trying to create a simple buy order through Excel API but can't manage to do so.

    The sample excel of TWS has hundreds lines of code and tons of loops which are mostly irrelevant..

    The basic code should be something like:

    Symbol = "XOM"
    Side = "BUY"
    Quantity = 1000
    Price = 110
    PriceType = "LMT"
    Exchange = "SMART"
    TIF = "DAY"

    submitorder

    Can anyone please tell me the right codes that IB is using for a simple order like this?

    Thanks!
     
  2. The examples in the sample spreadsheet should work for stocks.
    Have you enabled TWS to work with the API?
     
  3. The examples do work, but I want to use the script in my own custom excel sheet and there are tons of unneeded rows of code that I don't need.
     
  4. Do you receive an error message or something?
    Can you receive quotes in the Excel sheets?
     
  5. I already found it all out, been busy the whole day and it's working. I narrowed about 1000 lines of code to these few lines.

    Sub test()
    Dim Id As Long

    req = "buy_111_YHOO_STK_SMART_USD_MKT_{}_DAY_{}_{}_O_0_{}_1_{}_0_0_0_0_{}_0_0_{}_{}_{}_{}_{}_{}_{}_ISLAND'"

    Id = Round((Date - 39000 + Time) * 1000000, 0)


    ActiveCell.Value = "=droog914|ord!'id" & Id & "?place?" & req

    End Sub