[R-SIG-Finance] using reqHistoricalData

Stephen Choularton stephen at organicfoodmarkets.com.au
Tue Mar 27 22:41:41 CEST 2018


Hi

I am using this call to obtain the historical data for the SNFE SPI 
future contract.  Here is the full code I am using:

library("IBrokers")
closeAllConnections()

# IBrokersRef()

tws <- twsConnect()
reqCurrentTime(tws)



#contract <- twsFuture('SPI', exch='SNFE', expiry="201703", currency="AUD",|include_expired='1'|)

contract <- twsFuture('SPI', exch='SNFE', expiry="201803", 
currency="AUD", |include_expired='1'|)

reqContractDetails(tws, contract)


Sys.sleep(10) # mandatory 10s between request to avoid IB pacing violation
reqHistoricalData(tws, contract, barSize = "1 day", endDateTime='20180315 16:00:00', duration = "6 M")

and I get this result:

waiting for TWS reply on SPI ...... done.
            APH8.Open APH8.High APH8.Low APH8.Close APH8.Volume APH8.WAP 
APH8.hasGaps APH8.Count
2017-09-19      5650      5650     5650       5650           2 
5650.00            0          1
2017-10-03      5622      5622     5622       5622           2 
5622.00            0          1
2017-10-16      5774      5774     5774       5772           1 
5774.00            0          1
2017-11-28      5930      5953     5930       5953           3 
5937.65            0          2
2017-12-04      5948      5948     5948       5941           1 
5948.00            0          1
2017-12-06      5909      5909     5909       5909           1 
5909.00            0          1
2017-12-08      5960      5960     5948       5948           6 
5952.00            0          3
2017-12-11      5970      5970     5951       5951          11 
5968.25            0          7
2017-12-12      5958      5974     5952       5970         173 
5965.10            0        108
2017-12-13      5959      5982     5957       5975          81 
5973.15            0         49
2017-12-14      5982      6012     5962       5964         425 
5976.55            0        234
2017-12-15      5958      5986     5940       5957         245 
5953.70            0        184
2017-12-16      5953      5988     5953       5980         115 
5971.60            0         82
2017-12-18      5986      5994     5970       5989        1827 
5988.85            0       1012
2017-12-19      5988      6042     5988       6029        7575 
6027.75            0       4799
2017-12-20      6032      6046     6005       6036       16735 
6030.70            0      10465
2017-12-21      6036      6045     6007       6013       24219 
6017.80            0      16695
2017-12-22      6013      6045     6013       6026       18950 
6029.10            0      13816
2017-12-27      6019      6050     6011       6022       15864 
6029.60            0      11133
2017-12-28      6022      6052     6013       6046       21516 
6034.70            0      15445
2017-12-29      6045      6052     6008       6019       24757 
6028.20            0      17056
2018-01-02      6019      6033     5987       6022       19624 
6012.05            0      14487
2018-01-03      6023      6035     6005       6031       25104 
6023.40            0      18833
2018-01-04      6031      6065     6021       6024       30502 
6037.50            0      22464
2018-01-05      6026      6082     6024       6073       29123 
6064.45            0      19788
2018-01-06      6075      6101     6070       6092        6075 
6087.55            0       4696
2018-01-08      6095      6104     6079       6081       16224 
6086.90            0      12149
2018-01-09      6079      6105     6072       6088       25272 
6091.85            0      19091
2018-01-10      6089      6114     6044       6046       39228 
6072.60            0      27930
2018-01-11      6050      6055     6004       6012       38948 
6024.40            0      27751
2018-01-12      6011      6038     6001       6017       26643 
6021.65            0      19102
2018-01-13      6020      6054     6017       6049        7186 
6033.15            0       5817
2018-01-15      6059      6060     6023       6026       16203 
6036.50            0      11591
2018-01-16      6028      6030     5990       5991       25578 
6007.20            0      18025
2018-01-17      5994      6015     5945       5959       37579 
5974.70            0      26430
2018-01-18      5960      5985     5937       5951       31683 
5965.85            0      22749
2018-01-19      5948      5977     5946       5949       28451 
5960.65            0      20903
2018-01-20      5949      5981     5949       5980        8208 
5964.80            0       6587
2018-01-22      5973      5973     5933       5938       23302 
5948.30            0      16328
2018-01-23      5942      5990     5940       5986       27435 
5973.75            0      19193
2018-01-24      5989      6012     5981       6000       28456 
5998.90            0      20244
2018-01-25      6000      6009     5962       5999       31679 
5989.05            0      22431
2018-01-26      6000      6007     5976       5985        8956 
5991.10            0       6967
2018-01-27      5987      6016     5987       6015        6021 
6003.15            0       4643
2018-01-29      6020      6033     5999       6010       20523 
6018.10            0      14757
2018-01-30      6008      6020     5958       5960       36140 
5982.90            0      24692
2018-01-31      5961      5987     5920       5980       40809 
5960.15            0      28947
2018-02-01      5979      6038     5968       6037       39409 
6012.55            0      27264
2018-02-02      6037      6072     5999       6071       39430 
6039.40            0      28450
2018-02-03      6064      6071     5997       6006       16093 
6033.60            0      13032
2018-02-05      6002      6002     5958       5961       42093 
5976.80            0      27624
2018-02-06      5960      5965     5732       5763      123888 
5810.20            0      89853
2018-02-07      5789      5881     5732       5790       91626 
5819.55            0      67673
2018-02-08      5776      5851     5761       5810       55014 
5805.05            0      41684
2018-02-09      5814      5818     5681       5749       68010 
5761.95            0      51281
2018-02-10      5756      5767     5605       5724       26899 
5701.90            0      21716
2018-02-12      5735      5776     5724       5741       36295 
5748.25            0      25397
2018-02-13      5745      5805     5715       5792       48076 
5773.95            0      34088
2018-02-14      5794      5817     5770       5790       39991 
5794.55            0      29662
2018-02-15      5790      5869     5746       5863       44764 
5829.65            0      32971
2018-02-16      5864      5892     5845       5857       34515 
5868.05            0      25492
2018-02-17      5858      5878     5838       5850       10587 
5857.30            0       8843
2018-02-19      5863      5909     5841       5903       24088 
5888.25            0      17265
2018-02-20      5905      5906     5855       5905       27148 
5886.75            0      20262
2018-02-21      5899      5919     5864       5915       36287 
5895.35            0      26784
2018-02-22      5916      5967     5891       5914       39681 
5919.00            0      28694
2018-02-23      5912      5985     5907       5973       37903 
5955.25            0      27725
2018-02-24      5976      6004     5967       6004        7494 
5981.35            0       5928
2018-02-26      6005      6016     5993       6015       26766 
6005.75            0      17412
2018-02-27      6012      6059     6010       6036       37704 
6041.30            0      25322
2018-02-28      6037      6049     5991       6000       43430 
6010.05            0      29415
2018-03-01      6000      6017     5939       5961       42065 
5964.65            0      29407
2018-03-02      5966      5984     5883       5911       55735 
5920.85            0      40967
2018-03-03      5911      5925     5866       5924       14438 
5894.75            0      11996
2018-03-05      5928      5929     5866       5884       27914 
5886.75            0      19864
2018-03-06      5885      5969     5864       5954       42388 
5939.05            0      29752
2018-03-07      5958      5990     5883       5897       43885 
5921.85            0      30871
2018-03-08      5894      5943     5886       5939       41921 
5925.25            0      29409
2018-03-09      5942      5980     5927       5963       36634 
5959.15            0      25163
2018-03-10      5966      6020     5958       6020       11155 
5987.10            0       8263
2018-03-12      6029      6032     5986       5989       28166 
6007.95            0      17869
2018-03-13      5992      6011     5948       5967       26778 
5975.45            0      18867
2018-03-14      5969      5990     5921       5937       17305 
5941.85            0      13060
2018-03-15      5940      5962     5924       5924        2414 
5943.70            0       1761

I presume in the early period there were not transactions every day but 
as the volume picks up I notice the data seems to miss Sundays.

I thought these were continuous contracts (24/7) so I'm worried I have 
some setting wrong.  Maybe someone more familiar with the function can 
advise.

Thanks.
----------------------------------------------------------------------------------------------------------------------------------- 

Stephen Choularton PhD, FIoD



More information about the R-SIG-Finance mailing list