API Support Forum
OEC API > API Support > price is not updated
Author Topic: price is not updated
(18 messages, Page 1 of 1)
Moderators: VPfau
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 22, 2009 @ 03:06 PM             Msg. 1 of 18
Hello,
I've recently encountered a problem where the price is not updated anymore after some period of time the application (the sample one) runs.
If I restart the application the price is being updated again.
This happened to me in the last few days, and never happened before.
Is there a way to check when was the last time the price has changed?
If so, it should be done in some sort of event, right?

I appreciate your help on that,

YBar
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Sep 24, 2009 @ 08:28 AM             Msg. 2 of 18
you can look at Price.LastDateTime property - it holds the timestamp of the last trade.
Could you please tell us more details about the problem - what server you were connected to, under what login, what contracts and what subscription types you are using, and possible time when updates were stopped?
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 24, 2009 @ 04:51 PM             Msg. 3 of 18
Hi,

It happened again today at 09:50:05 ET.
I would like to check Price.LastDateTime, but since the whole API is event based, I woudn't know under which event should I check it. Should I set some timer? which event would you suggest to place this check under?

Requested details:
server used:api.openecry.com , 9200
Login: YBar
Contracts: FDAX
Subscription type: I'm using the code sample (oecClient1.Subscribe(c);)


Your help is much appreciated!
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 08:34 AM             Msg. 4 of 18
Hi Guys,

I continue to debug this problem ( It happened again today at 6:46ET), looks like the login event is fired but I guess the subscription is not renewed, eventhough the contract is still there in the combo-box (in the GUI).
any suggestions?

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


Posted: Sep 28, 2009 @ 08:40 AM             Msg. 5 of 18
In case of reconnect (OnLoginComplete event) it is application responsibility to re-estabilish all subscriptions.

OnPriceChanged event is fired for every quote update.
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 08:51 AM             Msg. 6 of 18
ok, so what I did is place this code in the OnLoginComplete event handler:
//////////////////////////////////////////////////////////
OEC.API.Contract c = cbContract.SelectedItem as OEC.API.Contract;
myContract = c;
myContractWasSet = 1;
if (c != null)
{
if (c.CurrentPrice == null)
{
oecClient1.Subscribe(c);
}
else
{
UpdatePrice(c);
}
}
//////////////////////////////////////////////////////////

However, today at 6:46ET the price stopped updating. I would appreciate any suggestion on how to debug this.

Thanks!
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 02:40 PM             Msg. 7 of 18
Hi again,
while debugging, I notice that in the piece of code mentinoed above c == null, which means that for some reason nothing in the combo-box is selected (although I can see the desired contract highlighted there!).
Is there a way to subscribe to my desired contract directly, without refering to the contract from the combo-box???

thanks!
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Sep 28, 2009 @ 02:43 PM             Msg. 8 of 18
You need to get contracts from the OECClient.Contracts collection.
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 03:05 PM             Msg. 9 of 18
ok. so what i do is this:
the login event handler takes care of doing LoadContracts();
then i wait for the OnContractsChanged event, there i subscribe to my contract using this code:

OEC.API.Contract c = oecClient1.Contracts["ESZ9"];
if (c != null)
{
if (c.CurrentPrice == null)
oecClient1.Subscribe(c);
else
UpdatePrice(c);
}


does it look ok to you?
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Sep 28, 2009 @ 03:17 PM             Msg. 10 of 18
this might work if you make sure you did not unsubscribe somewhere else.
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 03:24 PM             Msg. 11 of 18
unfortunatly it didn't work, c is still null..
how can I get the contract again???
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Sep 28, 2009 @ 03:28 PM             Msg. 12 of 18
Please check how do you load contracts.
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 03:39 PM             Msg. 13 of 18
I tried using:
OEC.API.BaseContract bc = oecClient1.BaseContracts["ES"];
OEC.API.Contract tryc = bc.GetNearestContract();

untortunaly, bc == null, so now i'm quite loss, what else can I try?

Thanks
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Sep 28, 2009 @ 03:58 PM             Msg. 14 of 18
I also found out that the only contracts in the base contract list are 5 CCI-*** contracts, where are the other ones?
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Oct 01, 2009 @ 01:59 PM             Msg. 15 of 18
Guys, I'm realy lost here.

today, after 3 days it worked fine, at 8:17ET I lost connection again. The application received the onLoginComplete event, and then onContractsChanged event. But I didn't get the onPriceChanged event, so prices are not updated.

Do someone have an idea what else can I try?

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


Posted: Oct 01, 2009 @ 02:02 PM             Msg. 16 of 18
please make sure you didn't store contract instances between sessions. API creates new contracts every time in logs on (OnLoginComplete event).
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Oct 01, 2009 @ 02:17 PM             Msg. 17 of 18
Hi SergeK,
I'm quite sure I didn't, but could you please give me an example of when could i've done so? does it appear on the example code? my application is mostly based on that example.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Oct 06, 2009 @ 10:09 AM             Msg. 18 of 18
try to debug your code and see what actually happens on reconnect. You are supposed to download contracts and then subscribe for the contract every time you are logging in - even if you were connected before.