An EventWindow class is responsible for making calculation over a moving window of values.
Parameters: |
|
---|
Note
This is a base class and should not be used directly.
Override to calculate a value using the values in the window.
Returns the values in the window.
Returns the window size.
Bases: pyalgotrade.dataseries.SequenceDataSeries
An EventBasedFilter class is responsible for capturing new values in a pyalgotrade.dataseries.DataSeries and using an EventWindow to calculate new values.
Parameters: |
|
---|
Returns the pyalgotrade.dataseries.DataSeries being filtered.
Returns the EventWindow instance to use to calculate new values.
The following example shows how to combine an EventWindow and an EventBasedFilter to build a custom filter:
from pyalgotrade import dataseries
from pyalgotrade import technical
# An EventWindow is responsible for making calculations using a window of values.
class Accumulator(technical.EventWindow):
def getValue(self):
ret = 0
for value in self.getValues():
if value != None:
ret += value
return ret
# Build a sequence based DataSeries.
seqDS = dataseries.SequenceDataSeries()
# Wrap it with a filter that will get fed as new values get added to the underlying DataSeries.
accum = technical.EventBasedFilter(seqDS, Accumulator(3))
# Put in some values.
for i in range(0, 50):
seqDS.append(i)
# Get some values.
print accum[0] # Not enough values yet.
print accum[1] # Not enough values yet.
print accum[2] # Ok, now we should have at least 3 values.
print accum[3]
# Get the last value, which should be equal to 49 + 48 + 47.
print accum[-1]
The output should be:
0
1
3
6
144
Bases: pyalgotrade.technical.EventBasedFilter
Simple Moving Average filter.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Exponential Moving Average filter.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Weighted Moving Average filter.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Volume Weighted Average Price filter.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Relative Strength Index filter as described in http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Stochastic Oscillator filter as described in http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:stochastic_oscillato. Note that the value returned by this filter is %K. To access %D use getD().
Parameters: |
|
---|
Returns a pyalgotrade.dataseries.DataSeries with the %D values.
Bases: pyalgotrade.technical.EventBasedFilter
Rate of change filter as described in http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:rate_of_change.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
The Slope filter calculates the slope of the least-squares regression line.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
This filter calculates the highest value.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
This filter calculates the lowest value.
Parameters: |
|
---|
Checks for a cross above conditions over the specified period between two DataSeries objects.
It returns the number of times values1 crossed above values2 during the given period.
Parameters: |
|
---|
Note
The default start and end values check for cross above conditions over the last 2 values.
Checks for a cross below conditions over the specified period between two DataSeries objects.
It returns the number of times values1 crossed below values2 during the given period.
Parameters: |
|
---|
Note
The default start and end values check for cross below conditions over the last 2 values.
A line in a line break chart.
The datetime.
The high value.
The low value.
True if the line is black (falling prices).
True if the line is white (rising prices).
Bases: pyalgotrade.dataseries.SequenceDataSeries
Line Break filter as described in http://stockcharts.com/help/doku.php?id=chart_school:chart_analysis:three_line_break . This is a DataSeries of Line instances.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Standard deviation filter.
Parameters: |
|
---|
Bases: pyalgotrade.technical.EventBasedFilter
Z-Score filter.
Parameters: |
|
---|
Bollinger Bands filter as described in http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:bollinger_bands.
Parameters: |
|
---|
Returns the lower band as a pyalgotrade.dataseries.DataSeries.
Returns the middle band as a pyalgotrade.dataseries.DataSeries.
Returns the upper band as a pyalgotrade.dataseries.DataSeries.
Bases: pyalgotrade.technical.EventBasedFilter
This filter calculates cumulative returns over another dataseries.
Parameters: |
|
---|