API Support Forum
OEC API > API Support > ConvertFromOECContractList
Author Topic: ConvertFromOECContractList
(4 messages, Page 1 of 1)
Moderators: VPfau
WBetts
Posts: 19
Joined: May 29, 2008


Posted: Jun 12, 2008 @ 08:07 AM             Msg. 1 of 4
I'm currently only getting "index" contracts returned through this function. How do I get other contracts (specifically OJ) to be returned.

btw - I'm connecting to the production server.

Thanks,
-TraderBetts
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Jun 12, 2008 @ 08:30 AM             Msg. 2 of 4
the code in the advanced sample is showing only indices contracts by design.

if you look in the contracts.cs file line 23, you see following code:
m_Contracts = OECClient.Global.ContractGroups["Indices"].Contracts.Values;

to get "OJ" contracts, you can use OECClient.Global.BaseContracts["OJ"].Contracts collection.

you can also refer to global contract collection OECClient.Global.Contracts - but make sure you not trying to display it in the combo box or other UI element, because the number of contracts there could be 50000 (with spreads) or even 200000 (with options).

Also I have to warn you not to use sample code in production environment - we have a dedicated server (api.openecry.com) for development.
WBetts
Posts: 19
Joined: May 29, 2008


Posted: Jun 12, 2008 @ 08:34 AM             Msg. 3 of 4
perfect. thanks Serge. I actually found that line right after I made the post. I have it working fine now.
And thanks for the tip on the dev server. I've been doing lots of testing and just started connecting to live today.

Thanks again,
-TraderBetts
HKusumakar79
Posts: 21
Joined: Feb 18, 2008


Posted: Jun 23, 2008 @ 09:57 AM             Msg. 4 of 4
hi,

i have add new tab and put one dropdownbox to get nearest contracts of basecontracts , so i am using what you said

OECClient.Global.BaseContracts["GCL"].GetNearestContract()

but it is not working.

it is showing me error : System.ArgumentNullException was unhandled by user code
Message="Value cannot be null.\r\nParameter name: item"

actually this type of code working earlier after you change dll this is not working so please help me.
Edited by HKusumakar79 on Jun 23, 2008 at 10:00 AM