Author |
Topic: When is current price available? (3 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
PDavies541 Posts: 21 Joined: Feb 01, 2013 |
Hi
I have been working on a project that re-used some code sent to me by your team which has been a great help. There is one problem that I can't seem to get around. Here is what I effectively need to do: 1 - Invoke a DLL from an OEC chart 2 - When I invoke the DLL, I send the last, high and low price of the session - that is one time at startup 3 -When the underlying instrument on the chart changes, I kill my DLL and invoke it again 4 - If the market is on line I send the current session values. When the market is off line, I send the closing price of the last session in the last, high and low. So - all this is working really well with the exception of one case. If I switch the indicator from YMM3, NQM3, ESM3, it works fine. If I try to switch to YMZ3, YMH4 - contracts that are not currently subscribed then it crashes when I try to access LastPrice, HighPrice or LowPrice. When it crashes, I can re-compile the indicator and this time it will work for the symbol it crashed on. I am subscribing to the contract but it seems that OEC is subscribing to certain commonly known contracts (current month for US stock indices, grains) on startup as they work. As soon as I try to load a contract a little further out or a slightly more exotic contract, it fails. I reproduced this issue with a small change to the domindicator.cs you send me - which is here: using System; Try running this & start changing to future contracts on NQ, YM, ES and you will see it starts outputting "Print in OSE Failed" messages in the log. You can see the code in the OnSymbolLookupReceived. It is almost as if I need to force it to load the contract data properly for those future month contracts but current month contracts work fine. Any thoughts? Thanks Pete Peter Davies |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Hello,
Requests to servers are asynchronous in OECAPI: it doesn't guarantee that ContractDOM.CurrentPrice will be defined on the next line after calling OEC.API.OECClient.Global.Subscribe method. If you need to monitor real-time quotes, it is better to hook OnPriceChanged or OnPriceTick events (http://www.openecry.com/api/api/html/4e2865e8-7ac9-457e-8d5a-6d930f3408a8.htm). Victor Vins Lead Software Developer |
||||
PDavies541 Posts: 21 Joined: Feb 01, 2013 |
OK - got it, many thanks!
Peter Davies |
||||