Referencing the first day in a Data
-
Hi,
I am trying to reference the first day in a data that I have. I want to do this in order to get all time highs and other relevant indicators. This is usually an issue with stocks that have had an IPO after the date my algo filters for. So if I am filtering stocks for the last three years, if something had an IPO a year ago, then I have no way of referencing the first traded day it had.
I looked through the documentation about backtrader's slicing/indexing and it seems this is something that isnt supported?
Any suggestions @backtrader or anyone else?
-
@rstrong said in Referencing the first day in a Data:
I looked through the documentation about backtrader's slicing/indexing and it seems this is something that isnt supported?
Following Docs - Platform Concepts and Indexing: 0 and -1 you just have to count backwards.
-1
is the previous bar (i.e.: one bar ago),-2
is two bars ago, hencefirstday = data[len(data) - 1]
-
@backtrader wow that seems so obvious now haha Thanks