Get historical time data
-
Hi, Backtraders!
I want to get n bars back the current day as a pandas dataframe. Reading various topics in this forum I was able to do it for OHLCV data, but not for DateTime.
I'm using
self.data.datetime.get(size=self.n_bars, ago=0)
but I got just an array of float numbers instead of an array of datetimes.
I thought the float number could be transformed to datetime withdatetime.fromtimestamp(timestamp)
but the result was a very different time of what was supposed to be.So, I ask for help to know what that float number mean or more concretely how to get the last n bars of the datetime column.
Thanks in advance.
-
Because there are no datetime objects used inside the library.
See here (just 2 days old): https://community.backtrader.com/topic/1151/datetime-format-internally/
-
Thank you very much @backtrader. I didn't notice that thread. The solution works like a charm.