These functions allows to pre-process transactions and market prices data frames performing aggregation and subsetting operations.

aggregate_transactions(portfolio_transactions, unit = "1 mins")

reduce_transactions(portfolio_transactions, unit = "1 mins")

clean_transactions(portfolio_transactions, unit = "1 mins", reduce = FALSE)

aggregate_market_prices(market_prices, unit = NULL, aggregate_price_fun = mean)

subset_market_prices(
  market_prices,
  portfolio_assets,
  portfolio_datetimes,
  unit = NULL
)

generate_data(
  portfolio_transactions,
  market_prices,
  investor_name = NULL,
  unit = NULL,
  subset = FALSE
)

Arguments

portfolio_transactions

Data frame. The investor's transactions data frame.

unit

Character string specifying a time unit or a multiple of a unit to be rounded to. Valid base units are second, minute, hour, day, week, etc. See lubridate::round_date.

reduce

Logical. If TRUE use reduce_transactions, otherwise use aggregate_transactions to aggregate portfolio transactions.

market_prices

Data frame containing the market prices.

aggregate_price_fun

Function to use to aggregate prices within the round unit. Default to mean.

portfolio_assets

Character vector of the transaction assets.

portfolio_datetimes

POSIXct vector of the transaction datetimes.

investor_name

Character. The name to be assigned to the investor.

subset

Logical. If TRUE, subset_market_prices is used to generate investor's data.

Value

A modified version of the input data frame.

Functions

  • aggregate_transactions: Aggregate the data frame of investors' transactions that happened at the same datetime.

  • reduce_transactions: Reduce the data frame of investors' transactions by aggregating those transactions that happened within a time interval.

  • clean_transactions: Clean the data frame of investors' transactions.

  • aggregate_market_prices: Aggregate the data frame of market prices with a specific aggregate function within a time interval.

  • subset_market_prices: Subset the data frame of market prices based on investor's traded assets and datetimes of transactions.

  • generate_data: Generate investors' data from transactions and market prices.

See also