Questions and Answers about programming a Datafeed


Q. What value should I use for BarInterval when calling NSTSETVALUE function and any other functions that require BarInterval as a parameter

A. IN GENERAL:

1) If you are receiving OHLC data (DateTime/Open/High/Low/Close/Volume) for both historical and realtime data, then you would use Positive Bar Interval and send the 6 data values.

2) If you are receiving OHLC historical data (DateTime/Open/High/Low/Close/Volume), but the realtime updates are tick by tick data (Date/Price/Volume), then you would use a Negative Bar Interval and send three data values (Date/Time, Price, Volume), with the OHLC historical data being sent as one tick for the Open, one tick for the High, one tick for the Low and one tick for the Close as done in the data pump example).

3) If you are receiving tick data (Date/Time, Price, Volume) for both historical data and realtime data, then you would set the bar interval to zero and send the three data values.


Q. How do I change the Data Pump example code to mimic the different BarInterval scenarios described in the question above

A. To setup the data pump example to work in the same manner as it you will be receiving data, simply set “Private Const DATAMODE = ” to either 1, 2 or 3 as described in the question above. Also search for the constant DATAMODE, to see how it is used in code to change the bar interval, which in turn changes how the data is sent to the Data Pump.


Q. Where do I put the Data Pump calls?

A. It doesn’t matter where you call the NST Data Pump functions. Whether it is in your data sink procedure or some other procedure, it shouldn’t matter. However, in general we suggest taking our working data pump example and adding your data feed calls into that code one piece at a time, so you can test at each step and make sure something hasn’t been broken (and go back a step if needed to get it working again).


Q. Should the code sleep/pause between NSTCOMMITROW?

A. The Data Pump does not need to sleep (pause) between NSTCommitRows. You just keep feeding it the latest data as new ticks occur. If a new tick hasn’t occurred, then you don’t call the DataPump. If the sleep is something needed by your data feed to allow for time for more data to come in, then how long your thread should sleep is best answered by your data feed provider.


Q. How do the realtime updates work when receiving OHLC values as the updates instead of tick values?

A. Note that in the case of having OHLC for real time updates, that means that you keep sending it the OHLC values for the same date/time stamp over and over again as you receive the updates in your sink (obviously the open won’t change, the high/low may occasionaly change and the close could be different with each new tick and the volume will gradually increase as more ticks come in). Each time you update the same OHLC with the same date/time stamp, the red bar in NeuroShell Trader will change based upon the new values. Once the bar is complete and you start getting OHLC data for the next bar, you simply feed the Data Pump the next bars OHLC values with the new bar date/time value and the Data Pump will automatically turn the old red bar to green and start creating a new red bar based upon the new OHLC values that are being fed to the data pump.


Q. What do I do for 5 minute bars if all I have is tick data?

A. If all your data is tick data, both historical and realtime updates, then you shouldn’t do anything differently for 5 minute data than you would do for tick by tick data. When NeuroShell requests 5-minute data, then do the EXACT same thing you do with tick data and feed in all the ticks with each tick original time/date stamp with the same bar interval of 0. NeuroShell will then convert the tick data to 5-minute data. You do NOT need to preprocess the data, round the date/time to the nearest minute or anything else and in fact doing so will mess up NeuroShell’s trader ability to convert and display data correctly.

However, if you have minute data available (OHLC historical), then you would feed in the data differently than you do with tick data. For instance you would feed in 1-minute data with a bar Interval of either 1 (if you have OHLC realtime updates) or a bar interval of -1 (if you have just tick by tick realtime updates). In either case, you would feed in the Date, Open, High, Low, Close and Volume once for each minute bar using the timestamp of the minute bar.

Note that if you do have historical minute bar data available, it is preferable to use the minute data when NeuroShell requests minute bars and the tick data when NeuroShell requests tick bars from a speed and memory usage standpoint. However, if all you have is tick by tick data available, then when NeuroShell Trader requests either minute or tick bars, then go ahead and feed in the tick data with a bar interval of 0 in both cases and NeuroShell Trader will convert the tick by tick data appropriately in either case.


