¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Margin for generic orders basket, multiple legs


 

Hi,
Margin for combo orders works fine. This is simply achieved by creating a combo order, and ask for whatif, exactly the same way as if the order was for a single leg.
In a generic coding language, that would look like:

IContractOrd = new IBApi.Contract()
IContractOrd.Symbol="SPY"
IContractOrd.secType="BAG"
IContractOrd.exchange="SMART"
IContractOrd.currency="USD"

IContractOrd.ComboLegs = new List<ComboLeg>()
// create all your legs (see API doc), then:
IContractOrd.ComboLegs.Add(leg1)
IContractOrd.ComboLegs.Add(leg2)
IContractOrd.ComboLegs.Add(leg3)
IContractOrd.ComboLegs.Add(leg4)

IOrder = new IBApi.Order()
IOrder.OrderRef = "4faf0786-dddd-4554-8307-05204548b17b"
IOrder.account="U123456"
IOrder.action = "SELL"
IOrder.orderType = "LMT"
IOrder.tif="GTC"
IOrder.totalQuantity = 5

IOrder.transmit = true?? //you need to transmit to get whatif response. In this case, it does NOT transmit the order to the market!
IOrder.WhatIf = true???? // Make sure you set this to true !
IBApi.placeOrder(NextOrderId,IContractOrd,IOrder )


Indeed you are right, about spreads or more complex strategies: combo margin is way less than leg-by-leg order.
You can see an example here :
This is an SPY Iron Condor. If you send 4 separate orders, you'll be required $68.366 margin. If you send a combo order, IB will require only $2.500 margin!
These computations are done through whatif orders. And yes, you can create combos with many more than 2 legs, including mixing options and underlying stock.

Join [email protected] to automatically receive all group messages.