Reqeust historical data problem (TWS API)

APItrader

Newbie
Messages
3
Likes
0
Hi,

I have a question about the TWS API.

What I need to do is to detect exactly when a new minutebars is avaliable which should be in the below scenario 23:13:00. So I have to request
a new minute bar for 23:13:00 for the 2 symbols below.(MSFT,IBM)

(0)20110416 23:12:22,22.83
(0)20110416 23:13:00,22.84
(0)finished-20110416 23:12:22-20110416 23:13:22,-1
(1)20110416 23:12:22,160.3
(1)20110416 23:13:00,160.3
(1)finished-20110416 23:12:22-20110416 23:13:22,-1

Now I can just click button1 and when I do that I get the below lines.

My questions are:

1. Why do I receive 3 lines per symbol? I beleive I only are interested in: 23:13:00,22.84 ?
Because I dont want to request 3 lines as it is unnessecary(BandWidth and request limitations, is it possible to only request the line I need?)

2. Later I will need to request 500 symbols at the same time. I know that the TWS API has a limit of 100 realtime symbols(Tick data).
But this should be a historical request which means practically that I will request 500 symbols last minute data perheps 1 millisecond after
it is avaliable.

How can I do this the best way with the avaliable events in the TWS API?

I will be very happy for any assitance. Thank you!

Code:
private AxTWSLib.AxTws Tws1;
        private void button3_Click(object sender, EventArgs e)
        {
            //Connect to TWS
            Tws1 = new AxTWSLib.AxTws();
            Tws1.BeginInit();
            Tws1.Enabled = true;
            Tws1.Location = new System.Drawing.Point(32, 664);
            Tws1.Name = "Tws1";
            Controls.Add(Tws1);
            Tws1.EndInit();
            Tws1.connect("127.0.0.1", 7496, 0);



            //How to Request 1 minute bars for those 2 JUST WHEN a new update is avaliable?
            Tws1.reqHistoricalData(0, "MSFT", "STK", "", 0, "", "", "SMART", "USD", 0, "", "60 S", "1 min", "TRADES", 1, 1);
            Tws1.reqHistoricalData(1, "IBM", "STK", "", 0, "", "", "SMART", "USD", 0, "", "60 S", "1 min", "TRADES", 1, 1);
           
            

            Tws1.historicalData -= new AxTWSLib._DTwsEvents_historicalDataEventHandler(this.historicalData22);//Delete current memory before filling
            Tws1.historicalData += new AxTWSLib._DTwsEvents_historicalDataEventHandler(this.historicalData22);

        }

        private void historicalData22(object sender, AxTWSLib._DTwsEvents_historicalDataEvent e)
        {
            String getInfo = "(" + e.reqId + ")" + e.date + "," + e.close;
            listBox1.Items.Add(getInfo);
        }
 
1.That is just the format IB use for historical data.
Ideally the IB realtime data would support 1min bars, which would be exactly what you want as it would send you 1 line of bar data at the close of every minute. But i think it only supports 5 second bars at the moment.

2.IB enforce pacing restrictions on historical data, no way you will be able to get data for 500 symbols quickly. More like 20 or 30 symbols is all you will get in one burst. Then you have to pace yourself for X seconds before your next request.

IB are a broker not a data provider. You might want to find a 3rd party data provider that will meet your requirements. Obviously that is going to cost you extra.
 
Top