Profile Picture

Get opening price of minute bar BEFORE bar is complete?

Posted By rekab 6 Years Ago
Message
Posted Friday December 16 2011
Hi,

I'm trying to get the opening price of the current minute bar before the bar is complete. If I use Bars.Current.Open, I get the open of the last complete bar, but I can see in my live charts that RE knows the opening price of the currently developing minute bar as soon as the first tick comes in. How do I access it?
Posted Friday December 16 2011
Figured it out:
SystemData.Bars[SystemData.GetSymbolByName("MSFT")].PartialItem.Open;
Posted Monday February 27 2012
does PartialItem.Open return the 1st tick received by RE during the day or the open print for the stock on that day, assuming we are using daily bars? The IB api group told me that there is an open tick to indicate the open price.

Thanks, Duane
Posted Tuesday March 06 2012
I tested this with IB and PartialItem.Open is Not the open price for the day.

Please advise on how this can be fixed for live systems. Per the post above, the IB data feed should have a tick labeled Open for the open tick of the day.

Thanks, Duane
Posted Thursday March 08 2012
The daily open tick won't affect how the bars are built, but it should be sent to your system. In your NewTick method, check for a tick type of TickType.OpenPrice. Then you can store the value and refer to it later.

Thanks,
Daniel
Posted Wednesday April 11 2012
For whatever reason, storing the open price during NewTick sometimes results in price of 0. Also, there is the issue of obtaining the open price when the system is started after the market has opened.

I was able to use RequestMarketData via the tws interface although the solution took several hours to work out. Which leads me to several questions:

1.   Is the broker plugin, e.g. TWSPlugin, instantiated twice, once during the “Start Data Feed” and a second time when the system is started?
2.   If yes to #1, can this be simplified into a single instance such as a singleton? This would be advantageous since some members, e.g. “watchedSymbols” are currently not available after the system is started.
3.   I’m currently using GetShares to pass in the symbol to the plugin since I can’t access RequestMarketData directly via the system. While the solution works, it adds functionality to an already existing method. To access the broker plugin directly, would it be possible to add a method to the broker interfaces that accepts an object? This will allow the system code to interact directly with the plugin to implement functionality not yet available.
4.   Is there a simpler way to obtain open price (for the day) via the system code? I see open price correctly displayed in the Live Data pane but it is different in the system. #3 is still a request because this functionality would be helpful in general.
5. Is the functionality of SystemData.Bars[symbol].PartialItem.Open different between sim and live? In sim, it is pointing to the current day open.

Thanks, Duane

Edited: Wednesday April 11 2012 by alpha23
Posted Tuesday April 17 2012
Is the open price zero because the OpenPrice tick isn't being received by the system, or because it is being received but the price with it is zero. I suspect that what is happening is that the TWS plugin only sends the daily open when it first connects, so if live data is already running when you start the system then you won't get the open price.

As to your questions:

1. The plugin is instantiated twice, once for the data feed and once for the broker functions. (Of course if you use different plugins for these functions than each plugin would be instantiated once.)
2. It would not be easy to do this. The data plugin runs in the main AppDomain, and the broker plugin runs in the system AppDomain.
3. I'd suggest creating a singleton for your broker plugin (ie a public static property that is set when the class is created). Then you can reference the broker plugin from your system, and call any public methods you add to it via the singleton instance. (Because the data plugin runs in a different AppDomain, the singleton your system sees will be the broker instance, not the data instance.)
4. I think for the open price, the best thing to do is probably to have the broker plugin re-send the open price periodically. That way if your system isn't running when it first happens, it will still get the value later.
5. It's the same. When running live it's the first tick that the system has received for that day. In simulation mode it's based on what is in the data store.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems