API Support Forum
OEC API > API Support > Contracts.Lookup.BySymbol() - We are having a problem
Author Topic: Contracts.Lookup.BySymbol() - We are having a problem
(2 messages, Page 1 of 1)
Moderators: VPfau
ASykes4318
Posts: 18
Joined:


Posted: Oct 26, 2020 @ 08:53 PM             Msg. 1 of 2
Our applicaton (developed in Microsoft Access), which connects to the API successfully, but we are having difficulties in setting the contract portion. Ou r main goal is to retrieve Contract details such as ContractSize, PriceFomat etc once we can connect.
?? We also have the Excel, that uses the same API and works successfully.
Our function initilized the GF_Api_COM.GFComClient , but following lines does not help to reacing the Contract
'WaitSeconds is a function that waits timer to loop x seconds.
'api = GF_Api_COM.GFComClient ' was already set

'(a)
Set Contract = api.Contracts.Get_2(Name)
WaitSeconds 5

'(b)'If fails, try by .Contracts.Base.Get_3
If Contract Is Nothing Then
Set Contract = api.Contracts.Base.Get_3(Name)
End If

'(c)'If fails: .Contracts.Lookup.BySymbol()
If Contract Is Nothing Then
If lookup Then
Set requestID = api.Contracts.lookup.BySymbol(Name)
' we have told to wait for system to return requestID, meaning contract is set
WaitSeconds 3
Set Contract = api.Contracts.Base.Get_3(Name)
End If
End If
'Contract is NOT set !!!

'Contract spossed to be set at this point, but it never works
If Not Contract Is Nothing Then
'Step (3) set the bc now
'GF_API_COM.GFComClient.Contracts.Base.Get_3()

'(3-a)
Set bc = api.Contracts.Base.Get_3(Name)
'(3-b)
If (bc Is Nothing) Then
Set bc = api.Contracts.Get_2(Name)
End If

If Not (bc Is Nothing) Then
'bc is set Subscribe now
Dim conID As String
conID = Contract.ID
'api.Subscribe Contract
'Set SubscribedContracts(i) = Contract
Dim subscription As PriceSubscription
end if
Anthony Sykes
JSmith5611
Posts: 187
Joined:


Posted: Oct 28, 2020 @ 01:51 PM             Msg. 2 of 2
hmm..
1) for starters, api.Contracts.Get_2(Name) and api.Contracts.Base.Get_3(Name) are going to return different types (Contract and BaseContract respectively)

2) Before connecting are you setting up the threading model?
3) Why do you sleep instead of listening for the events?
Jason Smith