Author |
Topic: price is not updated (18 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
YBar Posts: 24 Joined: Dec 01, 2008 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
You need to get contracts from the OECClient.Contracts collection.
|
||||
YBar Posts: 24 Joined: Dec 01, 2008 |
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 |
this might work if you make sure you did not unsubscribe somewhere else.
|
||||
YBar Posts: 24 Joined: Dec 01, 2008 |
unfortunatly it didn't work, c is still null..
how can I get the contract again??? |
||||
SergeK -Developer- Posts: 475 Joined: Jan 26, 2007 |
Please check how do you load contracts.
|
||||
YBar Posts: 24 Joined: Dec 01, 2008 |
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 |
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 |
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 |
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 |
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 |
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.
|
||||