API Support Forum
OEC API > API Support > Empty Contact List
Author Topic: Empty Contact List
(2 messages, Page 1 of 1)
Moderators: VPfau
TLong8876
Posts: 1
Joined: Dec 29, 2015


Posted: Jan 01, 2016 @ 03:19 PM             Msg. 1 of 2
I am using Delphi and hence the COM interface to connect.
After successfully logging in, I can load things like base contracts and accounts but the list of specific contracts appears to be empty.
Below is the delphi code test procedure I am using and below that is the output log resulting from it.

Thanks for any help.

procedure TOECServerForm.connectToOEC(Sender: TObject);
begin
log('Trying to connect to OEC...');
OECClient1.UUID := '9e61a8bc-0a31-4542-ad85-33ebab0e4e86';
OECClient1.Connect1('api.gainfutures.com', 9200, ***, ***, true);
end;

procedure TOECServerForm.loginComplete(Sender: TObject);
begin
log('login complete');
log('contracts: ' + intToStr(OECClient1.Contracts.Count));
end;

procedure TOECServerForm.testData(Sender: TObject);
var
i: integer;
obc: BaseContract;
ibc: IContract;
icontList: IContractList;
begin
log(intToStr(OECClient1.BaseContracts.Count) + ' base contracts found');
log(intToStr(OECClient1.Contracts.Count) + ' contracts found');

obc := OECClient1.BaseContracts.FindBySymbol('ES');
OECClient1.RequestContracts(obc);

log(intToStr(OECClient1.Accounts.Count) + ' accounts found');
log('Account: ' + OECClient1.Accounts.First.Name);

log(obc.ToString);
log(obc.Name);
log(obc.Currency.Name);
log(obc.ContractGroup.Name);

ibc := OECClient1.Contracts.GetContract(1, true);
if ibc <> nil then
log(ibc.Name);

icontList := OECClient1.Contracts;
log(intToStr(icontList.Count) + ' contracts found');
end;

Log
-----

7:19:44 AM: Trying to connect to OEC...
7:19:51 AM: login complete
7:19:51 AM: contracts: 0
7:19:51 AM: 479 base contracts found
7:19:51 AM: 0 contracts found
7:19:51 AM: 1 accounts found
7:19:51 AM: Account: API002723
7:19:51 AM: ES
7:19:51 AM: E-Mini S&P
7:19:51 AM: USD
7:19:51 AM: Indices
7:19:51 AM: 0 contracts found

Thomas Long
NShine
Posts: 36
Joined:


Posted: Jan 08, 2016 @ 12:27 PM             Msg. 2 of 2
Hi Thomas,

Please see our FAQ in our API documentation.

http://www.gainfutures.com/api/api/?topic=html/c1dcf698-2b86-4259-81c1-cb749c226e70.htm

Quote: I called RequestContracts(BaseContract), but Contracts list still has no contracts. Why?
As most of OECClient methods, RequestContracts is asynchronous. Though it returns immediately, results are available only after the contracts are downloaded and event is fired. Make sure you got an event OnContractsChanged before accessing the contracts

In your case, you will want to implement the above event and avoid checking the contracts immediately after your request. The API will not have had time to send the request and receive a response. Let me know if this works for you.