Troubleshooting IB API: Unexpected VOL attribute error when placing a simple order

I’m having trouble with the Interactive Brokers API using a Go library. When I try to place a basic buy order for MSFT stock, I keep getting this weird error:

Error validating request:-'bB' : cause - Cannot set VOL attribute on non-VOL order.

But I didn’t set any VOL attribute in my order! Here’s a quick example of what I’m doing:

func placeOrder(eng *ib.Engine) {
    order := ib.Order{
        Action:     "BUY",
        OrderType:  "LMT",
        TotalQty:   50,
        LimitPrice: 200.50,
    }
    contract := ib.Contract{
        SecurityType: "STK",
        Symbol:       "AAPL",
        Exchange:     "SMART",
        Currency:     "USD",
    }
    req := &ib.PlaceOrder{
        Order:    order,
        Contract: contract,
    }
    // ... send the order and handle the response
}

Am I missing something obvious? The API dump looks fine to me, but maybe there’s a hidden issue? Any help would be great!

yo mike, had dis problem too. try adding order.AuxPrice = 0 to ur code. sometimes IB api gets weird w/ default values. also, double check ur account settings - paper trading can mess things up. if nothin works, hit up IB support, they sorted me out quick last time.

I’ve encountered a similar issue when working with the IB API. In my experience, this error often occurs due to a mismatch between the order type and the attributes you’re trying to set.

For LMT orders, you shouldn’t need to worry about VOL attributes. However, I’ve found that sometimes the API can be finicky about certain default values or hidden fields. Here’s what worked for me:

Try explicitly setting more order parameters, even if they seem redundant. For instance, add fields like:

order.Transmit = true
order.OutsideRTH = false
order.Tif = "DAY"

Additionally, double-check your contract specifications. Make sure you’re using the correct exchange and that the symbol is valid for that exchange.

If the problem persists, you might want to enable more verbose logging in the API to see exactly what’s being sent. Sometimes, the error messages can be misleading, and seeing the raw data can help pinpoint the issue.

Lastly, ensure you’re using the latest version of the Go library for IB API. Older versions might have bugs that cause unexpected behavior.

I’ve run into this issue before, and it’s a tricky one. The VOL attribute error often pops up when there’s a mismatch between order types or some hidden default is causing trouble. Here’s what I’d suggest:

First, try explicitly setting the OrderType to ‘LMT’ in your contract definition, not just the order. Sometimes the API gets confused if these don’t match exactly.

Also, check your account permissions. If you’re using a paper trading account or have certain restrictions, it might be defaulting to a different order type behind the scenes.

If that doesn’t work, try placing the order through TWS or the web interface first, then compare the successful order details with what your API is sending. This can often reveal subtle differences causing the issue.

Lastly, consider using the Native IB API directly instead of a third-party Go library. While less convenient, it can help eliminate any potential library-specific quirks.