Utils API Reference
KPI Utility Functions
This module provides utility functions for calculating Key Performance Indicators (KPIs) for financial time series analysis.
            diff(data, periods=1)
    Calculate difference between consecutive values.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| periods | int | Number of periods to calculate difference over | 1 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Difference values | 
            log(data)
    Calculate the natural logarithm of price data.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | array - like | Input price data as list or numpy array | required | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Natural logarithm of the input data. Returns NaN for any non-positive values. | 
            rolling_kurtosis(data, period=14)
    Calculate rolling kurtosis over a specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for rolling kurtosis | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Rolling kurtosis values | 
            rolling_max(data, period=14)
    Calculate rolling maximum over a specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for rolling maximum | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Rolling maximum values | 
            rolling_min(data, period=14)
    Calculate rolling minimum over a specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for rolling minimum | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Rolling minimum values | 
            rolling_skew(data, period=14)
    Calculate rolling skewness over a specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for rolling skewness | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Rolling skewness values | 
            rolling_std(data, period=14)
    Calculate rolling standard deviation over a specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for rolling standard deviation | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Rolling standard deviation values | 
            rolling_var(data, period=14)
    Calculate rolling variance over a specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for rolling variance | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Rolling variance values | 
            slope(data, period=5)
    Calculate the slope of the time series over a specified period.
This function uses linear regression to calculate the slope of the line that best fits the data over the specified period.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Number of points to use for slope calculation | 5 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Slope values for each point in the time series | 
            typical_price(close, high, low)
    Calculate the typical price from close, high, and low prices.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| close | ndarray | Close prices | required | 
| high | ndarray | High prices | required | 
| low | ndarray | Low prices | required | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Typical price values | 
            zscore(data, period=14)
    Calculate rolling Z-score over a specified period.
Z-score measures how many standard deviations a data point is from the mean.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | ndarray | Input time series data | required | 
| period | int | Window size for Z-score calculation | 14 | 
Returns:
| Type | Description | 
|---|---|
| ndarray | Z-score values |