dataseries – Basic dataseries classes

Data series are abstractions used to manage time-series data.

class pyalgotrade.dataseries.DataSeries

Bases: object

Base class for data series.

Note

This is a base class and should not be used directly.

__getitem__(key)

Returns the value at a given position/slice. It raises IndexError if the position is invalid, or TypeError if the key type is invalid.

__len__()

Returns the number of elements in the data series.

__weakref__

list of weak references to the object (if defined)

getDateTimes()

Returns a list of datetime.datetime associated with each value.

class pyalgotrade.dataseries.SequenceDataSeries(maxLen=1024)

Bases: pyalgotrade.dataseries.DataSeries

A DataSeries that holds values in a sequence in memory.

Parameters:maxLen (int.) – The maximum number of values to hold. If not None, it must be greater than 0. Once a bounded length is full, when new items are added, a corresponding number of items are discarded from the opposite end.
append(value)

Appends a value.

appendWithDateTime(dateTime, value)

Appends a value with an associated datetime.

Note

If dateTime is not None, it must be greater than the last one.

getMaxLen()

Returns the maximum number of values to hold.

setMaxLen(maxLen)

Sets the maximum number of values to hold and resizes accordingly if necessary.

pyalgotrade.dataseries.aligned.datetime_aligned(ds1, ds2, maxLen=1024)

Returns two dataseries that exhibit only those values whose datetimes are in both dataseries.

Parameters:
  • ds1 (DataSeries.) – A DataSeries instance.
  • ds2 (DataSeries.) – A DataSeries instance.
  • maxLen (int.) – The maximum number of values to hold for the returned DataSeries. If not None, it must be greater than 0. Once a bounded length is full, when new items are added, a corresponding number of items are discarded from the opposite end.
class pyalgotrade.dataseries.bards.BarDataSeries(maxLen=1024)

Bases: pyalgotrade.dataseries.SequenceDataSeries

A DataSeries of pyalgotrade.bar.Bar instances.

Parameters:maxLen (int.) – The maximum number of values to hold. If not None, it must be greater than 0. Once a bounded length is full, when new items are added, a corresponding number of items are discarded from the opposite end.
getAdjCloseDataSeries()

Returns a pyalgotrade.dataseries.DataSeries with the adjusted close prices.

getCloseDataSeries()

Returns a pyalgotrade.dataseries.DataSeries with the close prices.

getHighDataSeries()

Returns a pyalgotrade.dataseries.DataSeries with the high prices.

getLowDataSeries()

Returns a pyalgotrade.dataseries.DataSeries with the low prices.

getOpenDataSeries()

Returns a pyalgotrade.dataseries.DataSeries with the open prices.

getVolumeDataSeries()

Returns a pyalgotrade.dataseries.DataSeries with the volume.

class pyalgotrade.dataseries.resampled.ResampledBarDataSeries(dataSeries, frequency, maxLen=1024)

Bases: pyalgotrade.dataseries.bards.BarDataSeries

A BarDataSeries that will build on top of another, higher frequency, BarDataSeries.

Parameters:
  • dataSeries (pyalgotrade.dataseries.bards.BarDataSeries.) – The DataSeries instance being resampled.
  • frequency – The grouping frequency.
  • maxLen (int.) – The maximum number of values to hold. If not None, it must be greater than 0. Once a bounded length is full, when new items are added, a corresponding number of items are discarded from the opposite end.

Note

  • Valid frequency parameter values are:
  • pyalgotrade.barfeed.Frequency.MINUTE
  • pyalgotrade.barfeed.Frequency.HOUR
  • pyalgotrade.barfeed.Frequency.DAY

Previous topic

bar – Instrument prices

Next topic

feed – Basic feeds

This Page