API Support Forum
OEC API > API Support > = api.BaseContracts.FindBySymbol(Name) in OECAPICOM
Author Topic: = api.BaseContracts.FindBySymbol(Name) in OECAPICOM
(5 messages, Page 1 of 1)
Moderators: VPfau
ASykes4318
Posts: 18
Joined:


Posted: Sep 07, 2020 @ 05:31 AM             Msg. 1 of 5
I'm trying to find a way in GF API COM to find the base symbol when the contract name is provided???

Public Sub SubscribeAll(oecApi As OECAPICOM.IOECClient)
Dim Contract As OECAPICOM.iContract, bc As OECAPICOM.IBaseContract
Dim i As Integer, Name As String, t As Integer

On Error GoTo Err_SubscribeAll

Set api = oecApi
t = UBound(aryCommodities()) + 1
For i = 1 To t
With aryCommodities(i - 1)
Name = .Base_Contract
Set Contract = api.Contracts.Item(Name)
If Contract Is Nothing Then
'Set Contract = Glob.FindNearest(Name)
If Not (Contract Is Nothing) Then
ElseIf Len(Name) > 3 Then
Set bc = api.BaseContracts.FindBySymbol(Name)
If Not (bc Is Nothing) Then
.Base_ContractSize = bc.ContractSize
.Base_Margin = Round(bc.InitialMargin / 2, 2)
.Base_PriceFormat = bc.PriceFormat
.Base_PriceMultiplier = bc.PriceMultiplier
.Base_TickSize = bc.TickSize
api.RequestContracts bc
Set Contract = api.Contracts.Item(Name)
End If
End If
Else
Set bc = api.BaseContracts.FindBySymbol(Name)
If Not (bc Is Nothing) Then
.Base_ContractSize = bc.ContractSize
.Base_Margin = Round(bc.InitialMargin / 2, 2)
.Base_PriceFormat = bc.PriceFormat
.Base_PriceMultiplier = bc.PriceMultiplier
.Base_TickSize = bc.TickSize
End If
End If
End With

If Not (Contract Is Nothing) Then
api.Subscribe Contract
Set SubscribedContracts(i) = Contract
Else
Set SubscribedContracts(i) = Nothing
End If

Next i

Exit_SubscribeAll:
On Error Resume Next
Exit Sub

Err_SubscribeAll:
gParms = "OECAPICOM.IOECClient"
Call LogError(Err.Number, Err.Description, "Quotes", "SubscribeAll()", gParms)
Resume Exit_SubscribeAll
Resume Next

End Sub
Anthony Sykes
JSmith5611
Posts: 187
Joined:


Posted: Sep 15, 2020 @ 11:42 AM             Msg. 2 of 5
GF_Api_COM.GFComClient.Contracts.Get_2(Name) is the equivalent to api.Contracts.Item(Name)
if that succeeds, then there is a BaseSymbol property on the Contract.

If that fails, you will have to do a contract lookup (GF_Api_COM.GFComClient.Contracts.Lookup.BySymbol() for the simplest method)

you can use that string as the input to GF_API_COM.GFComClient.Contracts.Base.Get_3()

If your wondering, the numbers on the Get() functions were chosen by how COM, not really by us.
Jason Smith
JSmith5611
Posts: 187
Joined:


Posted: Sep 15, 2020 @ 11:42 AM             Msg. 3 of 5
Also.. if I may ask, why are you using the COM api instead of the .NET nuget package?
Jason Smith
JSmith5611
Posts: 187
Joined:


Posted: Sep 17, 2020 @ 01:00 PM             Msg. 4 of 5
GF_Api_COM.GFComClient.Contracts.Lookup.BySymbol() does not return a contract, it returns a contract lookup id.
This actually does send a request looking for a contract that you had never previously seen since logging in. You need to wait for the SymbolLookupReceived event, which will contain the found contracts (and then they will also be available via GFComClient.Contracts.Get methods)
Jason Smith
CMicciche902
Posts: 367
Joined:


Posted: Sep 24, 2020 @ 02:42 PM             Msg. 5 of 5
If you need to reply to us, please reply in this forum. We are not able to reply to your emails. Unfortunately, we're unable to refer you to external developers to assist with programming COM API.
Chris M