txn_dates: Function for getting the final day of asset membership with...

Description Usage Arguments Details Note

Description

Finds the last trading day (with recorded data) for each asset each period (e.g. month).

Usage

1
2
txn_dates(df, membership = TRUE, hist_members = newHM, on = "months",
  ind = NULL)

Arguments

df

xts object containing price series of assets to rank. Every column will be treated as an independent asset. Column names of assets to rank must also appear in column names of 'hist_members'

membership

If FALSE will ignore asset membership and return last day of period with data.

hist_members

xts object containing membership data. Column names are assumed to be asset names corresponding to those in df. Note: All entries not NA are assumed to represent active membership.

on

Desired return periodicity (string). Passed to xts::endpoints. Ignored if 'ind' is provided.

ind

Optional date series to use as period end points. Used in place of 'ind'.

Details

Returns a dataframe with sepearate 'Date' column. This is last day of the given trading period. The remaining columns are the asset columns. The asset columns contain the last trading date for the given month, for which the asset was a member.

Note

Much of the apparant complexity/ugliness in this fuction is to deal with the case in which there is no price data in the current month. We could just return an NA in all these cases, but there is the special case in which this is not ideal: If the last day with membership and/or price data falls on the end point of the previous period. Because positions are often evaluated and entered based on end-of-period points, there is the possibility that we could have entered such a position, and then have no reference point for exit price or date the next period when we realise there is no longer membership or data.


T-Marty/trademartyr documentation built on May 31, 2019, 5:10 p.m.