Indicators¶
The indicator subpackage provides a set of efficient indicators and analyzers.
These are classes which can be used for signal discovery and filtering. The idea is to use the provided indicators as is, or as inspiration for a trader to implement their own proprietary indicator algorithms with the platform.
- class AdaptiveMovingAverage¶
Bases:
MovingAverageAdaptiveMovingAverage(int period_er, int period_alpha_fast, int period_alpha_slow, PriceType price_type=PriceType.LAST)
An indicator which calculates an adaptive moving average (AMA) across a rolling window. Developed by Perry Kaufman, the AMA is a moving average designed to account for market noise and volatility. The AMA will closely follow prices when the price swings are relatively small and the noise is low. The AMA will increase lag when the price swings increase.
- Parameters:
period_er (int) – The period for the internal EfficiencyRatio indicator (> 0).
period_alpha_fast (int) – The period for the fast smoothing constant (> 0).
period_alpha_slow (int) – The period for the slow smoothing constant (> 0 < alpha_fast).
price_type (PriceType) – The specified price type for extracting values from quotes.
- alpha_diff¶
The alpha difference value.
- Returns:
double
- alpha_fast¶
The alpha fast value.
- Returns:
double
- alpha_slow¶
The alpha slow value.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- period_alpha_fast¶
The period of the fast smoothing constant.
- Returns:
double
- period_alpha_slow¶
The period of the slow smoothing constant.
- Returns:
double
- period_er¶
The period of the internal EfficiencyRatio indicator.
- Returns:
double
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class ArcherMovingAveragesTrends¶
Bases:
IndicatorArcherMovingAveragesTrends(int fast_period, int slow_period, int signal_period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL)
Archer Moving Averages Trends indicator.
- Parameters:
fast_period (int) – The period for the fast moving average (> 0).
slow_period (int) – The period for the slow moving average (> 0 & > fast_sma).
signal_period (int) – The period for lookback price array (> 0).
ma_type (MovingAverageType) – The moving average type for the calculations.
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- long_run¶
- short_run¶
- signal_period¶
- slow_period¶
- update_raw(self, double close) void¶
Update the indicator with the given close price value.
- Parameters:
close (double) – The close price.
- class AroonOscillator¶
Bases:
IndicatorAroonOscillator(int period)
The Aroon (AR) indicator developed by Tushar Chande attempts to determine whether an instrument is trending, and how strong the trend is. AroonUp and AroonDown lines make up the indicator with their formulas below.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
- aroon_down¶
The current aroon down value.
- Returns:
double
- aroon_up¶
The current aroon up value.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
The window period.
- Returns:
int
- update_raw(self, double high, double low) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
- value¶
The current value.
- Returns:
double
- class AverageTrueRange¶
Bases:
IndicatorAverageTrueRange(int period, MovingAverageType ma_type=MovingAverageType.SIMPLE, bool use_previous=True, double value_floor=0)
An indicator which calculates the average true range across a rolling window. Different moving average types can be selected for the inner calculation.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
use_previous (bool) – The boolean flag indicating whether previous price values should be used. (note: only applicable for update(). update_mid() will need to use previous price.
value_floor (double) – The floor (minimum) output value for the indicator (>= 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
The window period.
- Returns:
int
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
The current value.
- Returns:
double
- class Bias¶
Bases:
IndicatorBias(int period, MovingAverageType ma_type=MovingAverageType.SIMPLE)
Rate of change between the source and a moving average.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- update_raw(self, double close) void¶
Update the indicator with the given raw values.
- Parameters:
close (double) – The close price.
- value¶
- class BollingerBands¶
Bases:
IndicatorBollingerBands(int period, double k, MovingAverageType ma_type=MovingAverageType.SIMPLE)
A Bollinger Band® is a technical analysis tool defined by a set of trend lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of an instruments price, which can be adjusted to user preferences.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
k (double) – The standard deviation multiple for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator.
- Raises:
ValueError – If period is not positive (> 0).
ValueError – If k is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given tick.
- Parameters:
tick (TradeTick) – The tick for the update.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given tick.
- Parameters:
tick (TradeTick) – The tick for the update.
- k¶
The standard deviation multiple.
- Returns:
double
- lower¶
The current value of the lower band.
- Returns:
double
- middle¶
The current value of the middle band.
- Returns:
double
- period¶
The period for the moving average.
- Returns:
int
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given prices.
- Parameters:
high (double) – The high price for calculations.
low (double) – The low price for calculations.
close (double) – The closing price for calculations
- upper¶
The current value of the upper band.
- Returns:
double
- class CandleBodySize¶
Bases:
IntFlag- BODY_NONE = 0¶
- BODY_SMALL = 1¶
- BODY_MEDIUM = 2¶
- BODY_LARGE = 3¶
- BODY_TREND = 4¶
- class CandleSize¶
Bases:
IntFlag- SIZE_NONE = 0¶
- SIZE_VERY_SMALL = 1¶
- SIZE_SMALL = 2¶
- SIZE_MEDIUM = 3¶
- SIZE_LARGE = 4¶
- SIZE_VERY_LARGE = 5¶
- SIZE_EXTREMELY_LARGE = 6¶
- class CandleWickSize¶
Bases:
IntFlag- WICK_NONE = 0¶
- WICK_SMALL = 1¶
- WICK_MEDIUM = 2¶
- WICK_LARGE = 3¶
- class ChandeMomentumOscillator¶
Bases:
IndicatorChandeMomentumOscillator(int period, ma_type=None)
Attempts to capture the momentum of an asset with overbought at 50 and oversold at -50.
- Parameters:
ma_type (int) – The moving average type for average gain/loss.
period (MovingAverageType) – The rolling window period for the indicator.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
The window period.
- Returns:
int
- update_raw(self, double close) void¶
Update the indicator with the given value.
- Parameters:
value (double) – The update value.
- value¶
The current value.
- Returns:
double
- class CommodityChannelIndex¶
Bases:
IndicatorCommodityChannelIndex(int period, double scalar=0.015, ma_type=None)
Commodity Channel Index is a momentum oscillator used to primarily identify overbought and oversold levels relative to a mean.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
scalar (double) – A positive float to scale the bands
ma_type (MovingAverageType) – The moving average type for prices.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- scalar¶
The positive float to scale the bands.
- Returns:
double
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
The current value.
- Returns:
double
- class DirectionalMovement¶
Bases:
IndicatorDirectionalMovement(int period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL)
Two oscillators that capture positive and negative trend movement.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- neg¶
- period¶
- pos¶
- update_raw(self, double high, double low) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
- value¶
- class DonchianChannel¶
Bases:
IndicatorDonchianChannel(int period)
Donchian Channels are three lines generated by moving average calculations that comprise an indicator formed by upper and lower bands around a mid-range or median band. The upper band marks the highest price of a instrument_id over N periods while the lower band marks the lowest price of a instrument_id over N periods. The area between the upper and lower bands represents the Donchian Channel.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given ticks high and low prices.
- Parameters:
tick (TradeTick) – The tick for the update.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given ticks price.
- Parameters:
tick (TradeTick) – The tick for the update.
- lower¶
- middle¶
- period¶
- update_raw(self, double high, double low) void¶
Update the indicator with the given prices.
- Parameters:
high (double) – The price for the upper channel.
low (double) – The price for the lower channel.
- upper¶
- class DoubleExponentialMovingAverage¶
Bases:
MovingAverageDoubleExponentialMovingAverage(int period, PriceType price_type=PriceType.LAST)
The Double Exponential Moving Average attempts to a smoother average with less lag than the normal Exponential Moving Average (EMA).
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class EfficiencyRatio¶
Bases:
IndicatorEfficiencyRatio(int period)
An indicator which calculates the efficiency ratio across a rolling window. The Kaufman Efficiency measures the ratio of the relative market speed in relation to the volatility, this could be thought of as a proxy for noise.
- Parameters:
period (int) – The rolling window period for the indicator (>= 2).
- Raises:
ValueError – If period is not >= 2.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
The window period.
- Returns:
int
- update_raw(self, double price) void¶
Update the indicator with the given price.
- Parameters:
price (double) – The update price.
- value¶
The current value.
- Returns:
double
- class ExponentialMovingAverage¶
Bases:
MovingAverageExponentialMovingAverage(int period, PriceType price_type=PriceType.LAST)
An indicator which calculates an exponential moving average across a rolling window.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- alpha¶
The moving average alpha value.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class FuzzyCandle¶
Bases:
objectFuzzyCandle(CandleDirection direction, CandleSize size, CandleBodySize body_size, CandleWickSize upper_wick_size, CandleWickSize lower_wick_size)
Represents a fuzzy candle.
- Parameters:
direction (CandleDirection) – The candle direction.
size (CandleSize) – The candle fuzzy size.
body_size (CandleBodySize) – The candle fuzzy body size.
upper_wick_size (CandleWickSize) – The candle fuzzy upper wick size.
lower_wick_size (CandleWickSize) – The candle fuzzy lower wick size.
- body_size¶
The candles fuzzy body size.
- Returns:
CandleBodySize
- direction¶
The candles close direction.
- Returns:
CandleDirection
- lower_wick_size¶
The candles fuzzy lower wick size.
- Returns:
CandleWickSize
- size¶
The candles fuzzy overall size.
- Returns:
CandleSize
- upper_wick_size¶
The candles fuzzy upper wick size.
- Returns:
CandleWickSize
- class FuzzyCandlesticks¶
Bases:
IndicatorFuzzyCandlesticks(int period, double threshold1=0.5, double threshold2=1.0, double threshold3=2.0, double threshold4=3.0)
An indicator which fuzzifies bar data to produce fuzzy candlesticks. Bar data is dimensionally reduced via fuzzy feature extraction.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
threshold1 (float) – The membership function x threshold1 (>= 0).
threshold2 (float) – The membership function x threshold2 (> threshold1).
threshold3 (float) – The membership function x threshold3 (> threshold2).
threshold4 (float) – The membership function x threshold4 (> threshold3).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar. (The update)
- period¶
The window period.
- Returns:
int
- update_raw(self, double open, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
open (double) – The open price.
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
The last fuzzy candle.
- Returns:
FuzzyCandle
- vector¶
The fuzzy candle represented as a vector of ints.
- Returns:
list[int]
- class HullMovingAverage¶
Bases:
MovingAverageHullMovingAverage(int period, PriceType price_type=PriceType.LAST)
An indicator which calculates a Hull Moving Average (HMA) across a rolling window. The HMA, developed by Alan Hull, is an extremely fast and smooth moving average.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class IchimokuCloud¶
Bases:
IndicatorIchimokuCloud(int tenkan_period=9, int kijun_period=26, int senkou_period=52, int displacement=26)
Ichimoku Cloud (Kinko Hyo) with five components.
Tenkan-sen (Conversion Line): (tenkan_period high + tenkan_period low) / 2.
Kijun-sen (Base Line): (kijun_period high + kijun_period low) / 2.
Senkou Span A (Leading Span A): (Tenkan + Kijun) / 2, displaced forward by displacement.
Senkou Span B (Leading Span B): (senkou_period high + senkou_period low) / 2, displaced forward by displacement.
Chikou Span (Lagging Span): Close displaced backward by displacement.
The indicator becomes
initializedaftersenkou_periodbars, at which point tenkan_sen, kijun_sen are valid. The displaced outputs (senkou_span_a, senkou_span_b, chikou_span) require an additionaldisplacementbars before they become non-zero.- Parameters:
tenkan_period (int) – Period for Tenkan-sen (default 9).
kijun_period (int) – Period for Kijun-sen (default 26).
senkou_period (int) – Period for Senkou Span B (default 52).
displacement (int) – Displacement for leading/lagging spans (default 26).
- Raises:
ValueError – If any period or displacement is not positive.
ValueError – If senkou_period is not >= kijun_period or kijun_period is not >= tenkan_period.
- chikou_span¶
- displacement¶
- handle_bar(self, Bar bar) void¶
- kijun_period¶
- kijun_sen¶
- senkou_period¶
- senkou_span_a¶
- senkou_span_b¶
- tenkan_period¶
- tenkan_sen¶
- update_raw(self, double high, double low, double close) void¶
- class Indicator¶
Bases:
objectIndicator(list params)
The base class for all indicators.
- Parameters:
params (list) – The initialization parameters for the indicator.
Warning
This class should not be used directly, but through a concrete subclass.
- handle_bar(self, Bar bar) void¶
Abstract method (implement in subclass).
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- class KeltnerChannel¶
Bases:
IndicatorKeltnerChannel(int period, double k_multiplier, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, MovingAverageType ma_type_atr=MovingAverageType.SIMPLE, bool use_previous=True, double atr_floor=0)
The Keltner channel is a volatility based envelope set above and below a central moving average. Traditionally the middle band is an EMA based on the typical price (high + low + close) / 3, the upper band is the middle band plus the ATR. The lower band is the middle band minus the ATR.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
k_multiplier (double) – The multiplier for the ATR (> 0).
ma_type (MovingAverageType) – The moving average type for the middle band (cannot be None).
ma_type_atr (MovingAverageType) – The moving average type for the internal ATR (cannot be None).
use_previous (bool) – The boolean flag indicating whether previous price values should be used.
atr_floor (double) – The ATR floor (minimum) output value for the indicator (>= 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- k_multiplier¶
- lower¶
- middle¶
- period¶
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- upper¶
- class KeltnerPosition¶
Bases:
IndicatorKeltnerPosition(int period, double k_multiplier, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, MovingAverageType ma_type_atr=MovingAverageType.SIMPLE, bool use_previous=True, double atr_floor=0)
An indicator which calculates the relative position of the given price within a defined Keltner channel. This provides a measure of the relative ‘extension’ of a market from the mean, as a multiple of volatility.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
k_multiplier (double) – The multiplier for the ATR (> 0).
ma_type (MovingAverageType) – The moving average type for the middle band (cannot be None).
ma_type_atr (MovingAverageType) – The moving average type for the internal ATR (cannot be None).
use_previous (bool) – The boolean flag indicating whether previous price values should be used.
atr_floor (double) – The ATR floor (minimum) output value for the indicator (>= 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- k_multiplier¶
- period¶
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw value.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
- class KlingerVolumeOscillator¶
Bases:
IndicatorKlingerVolumeOscillator(int fast_period, int slow_period, int signal_period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL)
This indicator was developed by Stephen J. Klinger. It is designed to predict price reversals in a market by comparing volume to price.
- Parameters:
fast_period (int) – The period for the fast moving average (> 0).
slow_period (int) – The period for the slow moving average (> 0 & > fast_sma).
signal_period (int) – The period for the moving average difference’s moving average (> 0).
ma_type (MovingAverageType) – The moving average type for the calculations.
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- signal_period¶
- slow_period¶
- update_raw(self, double high, double low, double close, double volume) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
volume (double) – The volume.
- value¶
- class LinearRegression¶
Bases:
IndicatorLinearRegression(int period=0)
An indicator that calculates a simple linear regression.
- Parameters:
period (int) – The period for the indicator.
- Raises:
ValueError – If period is not greater than zero.
- R2¶
- cfo¶
- degree¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- intercept¶
- period¶
- slope¶
- update_raw(self, double close) void¶
Update the indicator with the given raw values.
- Parameters:
close_price (double) – The close price.
- value¶
- class MovingAverage¶
Bases:
IndicatorMovingAverage(int period, list params, PriceType price_type)
The base class for all moving average type indicators.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
params (list) – The initialization parameters for the indicator.
price_type (PriceType, optional) – The specified price type for extracting values from quotes.
Warning
This class should not be used directly, but through a concrete subclass.
- count¶
The count of inputs received by the indicator.
- Returns:
int
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class MovingAverageConvergenceDivergence¶
Bases:
IndicatorMovingAverageConvergenceDivergence(int fast_period, int slow_period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, PriceType price_type=PriceType.LAST)
An indicator which calculates the difference between two moving averages. Different moving average types can be selected for the inner calculation.
- Parameters:
fast_period (int) – The period for the fast moving average (> 0).
slow_period (int) – The period for the slow moving average (> 0 & > fast_sma).
ma_type (MovingAverageType) – The moving average type for the calculations.
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If fast_period is not positive (> 0).
ValueError – If slow_period is not positive (> 0).
ValueError – If fast_period is not < slow_period.
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- slow_period¶
- update_raw(self, double close) void¶
Update the indicator with the given close price.
- Parameters:
close (double) – The close price.
- value¶
- class MovingAverageFactory¶
Bases:
objectProvides a factory to construct different moving average indicators.
- static create(int period, MovingAverageType ma_type: MovingAverageType, **kwargs) MovingAverage¶
Create a moving average indicator corresponding to the given ma_type.
- Parameters:
period (int) – The period of the moving average (> 0).
ma_type (MovingAverageType) – The moving average type.
- Return type:
- Raises:
ValueError – If period is not positive (> 0).
- class MovingAverageType¶
Bases:
IntFlag- SIMPLE = 0¶
- EXPONENTIAL = 1¶
- DOUBLE_EXPONENTIAL = 2¶
- WILDER = 3¶
- HULL = 4¶
- ADAPTIVE = 5¶
- WEIGHTED = 6¶
- VARIABLE_INDEX_DYNAMIC = 7¶
- class OnBalanceVolume¶
Bases:
IndicatorOnBalanceVolume(int period=0)
An indicator which calculates the momentum of relative positive or negative volume.
- Parameters:
period (int) – The period for the indicator, zero indicates no window (>= 0).
- Raises:
ValueError – If period is negative (< 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- update_raw(self, double open, double close, double volume) void¶
Update the indicator with the given raw values.
- Parameters:
open (double) – The high price.
close (double) – The low price.
volume (double) – The close price.
- value¶
- class Pressure¶
Bases:
IndicatorPressure(int period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, double atr_floor=0)
An indicator which calculates the relative volume (multiple of average volume) to move the market across a relative range (multiple of ATR).
- Parameters:
period (int) – The period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the calculations.
atr_floor (double) – The ATR floor (minimum) output value for the indicator (>= 0.).
- Raises:
ValueError – If period is not positive (> 0).
ValueError – If atr_floor is negative (< 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- update_raw(self, double high, double low, double close, double volume) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
volume (double) – The volume.
- value¶
- value_cumulative¶
- class PsychologicalLine¶
Bases:
IndicatorPsychologicalLine(int period, ma_type=None)
The Psychological Line is an oscillator-type indicator that compares the number of the rising periods to the total number of periods. In other words, it is the percentage of bars that close above the previous bar over a given period.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- update_raw(self, double close) void¶
Update the indicator with the given raw value.
- Parameters:
close (double) – The close price.
- value¶
- class RateOfChange¶
Bases:
IndicatorRateOfChange(int period, bool use_log=False)
An indicator which calculates the rate of change of price over a defined period. The return output can be simple or log.
- Parameters:
period (int) – The period for the indicator.
use_log (bool) – Use log returns for value calculation.
- Raises:
ValueError – If period is not > 1.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
The window period.
- Returns:
int
- update_raw(self, double price) void¶
Update the indicator with the given price.
- Parameters:
price (double) – The update price.
- value¶
The current value.
- Returns:
double
- class RelativeStrengthIndex¶
Bases:
IndicatorRelativeStrengthIndex(int period, ma_type=None)
An indicator which calculates a relative strength index (RSI) across a rolling window.
- Parameters:
ma_type (int) – The moving average type for average gain/loss.
period (MovingAverageType) – The rolling window period for the indicator.
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
The window period.
- Returns:
int
- update_raw(self, double value) void¶
Update the indicator with the given value.
- Parameters:
value (double) – The update value.
- value¶
The current value.
- Returns:
double
- class RelativeVolatilityIndex¶
Bases:
IndicatorRelativeVolatilityIndex(int period, double scalar=100.0, ma_type=None)
The Relative Volatility Index (RVI) was created in 1993 and revised in 1995. Instead of adding up price changes like RSI based on price direction, the RVI adds up standard deviations based on price direction.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
scalar (double) – A positive float to scale the bands.
ma_type (MovingAverageType) – The moving average type for the vip and vim (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- scalar¶
- update_raw(self, double close) void¶
Update the indicator with the given raw values.
- Parameters:
close (double) – The close price.
- value¶
- class SimpleMovingAverage¶
Bases:
MovingAverageSimpleMovingAverage(int period, PriceType price_type=PriceType.LAST)
An indicator which calculates a simple moving average across a rolling window.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class SpreadAnalyzer¶
Bases:
IndicatorSpreadAnalyzer(InstrumentId instrument_id, int capacity) -> None
Provides various spread analysis metrics.
- Parameters:
instrument_id (InstrumentId) – The instrument ID for the tick updates.
capacity (int) – The max length for the internal QuoteTick deque (determines averages).
- Raises:
ValueError – If capacity is not positive (> 0).
- average¶
The current average spread.
- Returns:
double
- capacity¶
The indicators spread capacity.
- Returns:
int
- current¶
The current spread.
- Returns:
double
- handle_quote_tick(self, QuoteTick tick) void¶
Update the analyzer with the given quote tick.
- Parameters:
tick (QuoteTick) – The tick for the update.
- Raises:
ValueError – If tick.instrument_id does not equal the analyzers instrument ID.
- instrument_id¶
The indicators instrument ID.
- Returns:
InstrumentId
- class Stochastics¶
Bases:
IndicatorStochastics(int period_k, int period_d, int slowing=1, ma_type=None, str d_method=’ratio’)
An oscillator which can indicate when an asset may be over bought or over sold.
- Parameters:
period_k (int) – The period for the K line (highest high / lowest low lookback).
period_d (int) – The period for the D line (smoothing period).
slowing (int, optional) – The slowing period for %K smoothing (1 = no slowing, > 1 = MA smoothed). Default is 1 for backward compatibility.
ma_type (MovingAverageType, optional) – The MA type for slowing and MA-based %D. Default is EXPONENTIAL.
d_method (str, optional) – The %D calculation method: “ratio” (Nautilus native) or “moving_average” (cTrader-like). Default is “ratio” for backward compatibility.
- Raises:
ValueError – If period_k is not positive (> 0).
ValueError – If period_d is not positive (> 0).
ValueError – If slowing is not positive (> 0).
References
https://www.forextraders.com/forex-education/forex-indicators/stochastics-indicator-explained/
- d_method¶
The %D calculation method (‘ratio’ or ‘moving_average’).
- Returns:
str
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- ma_type¶
The MA type for slowing and MA-based %D.
- Returns:
MovingAverageType
- period_d¶
The d period.
- Returns:
int
- period_k¶
The k period.
- Returns:
int
- slowing¶
The slowing period for %K smoothing.
- Returns:
int
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value_d¶
The d value.
- Returns:
double
- value_k¶
The k value.
- Returns:
double
- class StochasticsDMethod¶
Bases:
objectMethod for calculating %D in the Stochastics indicator.
The %D line is the smoothed version of %K and provides trading signals. Two calculation methods are supported:
RATIO: Nautilus original method using 100 * SUM(close-LL) / SUM(HH-LL) over period_d. This is range-weighted and has less lag than MA-based methods.
MOVING_AVERAGE: Standard method using MA of slowed %K values, compatible with cTrader/MetaTrader implementations.
- MOVING_AVERAGE = 'moving_average'¶
- RATIO = 'ratio'¶
- class Swings¶
Bases:
IndicatorSwings(int period)
A swing indicator which calculates and stores various swing metrics.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
- changed¶
- direction¶
- duration¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- high_datetime¶
- high_price¶
- length¶
- low_datetime¶
- low_price¶
- period¶
- since_high¶
- since_low¶
- update_raw(self, double high, double low, datetime timestamp) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
timestamp (datetime) – The current timestamp.
- class VariableIndexDynamicAverage¶
Bases:
MovingAverageVariableIndexDynamicAverage(int period, PriceType price_type=PriceType.LAST, MovingAverageType cmo_ma_type=MovingAverageType.SIMPLE)
Variable Index Dynamic Average (VIDYA) was developed by Tushar Chande. It is similar to an Exponential Moving Average, but it has a dynamically adjusted lookback period dependent on relative price volatility as measured by Chande Momentum Oscillator (CMO). When volatility is high, VIDYA reacts faster to price changes. It is often used as moving average or trend identifier.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
cmo_ma_type (int) – The moving average type for CMO indicator.
- Raises:
ValueError – If period is not positive (> 0). If cmo_ma_type is
VARIABLE_INDEX_DYNAMIC.
- alpha¶
The moving average alpha value.
- Returns:
double
- cmo_pct¶
The normal cmo value.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class VerticalHorizontalFilter¶
Bases:
IndicatorVerticalHorizontalFilter(int period, MovingAverageType ma_type=MovingAverageType.SIMPLE)
The Vertical Horizon Filter (VHF) was created by Adam White to identify trending and ranging markets.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- period¶
- update_raw(self, double close) void¶
Update the indicator with the given raw value.
- Parameters:
close (double) – The close price.
- value¶
- class VolatilityRatio¶
Bases:
IndicatorVolatilityRatio(int fast_period, int slow_period, MovingAverageType ma_type=MovingAverageType.SIMPLE, bool use_previous=True, double value_floor=0)
An indicator which calculates the ratio of different ranges of volatility. Different moving average types can be selected for the inner ATR calculations.
- Parameters:
fast_period (int) – The period for the fast ATR (> 0).
slow_period (int) – The period for the slow ATR (> 0 & > fast_period).
ma_type (MovingAverageType) – The moving average type for the ATR calculations.
use_previous (bool) – The boolean flag indicating whether previous price values should be used.
value_floor (double) – The floor (minimum) output value for the indicator (>= 0).
- Raises:
ValueError – If fast_period is not positive (> 0).
ValueError – If slow_period is not positive (> 0).
ValueError – If fast_period is not < slow_period.
ValueError – If value_floor is negative (< 0).
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- slow_period¶
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw value.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
- class VolumeWeightedAveragePrice¶
Bases:
IndicatorVolumeWeightedAveragePrice()
An indicator which calculates the volume weighted average price for the day.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- update_raw(self, double price, double volume, datetime timestamp) void¶
Update the indicator with the given raw values.
- Parameters:
price (double) – The update price.
volume (double) – The update volume.
timestamp (datetime) – The current timestamp.
- value¶
- class WeightedMovingAverage¶
Bases:
MovingAverageWeightedMovingAverage(int period, weights=None, PriceType price_type=PriceType.LAST)
An indicator which calculates a weighted moving average across a rolling window.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
weights (iterable) – The weights for the moving average calculation (if not
Nonethen = period).price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- weights¶
- class WilderMovingAverage¶
Bases:
MovingAverageWilderMovingAverage(int period, PriceType price_type=PriceType.LAST)
The Wilder’s Moving Average is simply an Exponential Moving Average (EMA) with a modified alpha = 1 / period.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- alpha¶
The moving average alpha value.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- class AdaptiveMovingAverage¶
Bases:
MovingAverageAdaptiveMovingAverage(int period_er, int period_alpha_fast, int period_alpha_slow, PriceType price_type=PriceType.LAST)
An indicator which calculates an adaptive moving average (AMA) across a rolling window. Developed by Perry Kaufman, the AMA is a moving average designed to account for market noise and volatility. The AMA will closely follow prices when the price swings are relatively small and the noise is low. The AMA will increase lag when the price swings increase.
- Parameters:
period_er (int) – The period for the internal EfficiencyRatio indicator (> 0).
period_alpha_fast (int) – The period for the fast smoothing constant (> 0).
period_alpha_slow (int) – The period for the slow smoothing constant (> 0 < alpha_fast).
price_type (PriceType) – The specified price type for extracting values from quotes.
- alpha_diff¶
The alpha difference value.
- Returns:
double
- alpha_fast¶
The alpha fast value.
- Returns:
double
- alpha_slow¶
The alpha slow value.
- Returns:
double
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- period_alpha_fast¶
The period of the fast smoothing constant.
- Returns:
double
- period_alpha_slow¶
The period of the slow smoothing constant.
- Returns:
double
- period_er¶
The period of the internal EfficiencyRatio indicator.
- Returns:
double
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class DoubleExponentialMovingAverage¶
Bases:
MovingAverageDoubleExponentialMovingAverage(int period, PriceType price_type=PriceType.LAST)
The Double Exponential Moving Average attempts to a smoother average with less lag than the normal Exponential Moving Average (EMA).
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class ExponentialMovingAverage¶
Bases:
MovingAverageExponentialMovingAverage(int period, PriceType price_type=PriceType.LAST)
An indicator which calculates an exponential moving average across a rolling window.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- alpha¶
The moving average alpha value.
- Returns:
double
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class HullMovingAverage¶
Bases:
MovingAverageHullMovingAverage(int period, PriceType price_type=PriceType.LAST)
An indicator which calculates a Hull Moving Average (HMA) across a rolling window. The HMA, developed by Alan Hull, is an extremely fast and smooth moving average.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class MovingAverage¶
Bases:
IndicatorMovingAverage(int period, list params, PriceType price_type)
The base class for all moving average type indicators.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
params (list) – The initialization parameters for the indicator.
price_type (PriceType, optional) – The specified price type for extracting values from quotes.
Warning
This class should not be used directly, but through a concrete subclass.
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Abstract method (implement in subclass).
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class MovingAverageFactory¶
Bases:
objectProvides a factory to construct different moving average indicators.
- static create(int period, MovingAverageType ma_type: MovingAverageType, **kwargs) MovingAverage¶
Create a moving average indicator corresponding to the given ma_type.
- Parameters:
period (int) – The period of the moving average (> 0).
ma_type (MovingAverageType) – The moving average type.
- Return type:
- Raises:
ValueError – If period is not positive (> 0).
- class MovingAverageType¶
Bases:
IntFlag- conjugate()¶
Returns self, the complex conjugate of any int.
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- bit_count()¶
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- to_bytes(length=1, byteorder='big', *, signed=False)¶
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- classmethod from_bytes(bytes, byteorder='big', *, signed=False)¶
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- as_integer_ratio()¶
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- is_integer()¶
Returns True. Exists for duck type compatibility with float.is_integer.
- real¶
the real part of a complex number
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- denominator¶
the denominator of a rational number in lowest terms
- SIMPLE = 0¶
- EXPONENTIAL = 1¶
- DOUBLE_EXPONENTIAL = 2¶
- WILDER = 3¶
- HULL = 4¶
- ADAPTIVE = 5¶
- WEIGHTED = 6¶
- VARIABLE_INDEX_DYNAMIC = 7¶
- class SimpleMovingAverage¶
Bases:
MovingAverageSimpleMovingAverage(int period, PriceType price_type=PriceType.LAST)
An indicator which calculates a simple moving average across a rolling window.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class VariableIndexDynamicAverage¶
Bases:
MovingAverageVariableIndexDynamicAverage(int period, PriceType price_type=PriceType.LAST, MovingAverageType cmo_ma_type=MovingAverageType.SIMPLE)
Variable Index Dynamic Average (VIDYA) was developed by Tushar Chande. It is similar to an Exponential Moving Average, but it has a dynamically adjusted lookback period dependent on relative price volatility as measured by Chande Momentum Oscillator (CMO). When volatility is high, VIDYA reacts faster to price changes. It is often used as moving average or trend identifier.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
cmo_ma_type (int) – The moving average type for CMO indicator.
- Raises:
ValueError – If period is not positive (> 0). If cmo_ma_type is
VARIABLE_INDEX_DYNAMIC.
- alpha¶
The moving average alpha value.
- Returns:
double
- cmo_pct¶
The normal cmo value.
- Returns:
double
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class WeightedMovingAverage¶
Bases:
MovingAverageWeightedMovingAverage(int period, weights=None, PriceType price_type=PriceType.LAST)
An indicator which calculates a weighted moving average across a rolling window.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
weights (iterable) – The weights for the moving average calculation (if not
Nonethen = period).price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- weights¶
- class WilderMovingAverage¶
Bases:
MovingAverageWilderMovingAverage(int period, PriceType price_type=PriceType.LAST)
The Wilder’s Moving Average is simply an Exponential Moving Average (EMA) with a modified alpha = 1 / period.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If period is not positive (> 0).
- alpha¶
The moving average alpha value.
- Returns:
double
- count¶
The count of inputs received by the indicator.
- Returns:
int
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar to handle.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The moving average period.
- Returns:
PriceType
- price_type¶
The specified price type for extracting values from quotes.
- Returns:
PriceType
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given raw value.
- Parameters:
value (double) – The update value.
- value¶
The current output value.
- Returns:
double
- class FuzzyCandle¶
Bases:
objectFuzzyCandle(CandleDirection direction, CandleSize size, CandleBodySize body_size, CandleWickSize upper_wick_size, CandleWickSize lower_wick_size)
Represents a fuzzy candle.
- Parameters:
direction (CandleDirection) – The candle direction.
size (CandleSize) – The candle fuzzy size.
body_size (CandleBodySize) – The candle fuzzy body size.
upper_wick_size (CandleWickSize) – The candle fuzzy upper wick size.
lower_wick_size (CandleWickSize) – The candle fuzzy lower wick size.
- body_size¶
The candles fuzzy body size.
- Returns:
CandleBodySize
- direction¶
The candles close direction.
- Returns:
CandleDirection
- lower_wick_size¶
The candles fuzzy lower wick size.
- Returns:
CandleWickSize
- size¶
The candles fuzzy overall size.
- Returns:
CandleSize
- upper_wick_size¶
The candles fuzzy upper wick size.
- Returns:
CandleWickSize
- class FuzzyCandlesticks¶
Bases:
IndicatorFuzzyCandlesticks(int period, double threshold1=0.5, double threshold2=1.0, double threshold3=2.0, double threshold4=3.0)
An indicator which fuzzifies bar data to produce fuzzy candlesticks. Bar data is dimensionally reduced via fuzzy feature extraction.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
threshold1 (float) – The membership function x threshold1 (>= 0).
threshold2 (float) – The membership function x threshold2 (> threshold1).
threshold3 (float) – The membership function x threshold3 (> threshold2).
threshold4 (float) – The membership function x threshold4 (> threshold3).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar. (The update)
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double open, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
open (double) – The open price.
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
The last fuzzy candle.
- Returns:
FuzzyCandle
- vector¶
The fuzzy candle represented as a vector of ints.
- Returns:
list[int]
- class ChandeMomentumOscillator¶
Bases:
IndicatorChandeMomentumOscillator(int period, ma_type=None)
Attempts to capture the momentum of an asset with overbought at 50 and oversold at -50.
- Parameters:
ma_type (int) – The moving average type for average gain/loss.
period (MovingAverageType) – The rolling window period for the indicator.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double close) void¶
Update the indicator with the given value.
- Parameters:
value (double) – The update value.
- value¶
The current value.
- Returns:
double
- class CommodityChannelIndex¶
Bases:
IndicatorCommodityChannelIndex(int period, double scalar=0.015, ma_type=None)
Commodity Channel Index is a momentum oscillator used to primarily identify overbought and oversold levels relative to a mean.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
scalar (double) – A positive float to scale the bands
ma_type (MovingAverageType) – The moving average type for prices.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- scalar¶
The positive float to scale the bands.
- Returns:
double
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
The current value.
- Returns:
double
- class EfficiencyRatio¶
Bases:
IndicatorEfficiencyRatio(int period)
An indicator which calculates the efficiency ratio across a rolling window. The Kaufman Efficiency measures the ratio of the relative market speed in relation to the volatility, this could be thought of as a proxy for noise.
- Parameters:
period (int) – The rolling window period for the indicator (>= 2).
- Raises:
ValueError – If period is not >= 2.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double price) void¶
Update the indicator with the given price.
- Parameters:
price (double) – The update price.
- value¶
The current value.
- Returns:
double
- class PsychologicalLine¶
Bases:
IndicatorPsychologicalLine(int period, ma_type=None)
The Psychological Line is an oscillator-type indicator that compares the number of the rising periods to the total number of periods. In other words, it is the percentage of bars that close above the previous bar over a given period.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double close) void¶
Update the indicator with the given raw value.
- Parameters:
close (double) – The close price.
- value¶
- class RateOfChange¶
Bases:
IndicatorRateOfChange(int period, bool use_log=False)
An indicator which calculates the rate of change of price over a defined period. The return output can be simple or log.
- Parameters:
period (int) – The period for the indicator.
use_log (bool) – Use log returns for value calculation.
- Raises:
ValueError – If period is not > 1.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double price) void¶
Update the indicator with the given price.
- Parameters:
price (double) – The update price.
- value¶
The current value.
- Returns:
double
- class RelativeStrengthIndex¶
Bases:
IndicatorRelativeStrengthIndex(int period, ma_type=None)
An indicator which calculates a relative strength index (RSI) across a rolling window.
- Parameters:
ma_type (int) – The moving average type for average gain/loss.
period (MovingAverageType) – The rolling window period for the indicator.
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double value) void¶
Update the indicator with the given value.
- Parameters:
value (double) – The update value.
- value¶
The current value.
- Returns:
double
- class RelativeVolatilityIndex¶
Bases:
IndicatorRelativeVolatilityIndex(int period, double scalar=100.0, ma_type=None)
The Relative Volatility Index (RVI) was created in 1993 and revised in 1995. Instead of adding up price changes like RSI based on price direction, the RVI adds up standard deviations based on price direction.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
scalar (double) – A positive float to scale the bands.
ma_type (MovingAverageType) – The moving average type for the vip and vim (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- scalar¶
- update_raw(self, double close) void¶
Update the indicator with the given raw values.
- Parameters:
close (double) – The close price.
- value¶
- class Stochastics¶
Bases:
IndicatorStochastics(int period_k, int period_d, int slowing=1, ma_type=None, str d_method=’ratio’)
An oscillator which can indicate when an asset may be over bought or over sold.
- Parameters:
period_k (int) – The period for the K line (highest high / lowest low lookback).
period_d (int) – The period for the D line (smoothing period).
slowing (int, optional) – The slowing period for %K smoothing (1 = no slowing, > 1 = MA smoothed). Default is 1 for backward compatibility.
ma_type (MovingAverageType, optional) – The MA type for slowing and MA-based %D. Default is EXPONENTIAL.
d_method (str, optional) – The %D calculation method: “ratio” (Nautilus native) or “moving_average” (cTrader-like). Default is “ratio” for backward compatibility.
- Raises:
ValueError – If period_k is not positive (> 0).
ValueError – If period_d is not positive (> 0).
ValueError – If slowing is not positive (> 0).
References
https://www.forextraders.com/forex-education/forex-indicators/stochastics-indicator-explained/
- d_method¶
The %D calculation method (‘ratio’ or ‘moving_average’).
- Returns:
str
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- ma_type¶
The MA type for slowing and MA-based %D.
- Returns:
MovingAverageType
- name¶
The name of the indicator.
- Returns:
str
- period_d¶
The d period.
- Returns:
int
- period_k¶
The k period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- slowing¶
The slowing period for %K smoothing.
- Returns:
int
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value_d¶
The d value.
- Returns:
double
- value_k¶
The k value.
- Returns:
double
- class StochasticsDMethod¶
Bases:
objectMethod for calculating %D in the Stochastics indicator.
The %D line is the smoothed version of %K and provides trading signals. Two calculation methods are supported:
RATIO: Nautilus original method using 100 * SUM(close-LL) / SUM(HH-LL) over period_d. This is range-weighted and has less lag than MA-based methods.
MOVING_AVERAGE: Standard method using MA of slowed %K values, compatible with cTrader/MetaTrader implementations.
- MOVING_AVERAGE = 'moving_average'¶
- RATIO = 'ratio'¶
- class SpreadAnalyzer¶
Bases:
IndicatorSpreadAnalyzer(InstrumentId instrument_id, int capacity) -> None
Provides various spread analysis metrics.
- Parameters:
instrument_id (InstrumentId) – The instrument ID for the tick updates.
capacity (int) – The max length for the internal QuoteTick deque (determines averages).
- Raises:
ValueError – If capacity is not positive (> 0).
- average¶
The current average spread.
- Returns:
double
- capacity¶
The indicators spread capacity.
- Returns:
int
- current¶
The current spread.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Abstract method (implement in subclass).
- handle_quote_tick(self, QuoteTick tick) void¶
Update the analyzer with the given quote tick.
- Parameters:
tick (QuoteTick) – The tick for the update.
- Raises:
ValueError – If tick.instrument_id does not equal the analyzers instrument ID.
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- instrument_id¶
The indicators instrument ID.
- Returns:
InstrumentId
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- class ArcherMovingAveragesTrends¶
Bases:
IndicatorArcherMovingAveragesTrends(int fast_period, int slow_period, int signal_period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL)
Archer Moving Averages Trends indicator.
- Parameters:
fast_period (int) – The period for the fast moving average (> 0).
slow_period (int) – The period for the slow moving average (> 0 & > fast_sma).
signal_period (int) – The period for lookback price array (> 0).
ma_type (MovingAverageType) – The moving average type for the calculations.
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- long_run¶
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- short_run¶
- signal_period¶
- slow_period¶
- update_raw(self, double close) void¶
Update the indicator with the given close price value.
- Parameters:
close (double) – The close price.
- class AroonOscillator¶
Bases:
IndicatorAroonOscillator(int period)
The Aroon (AR) indicator developed by Tushar Chande attempts to determine whether an instrument is trending, and how strong the trend is. AroonUp and AroonDown lines make up the indicator with their formulas below.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
- aroon_down¶
The current aroon down value.
- Returns:
double
- aroon_up¶
The current aroon up value.
- Returns:
double
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
- value¶
The current value.
- Returns:
double
- class Bias¶
Bases:
IndicatorBias(int period, MovingAverageType ma_type=MovingAverageType.SIMPLE)
Rate of change between the source and a moving average.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double close) void¶
Update the indicator with the given raw values.
- Parameters:
close (double) – The close price.
- value¶
- class DirectionalMovement¶
Bases:
IndicatorDirectionalMovement(int period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL)
Two oscillators that capture positive and negative trend movement.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- neg¶
- period¶
- pos¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
- value¶
- class IchimokuCloud¶
Bases:
IndicatorIchimokuCloud(int tenkan_period=9, int kijun_period=26, int senkou_period=52, int displacement=26)
Ichimoku Cloud (Kinko Hyo) with five components.
Tenkan-sen (Conversion Line): (tenkan_period high + tenkan_period low) / 2.
Kijun-sen (Base Line): (kijun_period high + kijun_period low) / 2.
Senkou Span A (Leading Span A): (Tenkan + Kijun) / 2, displaced forward by displacement.
Senkou Span B (Leading Span B): (senkou_period high + senkou_period low) / 2, displaced forward by displacement.
Chikou Span (Lagging Span): Close displaced backward by displacement.
The indicator becomes
initializedaftersenkou_periodbars, at which point tenkan_sen, kijun_sen are valid. The displaced outputs (senkou_span_a, senkou_span_b, chikou_span) require an additionaldisplacementbars before they become non-zero.- Parameters:
tenkan_period (int) – Period for Tenkan-sen (default 9).
kijun_period (int) – Period for Kijun-sen (default 26).
senkou_period (int) – Period for Senkou Span B (default 52).
displacement (int) – Displacement for leading/lagging spans (default 26).
- Raises:
ValueError – If any period or displacement is not positive.
ValueError – If senkou_period is not >= kijun_period or kijun_period is not >= tenkan_period.
- chikou_span¶
- displacement¶
- handle_bar(self, Bar bar) void¶
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- kijun_period¶
- kijun_sen¶
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- senkou_period¶
- senkou_span_a¶
- senkou_span_b¶
- tenkan_period¶
- tenkan_sen¶
- update_raw(self, double high, double low, double close) void¶
- class LinearRegression¶
Bases:
IndicatorLinearRegression(int period=0)
An indicator that calculates a simple linear regression.
- Parameters:
period (int) – The period for the indicator.
- Raises:
ValueError – If period is not greater than zero.
- R2¶
- cfo¶
- degree¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- intercept¶
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- slope¶
- update_raw(self, double close) void¶
Update the indicator with the given raw values.
- Parameters:
close_price (double) – The close price.
- value¶
- class MovingAverageConvergenceDivergence¶
Bases:
IndicatorMovingAverageConvergenceDivergence(int fast_period, int slow_period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, PriceType price_type=PriceType.LAST)
An indicator which calculates the difference between two moving averages. Different moving average types can be selected for the inner calculation.
- Parameters:
fast_period (int) – The period for the fast moving average (> 0).
slow_period (int) – The period for the slow moving average (> 0 & > fast_sma).
ma_type (MovingAverageType) – The moving average type for the calculations.
price_type (PriceType) – The specified price type for extracting values from quotes.
- Raises:
ValueError – If fast_period is not positive (> 0).
ValueError – If slow_period is not positive (> 0).
ValueError – If fast_period is not < slow_period.
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given quote tick.
- Parameters:
tick (QuoteTick) – The update tick to handle.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given trade tick.
- Parameters:
tick (TradeTick) – The update tick to handle.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- slow_period¶
- update_raw(self, double close) void¶
Update the indicator with the given close price.
- Parameters:
close (double) – The close price.
- value¶
- class Swings¶
Bases:
IndicatorSwings(int period)
A swing indicator which calculates and stores various swing metrics.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
- changed¶
- direction¶
- duration¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- high_datetime¶
- high_price¶
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- length¶
- low_datetime¶
- low_price¶
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- since_high¶
- since_low¶
- update_raw(self, double high, double low, datetime timestamp) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
timestamp (datetime) – The current timestamp.
- class AverageTrueRange¶
Bases:
IndicatorAverageTrueRange(int period, MovingAverageType ma_type=MovingAverageType.SIMPLE, bool use_previous=True, double value_floor=0)
An indicator which calculates the average true range across a rolling window. Different moving average types can be selected for the inner calculation.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
use_previous (bool) – The boolean flag indicating whether previous price values should be used. (note: only applicable for update(). update_mid() will need to use previous price.
value_floor (double) – The floor (minimum) output value for the indicator (>= 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
The window period.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
The current value.
- Returns:
double
- class BollingerBands¶
Bases:
IndicatorBollingerBands(int period, double k, MovingAverageType ma_type=MovingAverageType.SIMPLE)
A Bollinger Band® is a technical analysis tool defined by a set of trend lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of an instruments price, which can be adjusted to user preferences.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
k (double) – The standard deviation multiple for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator.
- Raises:
ValueError – If period is not positive (> 0).
ValueError – If k is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given tick.
- Parameters:
tick (TradeTick) – The tick for the update.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given tick.
- Parameters:
tick (TradeTick) – The tick for the update.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- k¶
The standard deviation multiple.
- Returns:
double
- lower¶
The current value of the lower band.
- Returns:
double
- middle¶
The current value of the middle band.
- Returns:
double
- name¶
The name of the indicator.
- Returns:
str
- period¶
The period for the moving average.
- Returns:
int
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given prices.
- Parameters:
high (double) – The high price for calculations.
low (double) – The low price for calculations.
close (double) – The closing price for calculations
- upper¶
The current value of the upper band.
- Returns:
double
- class DonchianChannel¶
Bases:
IndicatorDonchianChannel(int period)
Donchian Channels are three lines generated by moving average calculations that comprise an indicator formed by upper and lower bands around a mid-range or median band. The upper band marks the highest price of a instrument_id over N periods while the lower band marks the lowest price of a instrument_id over N periods. The area between the upper and lower bands represents the Donchian Channel.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
- Raises:
ValueError – If period is not positive (> 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Update the indicator with the given ticks high and low prices.
- Parameters:
tick (TradeTick) – The tick for the update.
- handle_trade_tick(self, TradeTick tick) void¶
Update the indicator with the given ticks price.
- Parameters:
tick (TradeTick) – The tick for the update.
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- lower¶
- middle¶
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low) void¶
Update the indicator with the given prices.
- Parameters:
high (double) – The price for the upper channel.
low (double) – The price for the lower channel.
- upper¶
- class KeltnerChannel¶
Bases:
IndicatorKeltnerChannel(int period, double k_multiplier, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, MovingAverageType ma_type_atr=MovingAverageType.SIMPLE, bool use_previous=True, double atr_floor=0)
The Keltner channel is a volatility based envelope set above and below a central moving average. Traditionally the middle band is an EMA based on the typical price (high + low + close) / 3, the upper band is the middle band plus the ATR. The lower band is the middle band minus the ATR.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
k_multiplier (double) – The multiplier for the ATR (> 0).
ma_type (MovingAverageType) – The moving average type for the middle band (cannot be None).
ma_type_atr (MovingAverageType) – The moving average type for the internal ATR (cannot be None).
use_previous (bool) – The boolean flag indicating whether previous price values should be used.
atr_floor (double) – The ATR floor (minimum) output value for the indicator (>= 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- k_multiplier¶
- lower¶
- middle¶
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- upper¶
- class KeltnerPosition¶
Bases:
IndicatorKeltnerPosition(int period, double k_multiplier, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, MovingAverageType ma_type_atr=MovingAverageType.SIMPLE, bool use_previous=True, double atr_floor=0)
An indicator which calculates the relative position of the given price within a defined Keltner channel. This provides a measure of the relative ‘extension’ of a market from the mean, as a multiple of volatility.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
k_multiplier (double) – The multiplier for the ATR (> 0).
ma_type (MovingAverageType) – The moving average type for the middle band (cannot be None).
ma_type_atr (MovingAverageType) – The moving average type for the internal ATR (cannot be None).
use_previous (bool) – The boolean flag indicating whether previous price values should be used.
atr_floor (double) – The ATR floor (minimum) output value for the indicator (>= 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- k_multiplier¶
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw value.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
- class VerticalHorizontalFilter¶
Bases:
IndicatorVerticalHorizontalFilter(int period, MovingAverageType ma_type=MovingAverageType.SIMPLE)
The Vertical Horizon Filter (VHF) was created by Adam White to identify trending and ranging markets.
- Parameters:
period (int) – The rolling window period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the indicator (cannot be None).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double close) void¶
Update the indicator with the given raw value.
- Parameters:
close (double) – The close price.
- value¶
- class VolatilityRatio¶
Bases:
IndicatorVolatilityRatio(int fast_period, int slow_period, MovingAverageType ma_type=MovingAverageType.SIMPLE, bool use_previous=True, double value_floor=0)
An indicator which calculates the ratio of different ranges of volatility. Different moving average types can be selected for the inner ATR calculations.
- Parameters:
fast_period (int) – The period for the fast ATR (> 0).
slow_period (int) – The period for the slow ATR (> 0 & > fast_period).
ma_type (MovingAverageType) – The moving average type for the ATR calculations.
use_previous (bool) – The boolean flag indicating whether previous price values should be used.
value_floor (double) – The floor (minimum) output value for the indicator (>= 0).
- Raises:
ValueError – If fast_period is not positive (> 0).
ValueError – If slow_period is not positive (> 0).
ValueError – If fast_period is not < slow_period.
ValueError – If value_floor is negative (< 0).
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- slow_period¶
- update_raw(self, double high, double low, double close) void¶
Update the indicator with the given raw value.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
- value¶
- class KlingerVolumeOscillator¶
Bases:
IndicatorKlingerVolumeOscillator(int fast_period, int slow_period, int signal_period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL)
This indicator was developed by Stephen J. Klinger. It is designed to predict price reversals in a market by comparing volume to price.
- Parameters:
fast_period (int) – The period for the fast moving average (> 0).
slow_period (int) – The period for the slow moving average (> 0 & > fast_sma).
signal_period (int) – The period for the moving average difference’s moving average (> 0).
ma_type (MovingAverageType) – The moving average type for the calculations.
- fast_period¶
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- signal_period¶
- slow_period¶
- update_raw(self, double high, double low, double close, double volume) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
volume (double) – The volume.
- value¶
- class OnBalanceVolume¶
Bases:
IndicatorOnBalanceVolume(int period=0)
An indicator which calculates the momentum of relative positive or negative volume.
- Parameters:
period (int) – The period for the indicator, zero indicates no window (>= 0).
- Raises:
ValueError – If period is negative (< 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double open, double close, double volume) void¶
Update the indicator with the given raw values.
- Parameters:
open (double) – The high price.
close (double) – The low price.
volume (double) – The close price.
- value¶
- class Pressure¶
Bases:
IndicatorPressure(int period, MovingAverageType ma_type=MovingAverageType.EXPONENTIAL, double atr_floor=0)
An indicator which calculates the relative volume (multiple of average volume) to move the market across a relative range (multiple of ATR).
- Parameters:
period (int) – The period for the indicator (> 0).
ma_type (MovingAverageType) – The moving average type for the calculations.
atr_floor (double) – The ATR floor (minimum) output value for the indicator (>= 0.).
- Raises:
ValueError – If period is not positive (> 0).
ValueError – If atr_floor is negative (< 0).
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- period¶
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double high, double low, double close, double volume) void¶
Update the indicator with the given raw values.
- Parameters:
high (double) – The high price.
low (double) – The low price.
close (double) – The close price.
volume (double) – The volume.
- value¶
- value_cumulative¶
- class VolumeWeightedAveragePrice¶
Bases:
IndicatorVolumeWeightedAveragePrice()
An indicator which calculates the volume weighted average price for the day.
- handle_bar(self, Bar bar) void¶
Update the indicator with the given bar.
- Parameters:
bar (Bar) – The update bar.
- handle_quote_tick(self, QuoteTick tick) void¶
Abstract method (implement in subclass).
- handle_trade_tick(self, TradeTick tick) void¶
Abstract method (implement in subclass).
- has_inputs¶
If the indicator has received inputs.
- Returns:
bool
- initialized¶
If the indicator is warmed up and initialized.
- Returns:
bool
- name¶
The name of the indicator.
- Returns:
str
- reset(self) void¶
Reset the indicator.
All stateful fields are reset to their initial value.
- update_raw(self, double price, double volume, datetime timestamp) void¶
Update the indicator with the given raw values.
- Parameters:
price (double) – The update price.
volume (double) – The update volume.
timestamp (datetime) – The current timestamp.
- value¶