Base class for data series. A data series is an abstraction used to manage historical data.
Note
This is a base class and should not be used directly.
Returns the value at a given position/slice. It raises IndexError if the position is invalid, or TypeError if the key type is invalid.
Returns the number of elements in the data series.
list of weak references to the object (if defined)
A sequence based DataSeries.
Parameters: | values (list.) – The values that this DataSeries will hold. If its None, an empty list is used. Note that the list is not cloned and it takes ownership of it. |
---|
Appends a value.
A DataSeries of pyalgotrade.bar.Bar instances.
Returns a DataSeries with the adjusted close prices.
Returns a DataSeries with the close prices.
Returns a DataSeries with the high prices.
Returns a DataSeries with the low prices.
Returns a DataSeries with the open prices.
Returns a DataSeries with the volume.
from pyalgotrade import dataseries
# Build a sequence based DataSeries.
ds = dataseries.SequenceDataSeries(range(0, 50))
# Get the last value.
print ds[49]
print ds[-1]
# Get the previous value.
print ds[48]
print ds[-2]
# Get the first value.
print ds[0]
print ds[-50]
# Get the last 3 values.
print ds[-3:]
The output should be:
49
49
48
48
0
0
[47, 48, 49]