Cumulative Return
Syntax
Description
The cmr
function calculates the Cumulative Returns (CMR) for a given symbol over a specified period. CMR represents the total percentage change in price over the specified period, including both price appreciation and dividends. The function can also be applied directly to an array of numerical data to calculate the CMR.
Returns
The cmr
function returns a single CMR value by default. If the rolling
option is specified, it returns an array of CMR values for the specified rolling period.
Parameters
len
: The length of the period over which to calculate the CMR.symbol
: The symbol for which to calculate the CMR.options?
(optional): An object with the following optional properties:rolling
: The number of days for which to return the CMR values. If specified, an array of CMR values is returned.offset
: The number of days ago to start the calculation. Default is 0 (current day).prop
: The property of the data to use for calculation. Default is'close'
. This option is only applicable when using with symbol.
Examples
Using with Symbol and Length
Using with Data Array
Use Cases
Evaluating Historical Performance:
Comparing Performance Across Securities:
Notes
- The
cmr
function is a useful tool for evaluating historical performance and comparing returns across different securities or portfolios. - CMR is calculated as the cumulative percentage change in price over the specified period, making it a valuable metric for assessing investment performance.
- Traders and investors often use CMR to analyze past performance trends and make informed decisions about future investments.