I found that is possible to retrieve historical data from IB from R using the IBrokers package. However, their website states that the data only goes up to one year back? thus, is it possible to loop so I get for example a 10 year period.
I found that it doesn't make sense to use IB for this since there are better alternatives to retrieve data which are not for free either.