question

Upvotes
Accepted
191 1 4 11

COMPLEXORDER - "Side is Required" Error

In production we're getting a "Side is Required" error from the code below however it works fine in the test environment. Any ideas welcome. Thanks!


Private Function SendOptionsOrder() As Integer
'===============================================================
' Send diagonal options order to REDI.
'===============================================================
    Dim Ord As New COMPLEXORDER
    Dim RediRtn As Variant
    Dim RetVal As Integer: RetVal = RET_OK
    Dim ErrMsg As Variant
    
    ' Complex order header
    Ord.Strategy = "Diagonal"
    Ord.SetSymbol 0, "VICI"
    Ord.SetTIF 0, "Day"
    Ord.SetAccount 0, "ACC1"
    
    ' Long Put
    Ord.SetSide 1, "Buy"
    Ord.SetPosition 1, "Open"
    Ord.SetOptType 1, "Put"
    Ord.SetMonth 1, "Jan '23"
    Ord.SetStrike 1, "30.00"
    
    ' Short Put
    Ord.AddOptionLeg
    Ord.SetSide 2, "Sell"
    Ord.SetPosition 2, "Open"
    Ord.SetOptType 2, "Put"
    Ord.SetMonth 2, "Nov '21"
    Ord.SetStrike 2, "25.00"
    
    ' complete header details
    Ord.CustomerIndicator = "xyz"
    Ord.SetExchange 0, "IBCO DMA"
    Ord.SetQuantity 0, 1
    Ord.SetPriceType 0, "Limit"
    Ord.SetPrice 0, 2
        
    ' send order
    RediRtn = Ord.Submit(ErrMsg)
    
    If Not RediRtn Then
        RetVal = RET_FAIL
        If Trim(ErrMsg) = "" Then
          ErrMsg = "No error message returned. Please contact support."
        End If
        ErrMsg = "Options order FAILED." & vbCrLf & vbCrLf & "Error Message: " & ErrMsg
        MsgBox ErrMsg, vbCritical + vbOKOnly, "Order Entry Failed"
    End If
    SendOptionsOrder = RetVal

End Function


redi-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
32.2k 40 11 19

Hello @DDALY ,

Try to remove

Ord.AddOptionLeg

Appears to be causing the same misreport, for me - hope this helps

---

When order population requirements for ComplexOrders in REDI turn a bit tricky, I find it helpful to go back to REDI VB ExcelExamples on GitHub -> Example "Order Entry - Complex Option", start with the working example for a specific option type, and work to the current requirement.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
191 1 4 11

Hi, @zoya faberov, Firstly, that worked so thank you! Also, great advice on the example Excel file - I'll keep that handy for reference.

The problem however is that now it doesn't work for me in the staging environment [see error message]. I remember this was the reason I added that line of code in the first place. Seems like there is some kind of environmental mismatch. How can we fix this?

Capture.JPG



capture.jpg (16.7 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
32.2k 40 11 19

Hello @DDALY and all,

Please find our Complex Options -> Diagonal sample updated on GitHub, to set Symbol before setting Strategy.

This example code is verified to work with versions 19 and 21, and by following the same approach, you should be able to have the custom code running under both versions.

Diagonal example does not include setting AddOptionLeg. It is not intended for use for Diagonal, it should only be used for custom strategy.

Hope this information helps

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
191 1 4 11
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.