How do I set the ratio for one leg in VBA?

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
Best Answer
-
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, 1By 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.ExcelExamples0
Answers
-
Hi Akechi,
What do you mean ratio for one leg?
0 -
I want to change the quantity on the second leg, so 1 of one
option and say 2x anotherSomething similar to what I do on this screenshot: screenshot.png
0 -
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.0 -
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
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.4K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 559 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 280 Open PermID
- 45 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 716 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