API Support Forum
OEC API > API Support > Contract List
Author Topic: Contract List
(9 messages, Page 1 of 1)
Moderators: VPfau
HKusumakar79
Posts: 21
Joined: Feb 18, 2008


Posted: Mar 20, 2008 @ 07:09 AM             Msg. 1 of 9
hi,

I am using

IList<ContractListEntry> contracts = OECContracts.ConvertFromOECContractList();

to get list of contracts and i am getting list of it but i think its not from all the groups so can you tell me how i can get all the contracts from all the groups? becoz i need to have contracts from energy and currency groups.

what the changes required?
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Mar 20, 2008 @ 08:27 AM             Msg. 2 of 9
to get the full contract list, you need to use OECClient.Contracts property.
HKusumakar79
Posts: 21
Joined: Feb 18, 2008


Posted: Mar 21, 2008 @ 03:06 AM             Msg. 3 of 9
Thanks for your quick reply..

Actually i would like to show contract list in dropdown and i have used OECClient object to get all contract as per your suggessions but still i am not getting proper resut. this is my code :

private void PrepareContracts()
{
OECClient contractList = new OECClient();


ContractList contracts = contractList.Contracts;


cbSymbol.ValueMember = "Symbol";
cbSymbol.DisplayMember = "Name";
cbSymbol.DropDownWidth = 200;

BindingSource bs = new BindingSource(contracts, "");
cbSymbol.DataSource = bs;


cbSymbol.Text = string.Empty;
}
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Mar 21, 2008 @ 10:50 AM             Msg. 4 of 9
contract list is downloaded from OEC Server and is available only after you log in successfully.

Also, there are several thousands of contracts, so I would not recommend to show them all in the combo box - you may want to show only nearest month Contract for each BaseContract .
HKusumakar79
Posts: 21
Joined: Feb 18, 2008


Posted: Mar 24, 2008 @ 08:26 AM             Msg. 5 of 9
Thanks for your suggestion.

Can you send me code to bind dropdownbox with contracts of any perticular group?

right now my code is like this :

---------------
IList<ContractListEntry> contracts = OECContracts.ConvertFromOECContractList();
//ContractList contracts = contractList.Contracts;

cbSymbol.ValueMember = "Symbol";
cbSymbol.DisplayMember = "Name";
cbSymbol.DropDownWidth = 200;

BindingSource bs = new BindingSource(contracts, "");
cbSymbol.DataSource = bs;

-----------------------

so send me the code like this only. i have once tried with oecclient object but it was showing me error "object reference not found in the object"
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Mar 24, 2008 @ 08:45 AM             Msg. 6 of 9
if you open the OEC API Example project source code, you can see following code there:

cbContract.Items.Clear();
cbContract.Items.AddRange( GetObjects( oecClient1.ContractGroups["Indices"].Contracts.Values ) );

(Form1.cs, line 141)
HKusumakar79
Posts: 21
Joined: Feb 18, 2008


Posted: Mar 25, 2008 @ 08:54 AM             Msg. 7 of 9
hi,

Yes you are right it is there in example but i am using advance example and it is not there and when i am using like simple example and putting oecClient1 object in advance example it is not even getting connection.

how to solvel this?
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Mar 25, 2008 @ 09:18 AM             Msg. 8 of 9
You can change code from advanced example:

file contracts.cs, line 23:

m_Contracts = OECClient.Global.ContractGroups["Indices"].Contracts.Values;

if you replace it to

m_Contracts = OECClient.Global.Contracts.Values;

you will have all available contracts there.
Edited by SergeK on Mar 25, 2008 at 09:19 AM
HKusumakar79
Posts: 21
Joined: Feb 18, 2008


Posted: Mar 25, 2008 @ 10:27 AM             Msg. 9 of 9
hi,

This is working.

Thank you thank you very much.