简体   繁体   中英

Is there a from and a to argument for reqHistoricalData in IBrokers?

How do I get historical data with an exact start and end date? It only has a "duration" parameter:

df <- reqHistoricalData(tws, Contract=contract, barSize = "1 day", duration = "2 M")

Can I do something like:

df <- reqHistoricalData(tws, Contract=contract, barSize = "1 day", from="2020-01-01", to="2020-02-01")

No. If you like you can write a function to do that and calculate the duration and just call the api function. Note that it will have to round the duration since only certain text values are allowed.

http://interactivebrokers.github.io/tws-api/historical_bars.html#hd_duration

Also make sure it is within limitations

https://interactivebrokers.github.io/tws-api/historical_limitations.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM