API Support Forum
OEC API > API Support > Trying to get contract Id
Author Topic: Trying to get contract Id
(2 messages, Page 1 of 1)
Moderators: VPfau
ASykes4318
Posts: 14
Joined:


Posted: Nov 05, 2020 @ 09:10 PM             Msg. 1 of 2
The following code is not returning Contract or Contract Id:


'---------------------------------------------------
'decleration
Private api As GF_Api_COM.IGFComClient

Dim Contract As GF_Api_COM.iContract
Dim myContract As Contract
Dim name As String
Dim ConID, requestID As Long

Dim builder As SymbolLookupRequestBuilder
Set builder = New SymbolLookupRequestBuilder

name = "GCLZ20"
Set myContract = api.Contracts.Get_2(name)

Debug.Print , ".builder.WithSymbol " & name & " My Contract ID:" & ConID
'builder.WithSymbol Name, TextSearchMode_StartsWith
If Not (myContract Is Nothing) Then
builder.WithSymbol name, TextSearchMode_Exact
ConID = Contract.ID
Set requestID = api.Contracts.lookup.BySymbol(name)

builder.WithResultCount 1
api.Contracts.lookup.ByCriteria builder.Build

End If

If Not (Contract Is Nothing) Then
'>>> Contract is nothing here !!!
'Stop
ConID = Contract.ID
End If
'---------------------------------------------------
Anthony Sykes
CMicciche902
Posts: 309
Joined:


Posted: Nov 30, 2020 @ 09:25 AM             Msg. 2 of 2
Sorry for delay. Do you see this issue with other expirations, ie. GCLF21? December contract has now expired so I cannot troubleshoot the matter.
Chris M