Hello There:
Is it possible to fech OHLCV data from TWS from short timeframes using ibridgepy?? with "short" I mean for example when a candlestick is one minute or two minutes, is it possible??
If so How do you do it??
Hi Ghery,
Yes, you can fetch OHLCV data using IBridgePy. You can use "request_historical_data()" function to do this. To get one-minute or two-minute candle data you can specify "barSize" parameter to 1 min or 2 min. Here is the link to the documentation of this function.
Thanks a lot, i really appreciate your help, but what I meant was… if it was possible to make an algorithm that actually shows me every single minute the OHLCV data of the previous minute… (barsize = 1 min). is it possible?? I am actually planning to use this for example to evaluate the Hurst exponent , as a criteria for a strategy …
If you actually see stocks like SGMA today…(december 10th, 2021) , I think the Hurst exponent and the ADX would be very usefull to trade this kind of stocks…
Hi Ghery,
When you are fetching data using "request_historical_data()" you must be storing it in a variable. You can use that variable to retrieve OHLCV data of the previous minute.
Let's see how you can do it.
# Fetch OHLC values of one minute timeframe
# Look back period is set to 5 days
df = request_historical_data(context.security, barSize='1m', goBack='5 D')
# Code below will give you the value of the current day
df.iloc[-1]
# Code below will give you the value of the previous day
df.iloc[-2]