Hi,
I would like to set the ratio for one leg in VBA. The Quantity is for the whole structure.
How to do that? Do I need to add it as a third leg?
Could you please help me?
Here is my source code:
Dim hOrder As New COMPLEXORDER ' Complex options order header --------------------------- hOrder.Strategy = "Vertical" hOrder.SetSymbol 0, Symbol hOrder.SetExchange 0, Exch hOrder.SetPriceType 0, "Limit" hOrder.SetTIF 0, "Day" hOrder.SetQuantity 0, Qty hOrder.SetAccount 0, Acct ' Leg 1 hOrder.SetSide 1, Side hOrder.SetPosition 1, "Open" hOrder.SetOptType 1, PC hOrder.SetMonth 1, Mat hOrder.SetStrike 1, Strike ' Leg 2 If (Side = "Buy") Then hOrder.SetSide 2, "Sell" ElseIf (Side = "Sell") Then hOrder.SetSide 2, "Buy" End If hOrder.SetPosition 2, "Open" hOrder.SetOptType 2, PC hOrder.SetMonth 2, Mat hOrder.SetStrike 2, Strike2 hOrder.SetPrice 0, Px If (Live) Then rtnVal = hOrder.Submit(myerr) If Not rtnVal Then If myerr <> "" Then MsgBox myerr MsgBox (Now() & "--" & str & "-- Error -- " & myerr) Else MsgBox "Failed - Please Contact REDI Support." End If Else Debug.Print (Now() & "--" & str & "-- Order Submitted") End If Else MsgBox (str & " Not live order") End If End Sub
You need to specify hOrder.Strategy = “Ratio Orders” and specify the header and leg quantities as per the below code snippet.
I just tried this on my machine and it worked (2:7 ratio).
hOrder.Strategy = "Ratio Orders" hOrder.SetSymbol 0, "AAPL" hOrder.SetExchange 0, "DEM2 DMA" hOrder.SetPriceType 0, "Market" hOrder.SetTIF 0, "Day" hOrder.SetAccount 0, "DEMO2" ' Leg 1 of calendar spread hOrder.SetSide 1, "Buy" hOrder.SetPosition 1, "Open" hOrder.SetOptType 1, "Call" hOrder.SetMonth 1, "Jun '18" hOrder.SetStrike 1, "175.00" hOrder.SetQuantity 1, 2 ' Leg 2 of calendar spread hOrder.SetSide 2, "Sell" hOrder.SetPosition 2, "Open" hOrder.SetOptType 2, "Call" hOrder.SetMonth 2, "Jun '18" hOrder.SetStrike 2, "180.00" hOrder.SetQuantity 2, 7hOrder.SetQuantity 0, 1
By the way, the Ratio Order strategy and other strategies like Butterfly, Delta Neutral, Ratio… are demonstrated in the "Order Entry - Complex Option (US Options).xlsm" example available on GitHub here: https://github.com/TR-API-Samples/Example.REDI.VB.ExcelExamples
Hi Dan,
I just tried it and it works perfectly well.
Thank you very much for you kind help and for the link to the examples on GitHub.
Akechi
I want to change the quantity on the second leg, so 1 of one option and say 2x another
Something similar to what I do on this screenshot: screenshot.png
I’ve done more testing:
When I set hOrder.Strategy = “Custom”, I get “Side is required”.
When I set hOrder.Strategy = “Calendar”, the order goes through in the custom ratio, but the side in Message Monitor says “Calendar”.
What do I have to specify in the API for Ratio orders to be submitted?
I tried hOrder.Strategy = “Custom”, but that didn’t work either.