Why `observer.array` so many `nan`?
-
Seems the
nan
count same to the nonnan
count, in other words, thenan
is a half of theobserver.array
. -
@asdasda Observer's
array
member actually refers to observers's first line (LineBuffer object)array
member. Thisarray
member is used internally for LineBuffer data storage and usually not used/accessed/manipulated directly unless one knows exactly what she/he is doing. In some cases it may be of larger size than loaded/filled data - in which case the extra size is filled wit nans. LineBuffer actually defines its own interface to access the underlyingarray
buffer ( for example it defines the currently active index, access to the past and future values, and many more)It is better to use a regular documented ways to access the line data. Please see the following docs:
https://www.backtrader.com/docu/concepts/#linesAlso the following post may be useful as well:
https://community.backtrader.com/topic/3921/zero-records-while-loading-data-from-csv/In case you really would like to access the internal buffer directly, please take a lool at the LineBuffer's implementation first:
https://github.com/mementum/backtrader/blob/master/backtrader/linebuffer.py -
@vladisld How can I access the full line data of
observer
aftercerebro.run()
? -