Published on :
Finance EXTERNAL

Martin_Ratio Macro

This code is also available in: Deutsch Español Français
Awaiting validation
This macro calculates the Martin Ratio by dividing the annualized excess return by the Ulcer Index. It orchestrates calls to several utility macros (%return_excess, %return_annualized, %Ulcer_Index) and combines the results via a DATA step using the LAG function to perform the division between the stacked results.
Data Analysis

Type : EXTERNAL


Input data is provided via the macro parameter 'returns'.

1 Code Block
MACRO
Explanation :
Definition of the macro accepting data parameters (returns), risk-free rate (Rf), time scale, and calculation method.
Copied!
1%macro Martin_Ratio(returns, Rf= 0, scale= 1, method= DISCRETE, dateColumn= DATE, outData= MartinRatio);
2... %mend;
3 
2 Code Block
MACRO CALL
Explanation :
Calls to underlying macros to calculate excess returns, annualize them, and compute the Ulcer Index.
Copied!
1%return_excess(...);
2%return_annualized(...);
3%Ulcer_Index(...);
4 
3 Code Block
DATA STEP Data
Explanation :
Stacks annualized results and the Ulcer Index. Uses the LAG function to divide the value from the first table (return) by that from the second (risk) to obtain the ratio.
Copied!
1DATA &outData (drop= &i);
2 SET &annualized &ulcer_index;
3 array Ulcer[*] &vars;
4 DO &i= 1 to dim(Ulcer);
5 Ulcer[&i]= lag(Ulcer[&i])/Ulcer[&i];
6 END;
7RUN;
4 Code Block
DATA STEP Data
Explanation :
Finalization of the output table: adding the '_STAT_' label and keeping only the last observation containing the calculated ratio.
Copied!
1DATA &outData;
2 FORMAT _stat_ $32.;
3 SET &outData END= last;
4 _STAT_= 'Martin Ratio';
5 IF last;
6RUN;
5 Code Block
PROC DATASETS
Explanation :
Deletion of temporary work tables.
Copied!
1PROC DATASETS lib=work nolist;
2 delete &ulcer_index &annualized;
3RUN;
4QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright (c) 2015 by The Financial Risk Group, Cary, NC, USA.