deephaven.MovingAverages¶
Deephaven moving averages. See the java classes in com.illumon.numerics.movingaverages for more details on Deephaven moving averages.
-
ByEmaSimple
(nullBehavior, nanBehavior, mode, timeScale, timeUnit, type=None)¶ Constructor for a DB aware Exponential Moving Average (EMA) which performs a by ema calculation without the added inefficiency of explicitly performing the grouping and then ungrouping operations.
- Parameters
nullBehavior – enum value ‘BD_RESET’, ‘BD_SKIP’, ‘BD_PROCESS’ which determines calculation behavior upon encountering a null value.
nanBehavior – enum value ‘BD_RESET’, ‘BD_SKIP’, ‘BD_PROCESS’ which determines calculation behavior upon encountering a null value.
mode – enum value ‘TICK’, ‘TIME’ specifying whether to calculate the ema with respect to record count or elapsed time.
timeScale – the ema decay constant.
timeUnit – None (assumed Nanoseconds), or one of the java.util.concurrent.TimeUnit enum values - like ‘MILLISECONDS’, ‘SECONDS’, ‘MINUTES’, ‘HOURS’, …
type – None or enum value ‘LEVEL’, ‘DIFFERENCE’.
- Returns
com.illumon.numerics.movingaverages.ByEmaSimple instance.
-
Ema
(type, mode, timeScale)¶ Constructor for a Exponential Moving Average (EMA) calculation object.
- Parameters
type – None or enum value ‘LEVEL’, ‘DIFFERENCE’.
mode – enum value ‘TICK’, ‘TIME’ specifying whether to calculate the ema with respect to record count or elapsed time.
timeScale – the ema decay constant (wrt nanosecond timestamp).
- Returns
com.illumon.numerics.movingaverages.Ema instance.
-
EmaArray
(type, mode, timeScales)¶ Constructor for object managing an array of Exponential Moving Average (EMA) objects.
- Parameters
type – enum value ‘LEVEL’, ‘DIFFERENCE’.
mode – enum value ‘TICK’, ‘TIME’ specifying whether to calculate the ema with respect to record count or elapsed time.
timeScales – the ema decay constants (wrt nanosecond timestamp) - list, tuple, numpy.ndarray, or java double array.
- Returns
com.illumon.numerics.movingaverages.EmaArray instance.
-
ExponentiallyDecayedSum
(decayRate, enableTimestepOutOfOrderException=True)¶ Constructor for an object to calculate a sum where the values are decayed at an exponential rate to zero.
- Parameters
decayRate – (double) rate in milliseconds to decay the sum.
enableTimestepOutOfOrderException – (boolean) true to allow an exception to be thrown when timesteps are not sequential.
- Returns
com.illumon.numerics.movingaverages.ExponentiallyDecayedSum instance.
-
NeighborEmaArrayDifferencer
(emaMode, emaTimescales, includeDifferenceWithCurrentValue)¶ Constructor for an object which manages and differences an array of emas.
- Parameters
emaMode – enum value ‘TICK’, ‘TIME’ specifying whether to calculate the ema with respect to record count or elapsed time.
emaTimescales – timescales for the emas (wrt nanoseconds) - list, tuple, numpy.ndarray, or java double array.
includeDifferenceWithCurrentValue – true includes the difference between the latest input value and the first ema in the output results; false does not.
- Returns
com.illumon.numerics.movingaverages.NeighborEmaArrayDifferencer instance.
-
TradingHoursEma
(type, mode, timeScale, tradingHours, gapTolerance=None)¶ Constructor for a simple ema calculation object which decays with trading time and only accepts samples during trading hours.
..Note: This is intended to be used when sampling is frequent.
- Parameters
type – enum value ‘LEVEL’, ‘DIFFERENCE’.
mode – enum value ‘TICK’, ‘TIME’ specifying whether to calculate the ema with respect to record count or elapsed time.
timeScale – timescale for the EMA.
tradingHours – object which implements (com.illumon.numerics.movingaverages.TradingHours) interface.
gapTolerance – double - time gap beyond which to restart the ema calculation - e.g. for a new trading day.
- Returns
com.illumon.numerics.movingaverages.TradingHoursEma instance.