finmlkit.feature.transforms module¶
Feature transform wrapper for financial time series data.
- class finmlkit.feature.transforms.ADX(length: int = 14, input_cols: list[str] = None)[source]¶
Bases:
MISOTransformComputes the Average Directional Index (ADX) of price data.
ADX measures the strength of a trend (regardless of direction) on a scale from 0 to 100. Values below 20 indicate a weak trend, above 25 indicate a strong trend.
This implementation uses Wilder’s smoothing method for calculations.
- __init__(length: int = 14, input_cols: list[str] = None)[source]¶
Compute the Average Directional Index (ADX) of price data.
- Parameters:
length – Period for ADX calculation, default is 14
input_cols – List of column names for [high, low, close], defaults to [“high”, “low”, “close”]
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ATR(window: int = 14, ema_based: bool = False, normalize: bool = False, input_cols: list[str] = None)[source]¶
Bases:
MISOTransformComputes the Average True Range (ATR) of price data.
- __init__(window: int = 14, ema_based: bool = False, normalize: bool = False, input_cols: list[str] = None)[source]¶
Compute the Average True Range (ATR) of price data.
- Parameters:
window – int, lookback period for ATR calculation, default is 14
ema_based – bool, if True uses EMA calculation, if False uses SMA calculation
normalize – bool, if True normalizes ATR by mid price (avg of high and low)
input_cols – list of column names for [high, low, close], defaults to [“high”, “low”, “close”]
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ApproximateEntropy(window: int = 24, m: int = 2, tolerance: float = 0.2, input_col: str = 'ret1')[source]¶
Bases:
SISOTransformComputes the approximate entropy (ApEn) of a time series.
Approximate entropy measures the complexity or irregularity of a time series: - High ApEn values indicate high irregularity/unpredictability - Low ApEn values indicate regularity/structure/predictability
This implementation uses the antropy package for calculating ApEn.
- __init__(window: int = 24, m: int = 2, tolerance: float = 0.2, input_col: str = 'ret1')[source]¶
Compute the approximate entropy of a time series.
- Parameters:
window – The rolling window size for ApEn calculation
m – Embedding dimension (pattern length), default is 2
tolerance – Tolerance parameter, default is 0.2 (will be multiplied by std of window)
input_col – Input column to compute ApEn on (typically returns)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.BarDuration(periods=1, input_col: str = 'close')[source]¶
Bases:
SISOTransformThis transform calculates the time difference between consecutive bars in seconds.
- __init__(periods=1, input_col: str = 'close')[source]¶
Compute the EWMA of bar durations.
- Parameters:
input_col – Input column to use (only needed for timestamp extraction)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.BarDurationEWMA(span: int = 20, input_col: str = 'close')[source]¶
Bases:
SISOTransformComputes the Exponentially Weighted Moving Average (EWMA) of bar durations.
This transform calculates the time difference between consecutive bars and then applies an exponential moving average to these durations. It’s useful for: - Identifying periods of high/low trading activity - Normalizing other features based on time flow - Detecting regime changes in market microstructure
- __init__(span: int = 20, input_col: str = 'close')[source]¶
Compute the EWMA of bar durations.
- Parameters:
span – The span parameter for the EWM calculation, default is 20 (equivalent to alpha=2/(span+1))
input_col – Input column to use (only needed for timestamp extraction)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.BarRate(window: Timedelta, input_col: str = 'close')[source]¶
Bases:
SISOTransformCalculates the rate of bars (number of bars divided by time window) in a specified time window.
This is useful for: - Detecting rare “flurries” of activity (multiple jumps in short periods) - Distinguishing between normal and super-quiet market regimes - Identifying periods of unusual market activity
For example: - rate_6m: bars in last 6 min ÷ 360 s - Flags the rare flurries (2-3 jumps in a few minutes) - rate_30m: CUSUM bars in last 30 min ÷ 1800 s - Separates “normal” from “super-quiet” regimes
- __init__(window: Timedelta, input_col: str = 'close')[source]¶
Calculate the rate of bars in a specified time window.
- Parameters:
window_sec – Time window size in seconds
input_col – Input column to use (only needed for timestamp extraction)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.BiPowerVariation(window: int = 12, input_col: str = 'ret1')[source]¶
Bases:
SISOTransformComputes the bi-power variation (BV) of a return series.
Bi-power variation is used to estimate the integrated variance in the presence of jumps. It is calculated as the sum of the products of consecutive absolute returns, multiplied by a correction factor.
This is useful for: - Separating continuous and jump components of volatility - Creating jump-robust volatility estimators - Identifying the presence of jumps when compared to realized volatility
- __init__(window: int = 12, input_col: str = 'ret1')[source]¶
Compute the bi-power variation of a return series.
- Parameters:
window – The window size for the calculation (12 means 12 consecutive returns ≈ 60 minutes on 5-min grid)
input_col – Input column containing returns to compute BV on
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.BollingerPercentB(window: int, num_std: float = 2.0, input_col: str = 'close')[source]¶
Bases:
SISOTransformComputes the Bollinger Percent B of a time series.
- __init__(window: int, num_std: float = 2.0, input_col: str = 'close')[source]¶
Compute the Bollinger Percent B of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
num_std – Number of standard deviations for the Bollinger Bands.
window – Window size for the rolling calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.BurstRatio(window: int, input_col: str)[source]¶
Bases:
SISOTransformComputes the burst ratio of a time series using a rolling window.
- __init__(window: int, input_col: str)[source]¶
Compute the burst ratio of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
window – Window size for the rolling calculation.
- Returns:
series of burst ratios (same size as input)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.CUSUMTest(window_size: int = 50, warmup_period: int = 30, max_age: int = 144, input_col: str = 'close')[source]¶
Bases:
SIMOTransformComputes the CUSUM test statistics for structural breaks in time series.
Features include: - Break indicators (snt - critical values): Positive when a break is detected - Flag features: Binary indicator when a break is detected (1 when break just fired, else 0) - Score features: Magnitude of the break, clipped to ±10 σ_noise - Age features: Number of bars since the last break, capped at a maximum value
- __init__(window_size: int = 50, warmup_period: int = 30, max_age: int = 144, input_col: str = 'close')[source]¶
Compute the CUSUM test statistics for structural breaks in time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute the CUSUM test on.
window_size – Size of the rolling window for CUSUM test, by default 50.
warmup_period – Minimum number of observations before the first statistic is calculated, by default 30.
max_age – Maximum age to track since last break (in bars), by default 144 (12h in 5-min bars).
- _abc_impl = <_abc._abc_data object>¶
- _pd(x)[source]¶
Transform the input data using pandas. For fast prototyping :param x: DataFrame or Series to transform
- property output_name¶
Get the output names of the transform. For SIMO transforms, the output names are derived from the input column name. :return: List of output names
- class finmlkit.feature.transforms.CandleShape(input_cols: list[str] = None)[source]¶
Bases:
MIMOTransformComputes various candle shape metrics to characterize price action.
Features include: - wick_up_ratio: Ratio of upper wick to total candle range - wick_dn_ratio: Ratio of lower wick to total candle range - body_ratio: Ratio of candle body to total candle range - vwap_drift: Percentage difference between VWAP and open price
- __init__(input_cols: list[str] = None)[source]¶
Calculate various candle shape metrics.
- Parameters:
input_cols – List of column names for [open, high, low, close, vwap], defaults to [“open”, “high”, “low”, “close”, “vwap”]
- _abc_impl = <_abc._abc_data object>¶
- _pd(x: DataFrame) tuple[Series, ...][source]¶
Pandas implementation of candle shape metrics.
- Parameters:
x – Input DataFrame with OHLCV data
- Returns:
Tuple of Series containing the calculated metrics
- property output_name¶
Get the output names of the transform. :return: List of output names
- class finmlkit.feature.transforms.DailyGap(input_col: str = 'close')[source]¶
Bases:
SISOTransformCalculates the overnight UTC gap between the close price at 00:00 and the previous day’s close at 23:45. Formula: (close_{00:00} - close_{23:45_prev}) / close_{23:45_prev}
This assumes the input data is in 15-minute intervals and is UTC-aligned.
- __init__(input_col: str = 'close')[source]¶
Calculate the overnight (UTC) gap in price.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute the gap on
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.DirRunLen(input_col: str = 'ret1')[source]¶
Bases:
SISOTransformCounts consecutive same-sign returns until just before the current bar.
The streak resets when the sign changes or when a return is 0. The count indicates the length of the streak of consecutive returns with the same sign.
- __init__(input_col: str = 'ret1')[source]¶
Initialize the directional run length transform.
- Parameters:
input_col – Input column containing returns
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.EWMA(span: int, input_col: str = None)[source]¶
Bases:
SISOTransformComputes the Exponentially Weighted Moving Average (EWMA) of a time series.
- __init__(span: int, input_col: str = None)[source]¶
Compute the Exponentially Weighted Moving Average (EWMA) of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
span – The decay window, or ‘span’. Determines how many past points meaningfully impact the EWMA value.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.EWMST(half_life: Timedelta, input_col: str = 'y')[source]¶
Bases:
SISOTransformComputes the exponentially weighted moving standard deviation of a time series.
- __init__(half_life: Timedelta, input_col: str = 'y')[source]¶
Compute the exponentially weighted moving standard deviation.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
half_life_sec – Period for the moving standard deviation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ExternalFunction(func: str | Callable, input_cols: str | Sequence[str], output_cols: str | Sequence[str] | None = None, *, args: Sequence[Any] | None = None, kwargs: dict | None = None, pass_numpy: bool = False)[source]¶
Bases:
BaseTransformWrap an external Python callable (by object or import path) as a Transform.
This enables integrating third-party libraries (e.g., NumPy, TA-Lib) into the Feature/FeatureKit pipelines while preserving consistent input/output handling and enabling serialization.
Notes:
For multiple outputs (functions returning a tuple/list), you must provide output_cols with matching length.
If pass_numpy=True, the callable receives NumPy arrays instead of pandas Series, which improves compatibility/performance for libraries expecting ndarrays (e.g., TA-Lib).
- __init__(func: str | Callable, input_cols: str | Sequence[str], output_cols: str | Sequence[str] | None = None, *, args: Sequence[Any] | None = None, kwargs: dict | None = None, pass_numpy: bool = False)[source]¶
Initialize the ExternalFunction transform. This transform wraps an external Python function or import path to be used as a Transform in the Feature/FeatureKit pipeline.
- Parameters:
func – String import path or callable object to wrap.
input_cols – Columns required as input for the function.
output_cols – Columns produced by the function.
args – Additional positional arguments to pass to the function.
kwargs – Additional keyword arguments to pass to the function.
pass_numpy – If True, the function receives NumPy arrays instead of pandas Series.
- _abc_impl = <_abc._abc_data object>¶
- _validate_input(x: DataFrame) bool[source]¶
Check if the input columns are present in the input DataFrame. This method is called before applying the transform.
- Parameters:
x – DataFrame to validate
- Returns:
True if the input is valid
- property output_name: str | list[str]¶
Get the output names of the transform. This is used to determine the output column names in the DataFrame. Used by prepare_output_nb to create the output Series. :return: Output name or list of output names
- class finmlkit.feature.transforms.FlowAcceleration(window: int, recent_periods, input_col: str = 'volume')[source]¶
Bases:
SISOTransformComputes the Flow Acceleration of a time series.
- __init__(window: int, recent_periods, input_col: str = 'volume')[source]¶
Compute the Flow Acceleration of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
window – Window size for the rolling calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.HurstExponent(window: int = 24, input_col: str = 'ret1')[source]¶
Bases:
SISOTransformComputes the Hurst exponent of a time series using the aggregated variance method.
The Hurst exponent (H) is a measure of the long-term memory of a time series: - H > 0.5 indicates a persistent/trending price path - H = 0.5 indicates a random walk (Brownian motion) - H < 0.5 indicates a mean-reverting/noisy series
This implementation uses the aggregated variance method to estimate H.
- __init__(window: int = 24, input_col: str = 'ret1')[source]¶
Compute the Hurst exponent using the aggregated variance method.
- Parameters:
window – The rolling window size to compute the Hurst exponent
input_col – The input column to compute the Hurst exponent on (typically returns)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.Identity(input_col: str = 'close')[source]¶
Bases:
BaseTransformReturns the identity transform of a selected column
- __init__(input_col: str = 'close')[source]¶
Identity transform that returns the input column as is.
- Parameters:
input_col – If DataFrame is passed, this is the column name to return.
- _abc_impl = <_abc._abc_data object>¶
- _validate_input(x: DataFrame) bool[source]¶
Check if the input columns are present in the input DataFrame. This method is called before applying the transform.
- Parameters:
x – DataFrame to validate
- Returns:
True if the input is valid
- property output_name: str¶
Returns the name of the output column.
- class finmlkit.feature.transforms.KurtosisTransform(window: int = 32, input_col: str = 'ret1')[source]¶
Bases:
SISOTransformComputes the rolling excess kurtosis of returns.
Excess kurtosis measures the “tailedness” of a distribution compared to a normal distribution. Positive values indicate fat tails (more extreme values than normal distribution). Useful for identifying fat-tail regimes (liquidations) that can hurt naive swing trading strategies.
- __init__(window: int = 32, input_col: str = 'ret1')[source]¶
Compute the rolling excess kurtosis of returns.
- Parameters:
window – Window size for rolling kurtosis calculation, default is 32
input_col – Input column to compute kurtosis on, expected to be returns, default is “ret1”
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.Lag(periods: int = 1, input_col: str = 'close')[source]¶
Bases:
SISOTransformImplements lagged values of a time series.
- __init__(periods: int = 1, input_col: str = 'close')[source]¶
Compute lagged values over the specified number of periods.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute lags on.
periods – The lag period.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.MeanReversionZScore(window: int = 48, input_col: str = 'close')[source]¶
Bases:
SISOTransformCalculates the z-score of price relative to its simple moving average. Formula: (close - SMA_window)/std_window Used as a mean-reversion filter to identify potential mean-reversion opportunities.
- __init__(window: int = 48, input_col: str = 'close')[source]¶
Calculate the z-score of price relative to its simple moving average.
- Parameters:
window – The window size for SMA and standard deviation calculation
input_col – If DataFrame is passed, this is the column name to compute z-score on
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ORBBreak(input_cols: list[str] = None)[source]¶
Bases:
MIMOTransformDetects Opening Range Breakout (ORB) signals within a UTC day.
An ORB occurs when the price breaks above the high or below the low of the first hour of trading. The transform returns two signals: a long signal (1 when price breaks above opening range high, otherwise 0) and a short signal (1 when price breaks below opening range low, otherwise 0).
This implementation assumes the input data is in 15-minute intervals and is UTC-aligned. The opening range is defined as the first 4 bars (first hour) of each UTC day.
- __init__(input_cols: list[str] = None)[source]¶
Calculate Opening Range Breakout signals
- Parameters:
input_cols – List of column names for [high, low, close], defaults to [“high”, “low”, “close”]
- _abc_impl = <_abc._abc_data object>¶
- _pd(x: DataFrame) tuple[Series, Series][source]¶
Transform the input data using pandas. For fast prototyping :param x: DataFrame or Series to transform
- property output_name¶
Get the output names of the transform. :return: List of output names
- class finmlkit.feature.transforms.ParkinsonRange(input_cols=None)[source]¶
Bases:
MISOTransformComputes the Parkinson range of a time series.
- __init__(input_cols=None)[source]¶
Compute the Parkinson range of a time series.
- Parameters:
input_cols – High and Low columns. If None defaults to [“high”, “low”].
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.PctChange(window: int, input_col: str = 'close')[source]¶
Bases:
SISOTransformComputes the percentage change of a time series using a specified lag.
- __init__(window: int, input_col: str = 'close')[source]¶
Calculate the percentage change of a signal with a specified lag.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
periods – The lag period.
- Returns:
The percentage change of the signal.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.PriceVolumeCorrelation(window: int = 8, input_cols: list[str] = None)[source]¶
Bases:
MISOTransformCalculates the rolling Pearson correlation coefficient between price returns and volume.
- __init__(window: int = 8, input_cols: list[str] = None)[source]¶
Compute the rolling correlation between price returns and volume.
- Parameters:
window – int, lookback period for correlation calculation, default is 8
input_cols – list of column names for [close, volume], defaults to [“close”, “volume”]
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ROC(periods: int, input_col: str = 'close')[source]¶
Bases:
SISOTransformComputes the Rate of Change (ROC) of a time series.
- __init__(periods: int, input_col: str = 'close')[source]¶
Compute the Rate of Change (ROC) of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
periods – The lag periods for the ROC calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.RSIWilder(window: int = 14, input_col: str = 'close')[source]¶
Bases:
SISOTransformComputes the Relative Strength Index (RSI) of a time series using Wilder’s smoothing method.
- __init__(window: int = 14, input_col: str = 'close')[source]¶
Compute the Relative Strength Index (RSI) of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute RSI on.
window – Window size for the RSI calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.RealizedVolatility(window: int, is_sample=False, input_col: str = 'ret')[source]¶
Bases:
SISOTransformComputes the realized volatility of a time series.
- __init__(window: int, is_sample=False, input_col: str = 'ret')[source]¶
Compute the realised volatility of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
is_sample – If True, use sample standard deviation. If False, use population standard deviation.
window – Window size for the rolling calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.Return(periods: int = 1, input_col: str = 'close', is_log: bool = False)[source]¶
Bases:
SISOTransformImplements lagged return
- __init__(periods: int = 1, input_col: str = 'close', is_log: bool = False)[source]¶
Compute lagged returns over the specified number of periods.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
periods – The lag period.
is_log – If True, compute log returns. Otherwise, compute simple returns.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ReturnT(window: Timedelta = Timedelta('0 days 00:00:00.000001'), is_log: bool = False, input_col: str = 'close')[source]¶
Bases:
SISOTransformCalculates the lagged returns of a time series using a specified period defined in seconds. Works for irregular time series too.
- __init__(window: Timedelta = Timedelta('0 days 00:00:00.000001'), is_log: bool = False, input_col: str = 'close')[source]¶
Compute lagged returns over the specified time window. Works for unregular time series too.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
window – Period in for the lagged returns. Set it to a small value (e.g. 1e-6) for 1 sample lag.
is_log – If True, compute log returns. Otherwise, compute simple returns.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.SMA(window: int, input_col: str = 'x')[source]¶
Bases:
SISOTransformComputes the Simple Moving Average (SMA) of a time series.
- __init__(window: int, input_col: str = 'x')[source]¶
Compute the Simple Moving Average (SMA) of a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
window – Window size for the rolling calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.StochK(length: int = 14, input_cols: list[str] = None)[source]¶
Bases:
MISOTransformComputes the Stochastic Oscillator %K of a time series.
- __init__(length: int = 14, input_cols: list[str] = None)[source]¶
Compute the Stochastic Oscillator %K of a time series.
- Parameters:
input_cols – If DataFrame is passed, this is the column names to compute %K on. Default is [“high”, “low”, “close”].
length – The lookback period for the stochastic calculation.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.TimeCues(input_col: str = 'close')[source]¶
Bases:
SIMOTransformComputes time-based features for a time series.
- __init__(input_col: str = 'close')[source]¶
Compute time-based features for a time series.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
- _abc_impl = <_abc._abc_data object>¶
- _pd(x)[source]¶
Transform the input data using pandas. For fast prototyping :param x: DataFrame or Series to transform
- property output_name¶
Get the output names of the transform. For SIMO transforms, the output names are derived from the input column name. :return: List of output names
- class finmlkit.feature.transforms.TrendSlope(window: int = 24, input_col: str = 'close')[source]¶
Bases:
SISOTransformComputes the OLS slope of ln(close) over a specified window and converts it to an angle in degrees.
This is useful as a trend indicator where the angle represents how steep the trend is. Positive angles indicate uptrend, negative angles indicate downtrend, and the magnitude represents the steepness of the trend.
- __init__(window: int = 24, input_col: str = 'close')[source]¶
Compute the OLS slope of ln(close) over a specified window and convert to an angle in degrees.
- Parameters:
window – Window size for the rolling OLS calculation, default is 24
input_col – Input column to compute slope on, default is “close”
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.VPIN(window: int = 32, input_cols: list[str] = None)[source]¶
Bases:
MISOTransformCalculates the VPIN (Volume-synchronized Probability of Informed Trading) metric. VPIN measures the fraction of signed volume imbalance to total volume in a rolling window.
- __init__(window: int = 32, input_cols: list[str] = None)[source]¶
Compute the VPIN metric over a specified window.
- Parameters:
window – int, lookback period for VPIN calculation, default is 32
input_cols – list of column names for [volume_buy, volume_sell], defaults to [“volume_buy”, “volume_sell”]
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.VWAPDistance(periods: int, is_log: bool = False, input_cols: str = None)[source]¶
Bases:
MISOTransformComputes the distance of the current price from the VWAP (Volume Weighted Average Price).
- __init__(periods: int, is_log: bool = False, input_cols: str = None)[source]¶
Calculate the distance of the current price from the VWAP (Volume Weighted Average Price).
- Parameters:
input_cols – close and volume columns. Default is [“close”, “volume”] when None.
periods – Number of periods to calculate VWAP.
is_log – If True, calculate log distance.
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.VarianceRatio14(window: int = 32, input_col: str = 'close', ret_type: str = 'log', ddof: int = 0)[source]¶
Bases:
SISOTransformComputes the Variance Ratio of 1-bar returns to 4-bar returns: var(1-bar) / var(4×1-bar).
This is a useful metric to detect microstructure noise vs trending behavior. For random walks, the ratio should be close to 0.25 (1/4). Values < 0.25 suggest mean reversion, while values > 0.25 suggest trending/momentum.
- __init__(window: int = 32, input_col: str = 'close', ret_type: str = 'log', ddof: int = 0)[source]¶
Compute the variance ratio var(1-bar return) / var(4×1-bar return)
- Parameters:
window – Window size for variance calculation, default is 32
input_col – Column to compute the ratio on, default is “close”
ret_type – Type of returns, “simple” or “log”, default is “log”
ddof – Delta degrees of freedom for variance calculation, default is 0 (sample variance)
- _abc_impl = <_abc._abc_data object>¶
- class finmlkit.feature.transforms.ZScore(window: int, input_col: str, ddof: int = 0)[source]¶
Bases:
SISOTransformComputes the z-score of a time series using a rolling window.
- __init__(window: int, input_col: str, ddof: int = 0)[source]¶
Compute the z-score of a time series using a rolling window.
- Parameters:
input_col – If DataFrame is passed, this is the column name to compute returns on.
window – Window size for the rolling calculation.
ddof – Delta degrees of freedom for standard deviation calculation.
- _abc_impl = <_abc._abc_data object>¶