Keyboard Shortcuts
Likes
Search
How should one request 6-months worth of historical 1-min stock data from Interactive Brokers API?
For getting historical data from Interactive Brokers APIs, how should the request be called if one wants multiple months (say 6) worth of 1-min stock data?
I came across the following: ?- [Step Sizes](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/#step-sizes). ? It seems to refer to the maximum data request time window for each data size (1min, 30min, 1hr, etc).? The linked table shows 1 Day duration for 1min bar size; does it mean for 1-min data, I can only get 1-day worth per request? But that will be only 390 (6.5 hours x 60 mins) bars. So for 6months worth, I have to send one request for each day?? - [Data type](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/#historical-whattoshow), so Trade, Bid, Ask prices are separate and I need to get each per request, so 3 requests and then combine them? Hence, I need to send 3 requests for each day, each day for 6 months? |
开云体育That documentation is very misleading. The crucial thing is that it says: ‘The following table exemplifies this concept’, ie the table is examples, not the only permissible possibilities. ? The table below is a comment extracted from my code, which shows the maximum durations I use for all the various allowable bar sizes. I determined these by trial and error. I haven’t updated it for several years, and it’s certainly not entirely correct now: for example I just had 13051 1-min bars returned in a single call using a duration of 30D. ? So I suggest you use the info below as a guide to what might be possible, but bear in mind that you may well be able to improve on this. Just try it and see! ? ? '?? Bar Size??????? Max Duration '?? --------??????? ------------ ' '?? 1 secs????????? 2000 S '?? 5 secs????????? 10000 S '?? 10 secs???????? 20000 S '?? 15 secs???????? 30000 S '?? 30 secs???????? 86400 S '?? 1 min?????????? 86400 S '?????????????????? 6 D '?????????????????? 1 W '?? 2 mins????????? 86400 S '?????????????????? 10 D '?????????????????? 2 W '?? 3 mins????????? 86400 S '?????????????????? 10 D '?????????????????? 2 W '?? 5 mins????????? 86400 S '?????????????????? 20 D '?????????????????? 3 W '?? 10 mins???????? 86400 S '?????????????????? 50 D '?????????????????? 8 W '?? 15 mins???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?? 20 mins???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?? 30 mins???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?????????????????? 3 M '?????????????????? 1 Y '?? 1 hour????????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?????????????????? 3 M '?? 2 hours???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?????????????????? 3 M '?? 3 hours???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?????????????????? 3 M '?? 4 hours???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?????????????????? 3 M '?? 8 hours???????? 86400 S '?????????????????? 50 D '?????????????????? 10 W '?????????????????? 3 M '?? 1 day?????????? 86400 S '?????????????????? 365 D '?????????????????? 12 M '?????????????????? 52 W '?????????????????? 50 Y '?? 1 W???????????? 86400 S '?????????????????? 365 D '?????????????????? 12 M '?????????????????? 52 W '?????????????????? 50 Y '?? 1 M???????????? 86400 S '?????????????????? 365 D '?????????????????? 12 M '?????????????????? 52 W '?????????????????? 50 Y ? |
开云体育What you are referring to is called ‘historical data pacing’. See the section before the Step Sizes section entitled ‘Pacing Violations for Small Bars (30 secs or less)Copy Location’. ? In the ‘old days’, IB imposed these stringent rules on all historical data requests, which greatly limited the usefulness of the Historical Data facility. ? This is all much more relaxed now. For example, I can download the past two days 1-minute data for all S&P 100 stocks in about 8 seconds. It may be that the rules referred to above still apply to 30-sec or smaller bars as stated, but I haven’t investigated this. ? So for purposes like backfilling a handful of charts with a couple of hundred bars, it’s generally problem free. ? However there are still pacing delays once you start to ‘bulk load’ historical data. For example Jürgen made this very interesting post that touched on this: ? ? I have similar observations: the data below shows the time a response was received with the number of seconds since the request. This was a couple of years ago (before Jürgen’s post) and I don’t recall exactly what I was doing, but it may have been trying to get 1-minute data for a whole year or something similar. You can see that the requests were completing at a rate of about 13 per minute, with the same sort of ‘pulsing’ that Jürgen described. I had intended to post about this to the group, but I never got round to doing a nice summary of it, and the data has been sitting in my Notepad++ ever since… ? So I think the takeaway here is that historical data is fine for relatively small amounts of data such as chart backfilling or priming indicators for an autotrading strategy, but abuse it and it gets too sluggish. If you need bulk historical data, get it from a specialist data provider. ? ? 10:59:44.446 0.7 10:59:45.256 0.7 10:59:45.984 0.6 10:59:46.729 0.6 10:59:50.403 3.6 10:59:51.131 0.6 10:59:56.414 5.2 10:59:57.161 0.7 11:00:02.426 5.2 11:00:08.310 5.8 11:00:14.310 5.9 11:00:26.386 12.0 11:00:44.301 17.8 11:00:45.075 0.6 11:00:45.796 0.6 11:00:46.668 0.8 11:00:50.314 3.6 11:00:51.016 0.6 11:00:56.295 5.1 11:00:57.189 0.8 11:01:02.304 5.0 11:01:03.064 0.7 11:01:08.416 5.2 11:01:20.314 11.8 11:01:32.296 11.9 11:01:44.406 12.0 11:01:45.135 0.6 11:01:45.853 0.6 11:01:46.602 0.6 11:01:50.396 3.7 11:01:51.115 0.6 11:01:56.421 5.2 11:01:57.129 0.6 11:02:02.412 5.2 11:02:08.306 5.8 11:02:14.307 5.9 11:02:26.310 11.9 11:02:44.325 17.9 11:02:45.023 0.6 11:02:45.731 0.6 11:02:46.623 0.8 11:02:50.303 3.6 11:02:51.359 1.0 11:02:56.441 5.0 11:02:57.157 0.6 11:03:02.410 5.2 11:03:08.307 5.8 11:03:20.243 11.8 11:03:32.299 12.0 11:03:44.419 11.6 11:03:45.168 0.7 11:03:45.952 0.7 11:03:46.701 0.7 11:03:50.427 3.6 11:03:51.137 0.6 11:03:56.413 5.2 11:03:57.129 0.6 11:04:02.413 5.2 11:04:08.312 5.8 11:04:14.318 5.8 11:04:26.321 11.9 11:04:44.306 17.9 11:04:45.103 0.6 11:04:45.805 0.6 11:04:46.516 0.6 11:04:50.305 3.7 11:04:51.090 0.6 11:04:56.315 5.1 11:04:57.069 0.6 11:05:02.302 5.1 11:05:03.037 0.6 11:05:08.414 5.3 11:05:20.306 11.8 11:05:32.304 11.9 11:05:44.419 12.0 11:05:45.161 0.6 11:05:45.870 0.6 11:05:46.572 0.6 11:05:50.408 3.7 11:05:51.151 0.6 11:05:56.419 5.2 11:05:57.210 0.7 11:06:02.406 5.1 11:06:08.322 5.8 11:06:14.308 5.9 11:06:26.312 11.9 11:06:44.315 17.9 11:06:45.036 0.6 11:06:45.751 0.6 11:06:46.461 0.6 11:06:50.306 3.7 11:06:51.037 0.6 11:06:56.308 5.2 11:06:57.023 0.6 11:07:02.307 5.2 11:07:03.071 0.7 11:07:08.428 5.3 11:07:20.311 11.8 11:07:32.310 11.9 11:07:44.424 12.0 11:07:45.173 0.7 11:07:45.939 0.6 11:07:46.640 0.6 11:07:50.411 3.7 11:07:51.142 0.6 11:07:56.431 4.9 11:07:57.155 0.6 11:08:02.418 5.2 11:08:08.349 5.8 11:08:14.313 5.9 11:08:26.372 12.0 11:08:44.349 17.9 11:08:45.182 0.7 11:08:45.891 0.6 11:08:46.640 0.6 11:08:50.316 3.6 11:08:51.040 0.6 11:08:56.311 5.1 11:08:57.046 0.6 11:09:02.318 5.2 11:09:03.044 0.6 11:09:08.424 5.3 11:09:20.310 11.8 11:09:32.311 11.9 11:09:44.427 12.0 11:09:45.168 0.6 11:09:45.954 0.6 11:09:46.769 0.7 11:09:50.444 3.6 11:09:51.224 0.7 11:09:56.425 5.1 11:09:57.148 0.6 11:10:02.423 5.2 11:10:08.384 5.9 11:10:14.325 5.9 11:10:26.311 11.9 11:10:44.313 17.9 11:10:45.033 0.6 11:10:45.738 0.6 11:10:46.442 0.6 11:10:50.314 3.8 11:10:51.058 0.6 11:10:56.366 5.2 11:10:57.119 0.7 11:11:02.321 5.1 11:11:03.048 0.6 11:11:08.424 5.3 11:11:20.326 11.8 11:11:32.332 11.9 11:11:44.424 12.0 11:11:45.145 0.6 11:11:45.873 0.6 11:11:46.717 0.7 11:11:50.415 3.6 11:11:51.135 0.6 11:11:56.426 5.2 11:12:02.346 5.8 11:12:03.087 0.6 11:12:08.432 5.2 11:12:20.330 11.8 11:12:32.391 12.0 11:12:44.431 11.9 11:12:45.136 0.6 11:12:45.842 0.6 11:12:46.556 0.6 11:12:50.432 3.8 11:12:51.163 0.6 11:12:56.432 4.4 11:12:57.147 0.6 11:13:02.438 5.2 11:13:08.355 5.8 11:13:14.329 5.9 11:13:26.334 11.9 11:13:44.334 17.9 11:13:45.049 0.6 11:13:45.753 0.6 11:13:46.469 0.6 11:13:50.334 3.8 11:13:51.239 0.8 11:13:56.323 5.0 11:13:57.022 0.6 11:14:02.324 5.2 11:14:03.028 0.6 11:14:08.444 5.3 11:14:14.353 5.8 11:14:26.325 11.9 11:14:44.362 17.9 11:14:45.108 0.7 11:14:45.839 0.6 11:14:46.569 0.6 11:14:50.335 3.7 11:14:51.034 0.6 11:14:56.330 5.2 11:14:57.216 0.8 11:15:02.339 5.0 11:15:03.050 0.6 11:15:08.446 5.3 11:15:20.352 11.8 11:15:32.323 11.9 11:15:44.437 12.0 11:15:45.149 0.6 11:15:45.536 0.3 11:15:46.243 0.6 11:15:50.365 4.0 11:15:51.162 0.6 11:15:56.332 5.1 11:15:57.041 0.6 11:16:02.331 5.2 11:16:03.039 0.6 11:16:08.531 5.4 11:16:20.336 11.7 11:16:32.344 11.9 11:16:44.452 12.0 11:16:45.165 0.6 11:16:45.870 0.6 11:16:46.575 0.6 11:16:50.523 3.8 11:16:51.247 0.6 11:16:56.478 5.1 11:16:57.214 0.6 11:17:02.439 5.1 11:17:08.338 5.8 11:17:14.382 5.9 11:17:26.334 11.8 11:17:44.329 17.9 11:17:45.023 0.6 11:17:45.773 0.6 11:17:46.499 0.6 11:17:50.344 3.8 11:17:51.031 0.6 11:17:56.330 5.2 11:17:57.039 0.6 11:18:02.524 5.4 11:18:03.276 0.7 11:18:08.442 5.1 11:18:20.337 11.8 11:18:32.342 11.9 11:18:44.448 12.0 11:18:45.153 0.6 11:18:45.868 0.6 11:18:46.622 0.6 11:18:50.441 3.7 11:18:51.158 0.6 11:18:56.444 5.2 11:18:57.165 0.6 11:19:02.439 5.2 11:19:08.377 5.8 11:19:14.327 5.8 11:19:26.331 11.9 11:19:44.364 17.9 11:19:45.098 0.6 11:19:45.829 0.6 11:19:46.551 0.6 11:19:50.335 3.7 11:19:51.034 0.6 11:19:56.335 5.2 11:19:57.051 0.6 11:20:02.336 5.2 11:20:03.090 0.6 11:20:08.492 5.3 11:20:20.342 11.8 11:20:32.336 11.9 11:20:44.449 12.0 11:20:45.265 0.7 11:20:45.988 0.6 11:20:50.441 4.4 11:20:51.217 0.7 11:20:56.363 5.0 11:20:57.075 0.6 11:21:02.343 5.2 11:21:03.049 0.6 11:21:08.441 5.3 11:21:20.377 11.8 11:21:32.344 11.9 11:21:44.450 12.0 11:21:45.159 0.6 11:21:45.863 0.6 11:21:46.586 0.6 11:21:50.442 3.8 11:21:51.133 0.6 11:21:56.450 5.2 11:21:57.184 0.6 11:22:02.442 5.2 11:22:08.349 5.8 11:22:14.339 5.9 11:22:26.371 11.9 11:22:44.329 17.9 11:22:45.051 0.6 11:22:45.755 0.6 11:22:46.483 0.6 11:22:50.332 3.7 11:22:51.043 0.6 11:22:56.330 5.2 11:22:57.033 0.6 11:23:02.358 5.2 11:23:03.080 0.6 11:23:08.468 5.3 11:23:20.326 11.8 11:23:32.350 11.9 11:23:44.453 12.0 11:23:45.186 0.6 11:23:45.893 0.6 11:23:46.616 0.6 11:23:50.442 3.7 11:23:51.140 0.6 11:23:56.446 5.2 11:23:57.160 0.6 11:24:02.449 5.2 11:24:08.353 5.7 11:24:14.336 5.9 11:24:26.331 11.9 11:24:44.331 17.9 11:24:45.043 0.6 11:24:45.778 0.6 11:24:46.499 0.6 11:24:50.322 3.7 11:24:51.021 0.6 11:24:56.334 5.2 11:24:57.228 0.8 11:25:02.369 5.1 11:25:03.080 0.6 11:25:08.439 5.3 11:25:20.328 11.8 11:25:32.325 11.9 11:25:44.480 12.1 11:25:45.236 0.7 11:25:45.942 0.6 11:25:46.652 0.6 11:25:50.432 3.7 11:25:51.137 0.6 11:25:56.440 5.2 11:25:57.150 0.6 11:26:02.434 5.2 11:26:08.334 5.8 11:26:14.351 5.9 11:26:26.331 11.8 11:26:44.339 17.9 11:26:45.039 0.6 11:26:45.800 0.7 11:26:46.559 0.7 11:26:50.373 3.7 11:26:51.109 0.6 11:26:56.347 5.1 11:26:57.068 0.6 11:27:02.330 5.2 11:27:03.041 0.6 11:27:08.448 5.3 11:27:20.328 11.8 11:27:32.334 11.9 11:27:44.460 12.0 11:27:45.179 0.6 11:27:45.891 0.6 11:27:46.616 0.6 11:27:50.433 3.7 11:27:51.136 0.6 11:27:56.477 5.2 11:27:57.180 0.6 11:28:02.452 5.2 11:28:08.330 5.8 11:28:14.331 5.9 11:28:26.346 11.9 11:28:44.334 17.9 11:28:45.032 0.6 11:28:45.814 0.7 11:28:46.528 0.6 11:28:50.340 3.7 11:28:51.032 0.6 11:28:56.333 5.2 11:28:57.045 0.6 11:29:02.365 5.2 11:29:03.073 0.6 11:29:08.446 5.3 11:29:20.341 11.8 11:29:32.335 11.9 11:29:44.448 12.0 11:29:45.152 0.6 11:29:45.870 0.6 11:29:46.611 0.6 11:29:50.434 3.7 11:29:51.140 0.6 11:29:56.448 5.2 11:29:57.165 0.6 11:30:02.436 5.2 11:30:08.349 5.8 11:30:14.334 5.9 11:30:26.455 12.0 11:30:44.339 17.4 11:30:45.030 0.6 11:30:45.814 0.7 11:30:46.515 0.6 11:30:50.340 3.7 11:30:51.046 0.6 11:30:56.333 5.1 11:30:57.218 0.8 11:31:02.338 5.0 11:31:03.044 0.6 11:31:08.442 5.3 11:31:20.337 11.8 11:33:36.387 11.9 11:33:37.166 0.6 11:33:37.902 0.6 11:33:38.631 0.6 11:33:39.327 0.6 11:33:43.137 3.7 11:33:43.863 0.6 11:33:49.150 5.2 11:33:49.927 0.6 11:33:55.151 5.1 11:34:01.075 5.8 11:34:07.034 5.9 11:34:19.052 11.9 11:34:37.046 17.9 11:34:37.768 0.6 11:34:38.477 0.6 11:34:39.184 0.6 11:34:43.032 3.7 11:34:43.744 0.6 11:34:49.040 5.2 11:34:49.751 0.6 11:34:55.039 5.2 11:34:55.865 0.7 11:35:01.134 5.2 11:35:13.049 11.8 11:35:25.045 11.9 11:35:37.179 12.0 11:35:37.904 0.6 11:35:38.616 0.6 11:35:39.334 0.6 11:35:43.137 3.7 11:35:43.853 0.6 11:35:49.160 5.2 11:35:49.912 0.6 11:35:55.131 5.1 11:36:01.049 5.8 11:36:07.056 5.9 11:36:19.045 11.9 11:36:37.063 17.9 11:36:37.756 0.6 11:36:38.483 0.6 11:36:39.244 0.7 11:36:43.081 3.7 11:36:43.780 0.6 11:36:49.055 5.2 11:36:49.750 0.6 11:36:55.052 5.2 11:36:55.886 0.7 11:37:01.144 5.2 11:37:13.049 11.8 11:37:25.045 11.9 11:37:37.200 12.0 11:37:37.917 0.6 11:37:38.629 0.6 11:37:39.347 0.6 11:37:43.146 3.7 11:37:43.923 0.7 11:37:49.158 5.1 11:37:49.915 0.6 11:37:55.155 5.1 11:38:01.044 5.8 11:38:07.332 6.2 11:38:19.084 11.7 11:38:37.057 17.9 11:38:37.779 0.6 |