Learn R Programming

PortfolioTesteR (version 0.1.4)

align_to_timeframe: Align Data to Strategy Timeframe

Description

Aligns higher-frequency data to match strategy timeframe.

Usage

align_to_timeframe(
  high_freq_data,
  low_freq_dates,
  method = c("forward_fill", "nearest", "interpolate")
)

Value

Aligned data frame

Arguments

high_freq_data

Data frame to align

low_freq_dates

Date vector from strategy

method

Alignment method: "forward_fill", "nearest", or "interpolate"

Examples

Run this code
data("sample_prices_weekly")
data("sample_prices_daily")
momentum <- calc_momentum(sample_prices_weekly, lookback = 12)
selected <- filter_top_n(momentum, 10)
# Create a stability signal from daily data
daily_vol <- calc_rolling_volatility(sample_prices_daily, lookback = 20)
stability_signal <- align_to_timeframe(daily_vol, sample_prices_weekly$Date)
weights <- weight_by_signal(selected, stability_signal)

Run the code above in your browser using DataLab