R/manipulate_initial_data.R
manipulate_initial_data.RdThese 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
)Data frame. The investor's transactions data frame.
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.
Logical. If TRUE use reduce_transactions, otherwise use
aggregate_transactions to aggregate portfolio transactions.
Data frame containing the market prices.
Function to use to aggregate prices within
the round unit. Default to mean.
Character vector of the transaction assets.
POSIXct vector of the transaction datetimes.
Character. The name to be assigned to the investor.
Logical. If TRUE, subset_market_prices is used to generate
investor's data.
A modified version of the input data frame.
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.
closest_market_price,
lubridate::round_date