Q. I have a datapump I use to send in daily data. I have been trying to have the chart automatically update and send new data for the next day after the market closes. It doesnt seem to appear. Does the engine prevent showing the daily data until the next day?

A. If all the data is passed in with a date only and no time, then it assumes a midnight expiration. If you send in a time with the date (for example 1/21/2001 4:00pm), then the red bar should turn into a green bar at that time.


Q. what is the differerence between interval=0 and interval negative?

A. There are three situations:

Zero bar interval is used if BOTH historical data and real time updates are in tick by tick form (Date/Time, Price, Volume)

Negative bar interval is used if historical data is in OHLC form and real time updates are in tick by tick form.

Positive bar interval is used if historical data AND real time updates are in OHLC form.


Q. As a general rule, should I expect that, regardless of interval, 1 call will be made of my data provider every time data regarding one of my ticker symbols is requested? Are the number of charts or the number of instances of the ticker in a chart also factors in the number of calls that I should expect to be made of my data provider?

Below are several scenarios that I am curious about:

1) 10 different tickers are represented on the same chart. When a user refreshes the chart, how many calls will be made to the data provider? Will there be 10 calls, or is there a way to reduce the number of calls to 1?

2) 1 ticker is represented on the same chart in 10 different calculations (indicators, trading strategies, etc). When a user refreshes the chart, how many calls will be made to the data provider?

3) 1 ticker (the same ticker) is represented on 10 different charts. When a user refreshes the charts, how many calls will be made to the data provider? 1 call or 10?

4) 1000 different charts each have a single, unique ticker (said differently: 1k distinct tickers are represented individually on 1k distinct charts). Will refreshing these 1k charts result in 1k calls made to my data provider, or is it possible to reduce the request to a single call?

A. There is one data request per ticker and frequency combination for historical data from the data pump. You will be responsible for updating the data pump with incoming real time data however you chose to get that data (assuming you are going to use realtime data). Refreshing charts does not rerequest data from the data pump. Regarding your scenarios:

1) There will be 10 different calls from the data pump for each of the different tickers when the chart loads. Data refreshes do not rerequest data from the data pump. Updating the data pump with the most recent incoming realtime data is the responsibility of the application.

2) There will be 1 call from the data pump for the ticker when the chart loads.

3) There will be 1 call from the data pump for the ticker on the first chart when the first chart loads. Subsequent charts will not request data again unless they require data farther back in time than was requested by the earlier chart(s).

4) There will be 1 call from the data pump for the ticker on the first chart when the first chart loads. Subsequent charts will not request data again unless they require data farther back in time than was requested by the earlier chart(s).


Q. Suppose I have two different style charts, minute and tick, that can be updated from a single stream of tick data. The problem is that the incoming stream of tick data needs to be set to either minute or tick format. Is there a way where my pushing in one quote will update both formats?

A. No, the data pump doesnt update multiple data streams (minute, tick, etc) with a single update. So what is required is that your app remember which streams are currently open for each ticker and update all the appropriate streams with each new tick value. So for instance if there is a tick stream (0), a 1-minute stream (-1) and an hourly stream (-60) for ticker XYZ, then the app would have to update all 3 streams with each incoming XYZ tick by making NSTSetValues for date, close and volume plus the final NSTCommitRow for each of the 3 different bar intervals (0, -1, -60)


Q. I have a tick data chart. While it was collecting data I reset the chart start date back to an earlier date and I am now seeing strange spikes in the historical tick data. It looks like current price levels are showing up in the older data.

A. Tick data needs to be feed in from earliest date to latest date with no out of order dates/times. If you have a realtime update thread that runs at the same time as a historical thread, then you need to make sure all the historical ticks are uploaded before the realtime ticks start being uploaded. So when reloading the tick data to a date farther back in time, depending upon how the timing between your historical load and realtime updates work, you may need to collect the realtime updates in some array and then just after the historical data is uploaded to the Data Pump, send the collected (and non historical duplicates) to the data pump.

Was this article helpful?

Related Articles