API Support Forum
OEC API > API Support > Price Feed
Author Topic: Price Feed
(19 messages, Page 1 of 1)
Moderators: VPfau
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 17, 2008 @ 01:56 PM             Msg. 1 of 19
Hi,
After talk on live help i get the login problem solved. Now i want to pick the Bid and Ask of contracts please tell me how i can get on event handle oecClient1_OnPriceChanged() is i need to pass the contract or it give me all contracts prices when it update.

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


Posted: Jun 17, 2008 @ 03:39 PM             Msg. 2 of 19
You need to subscribe for needed contracts, and then you will get an event per each contract update.
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 17, 2008 @ 03:43 PM             Msg. 3 of 19
How i can subscribe to the contracts. Do you have code samples or another sample in vb.net? I want that when everytick change it update data to sql database.

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


Posted: Jun 17, 2008 @ 03:47 PM             Msg. 4 of 19
to subscribe for every tick (trade) you need to call OECClient.SubscribeTicks and handle OnTicksReceived event.

to subscribe for bid/ask prices you need to call OECClient.Subscribe and handle OnPriceChanged event.
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 17, 2008 @ 03:50 PM             Msg. 5 of 19
I didn't got you. do you have sample in vb.net or vb?

i am using simple api example downlaoded from your website.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Jun 17, 2008 @ 03:54 PM             Msg. 6 of 19
please go to My Account section of this web site, then go to API Documentation page. You can download API samples and documentation.
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 17, 2008 @ 04:05 PM             Msg. 7 of 19
Hi Friend,
I downloaded but didn;t got it. I downloaded 2 advance and simple examples i am not seeing any function it it for seeing live bid and ask.

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


Posted: Jun 17, 2008 @ 04:28 PM             Msg. 8 of 19
OEC API Example, file Form1.cs, line 236:
oecClient1.Subscribe( c );

prices are subscribed for a contract currently selected in the combobox.

at line 220:

lbPrice.Text = string.Format( "Last {0}, Ask {1}, Bid {2}",
Contract.PriceToString( Contract.CurrentPrice.LastPrice ),
Contract.PriceToString( Contract.CurrentPrice.AskPrice ),
Contract.PriceToString( Contract.CurrentPrice.BidPrice ));

Bid/Ask price displayed
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 18, 2008 @ 12:52 AM             Msg. 9 of 19
Hi,
I see that code, But the main thing is that i didn't got any contract list after login . I am not getting list of contracts in cbcontract combo box. Is there anyway that we get all products prices without subscribing or selecting the contract it or we get one by one price?

Thanks
Zafar
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 18, 2008 @ 01:25 AM             Msg. 10 of 19
Hi,
It now shows me indicies,. I actually want that without selecting contracts symbols through combo box i get prices on everytick with symbol and it update into the database
So i actually call like

Contract.PriceToString( Contract.CurrentPrice.LastPrice ),
Contract.PriceToString( Contract.CurrentPrice.AskPrice ),
Contract.PriceToString( Contract.CurrentPrice.BidPrice )
//

Contract.PricetoString ( Contract.Name),

Something like that.

Thanks
Zafar
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 18, 2008 @ 06:32 AM             Msg. 11 of 19
Hi,
I am confused that i am only getting indicies in the list not the CME or Currencies exchange. I even logged in the trading station and subscribe it through that but not working. How i can activate the CME exchange for Feed.

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


Posted: Jun 18, 2008 @ 08:24 AM             Msg. 12 of 19
The sample is loading only indices contracts - see the method LoadContracts (Form1.cs, line 33). You can change it to load anything you need.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Jun 18, 2008 @ 08:30 AM             Msg. 13 of 19
Note that you should not call PriceToString for getting contract name - the method is used only to format price value to text representation, such as 1230.00 or 123 12/32.

There is no way to get prices for all products, and there is a limit of max 50 price subscriptions and max 5 tick subscriptions.
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 18, 2008 @ 08:31 AM             Msg. 14 of 19
Hi,
I changed the following code


private void LoadContracts()
{
foreach (OEC.API.BaseContract bc in oecClient1.ContractGroups["Indices"].BaseContracts)



if (bc.IsFuture)



oecClient1.RequestContracts( bc );


}

indicies to Currencies, indicies to Metals,indicies to Meats. But i am not getting these catagory pairs.When i add Indicies in the code it give me only indicis?
Is the price feed for CME or othre futures exchanges are live?

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


Posted: Jun 18, 2008 @ 08:47 AM             Msg. 15 of 19
please change line 150 to

cbContract.Items.AddRange( GetObjects( oecClient1.Contracts.Values ) );
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 18, 2008 @ 08:56 AM             Msg. 16 of 19
Now it is showing.
After selecting the pair on combo box is it update the rates automatic? and is these rates are real/live?

Thanks for your information.

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


Posted: Jun 18, 2008 @ 09:14 AM             Msg. 17 of 19
As you can see in the line 260, when selected value of the combo box is changed, price for the selected contract is subscribed.

Yes, the price data is live.
ZIqbal51
Posts: 13
Joined: Jun 17, 2008


Posted: Jun 18, 2008 @ 09:27 AM             Msg. 18 of 19
Thanks friend for that.
I want to know is that possible to have multiple logins of same account same time is it possible that one login account use for muliple applications same time same account?
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Jun 18, 2008 @ 09:45 AM             Msg. 19 of 19
Multiple connections for one login are not allowed.

To use one connection with multiple application you need to use remoting feature, which allow to share one API instance between different applications on the same machine.