time_volume_weights: Compute Time Weights from Trading Volumes

View source: R/time-volume-weights.R

time_volume_weightsR Documentation

Compute Time Weights from Trading Volumes

Description

Aggregates numeric volume columns row-wise and converts the aggregate volume profile into non-negative time weights.

Usage

time_volume_weights(
  volume_df,
  date_col = NULL,
  alpha = 1,
  normalize = TRUE,
  eps = 1e-08,
  winsorize = FALSE,
  winsor_q = 0.99
)

Arguments

volume_df

A data frame containing one or more numeric volume columns.

date_col

Optional name of a date column to exclude from the numeric volume aggregation and use as output names.

alpha

Non-negative exponent applied to aggregate volume scores. Values below 1 compress high-volume observations; values above 1 emphasize them.

normalize

Logical. If TRUE, return weights summing to one.

eps

Small positive offset added before exponentiation.

winsorize

Logical. If TRUE, cap aggregate volumes at winsor_q.

winsor_q

Quantile used as the cap when winsorize = TRUE.

Value

A numeric vector of weights, named by date_col when supplied.

Examples

vol <- data.frame(day = as.Date("2024-01-01") + 0:2, a = c(10, 20, 30), b = c(5, 5, 10))
time_volume_weights(vol, date_col = "day")

CRAFT documentation built on Nov. 2, 2026, 9:06 a.m.