For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Indexing a list in the same manner as backtrader
-
Hello,
I have a list of values. In order to be consistent with the platform, I would like to access the most recent value a 0, second most recent as -1 and so on as describes in the concepts section below.https://www.backtrader.com/docu/concepts.html#indexing-0-and-1
How can I implement something similar on my list? I can append to the front of the list to access 0 as the most recent but I am not sure how to get -1 not to point to the end of the list.
-
Try
len(array) - 1 + your_index
- For
0
that islen(array) - 1
(which is the last element) - For
-1
that islen(arry) - 1 - 1
(which is the element before the last element)
And so on
- For