-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finance metrics and median calculation #1289
Merged
Merged
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
18b9245
current with median
JiaZhou-PU 522f089
Merge branch 'devel' into ppvar
JiaZhou-PU 8072084
finished metrics, update percentile and median
JiaZhou-PU 13f9857
restore originfile
JiaZhou-PU 11eb27c
add manual
JiaZhou-PU 051a1f0
change index
JiaZhou-PU dc04739
regold percentile
JiaZhou-PU 61a2d15
reverse sensitivity
JiaZhou-PU 37cd08e
delete trailing white space
JiaZhou-PU f3cfb88
fix tests
JiaZhou-PU 6ea1983
fixed pptest
JiaZhou-PU 9f1f9e8
add ad hoc
JiaZhou-PU d83d24a
rm debugprint
JiaZhou-PU b65d0c4
rm whitespace
JiaZhou-PU 30eb3dc
adhoc PP
JiaZhou-PU 979f995
rm in basicstat
JiaZhou-PU 82cf3fc
wrap up
JiaZhou-PU 8794a93
fix typo
JiaZhou-PU 71cc6d2
remove features
JiaZhou-PU 00b99fb
test git setup
JiaZhou-PU ee02ddf
Merge branch 'devel' into ppvar
JiaZhou-PU 4a0c149
remove redundant
JiaZhou-PU 9547d0d
rm white space
JiaZhou-PU c96f2e9
Merge branch 'devel' into ppvar
JiaZhou-PU c861477
add percentile tests
JiaZhou-PU 0c1a4b4
add description
JiaZhou-PU dac138b
move runinfo
JiaZhou-PU e113d8d
fix typo
JiaZhou-PU 295e9f4
Update test_median_and_percentile.xml
alfoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
\subsubsection{EconomicRatio} | ||
\label{EconomicRatio} | ||
The \xmlNode{EconomicRatio} post-processor provides the economic metrics from the percent change | ||
period return of the asset or strategy that is given as an input. These metrics measure the risk-adjusted returns. | ||
% | ||
\ppType{EconomicRatio}{EconomicRatio} | ||
|
||
\begin{itemize} | ||
\item \xmlNode{"metric"}, \xmlDesc{comma separated string or node list, required field}, | ||
specifications for the metric to be calculated. The name of each node is the requested metric. | ||
The text of the node is a comma-separated list of the parameters for which the metric should be calculated. | ||
|
||
Currently the scalar quantities available for request are: | ||
\begin{itemize} | ||
|
||
\item \textbf{sharpeRatio}: the Sharpe Ratio, measures the performance of an investment. It is defined as the historical returns of the investment, divided by the standard deviation of the investment(Volatility). | ||
\item \textbf{sortinoRatio}: the Sortino ratio, measures the risk-adjusted return of an investment asset. Discounts the excess return of a portfolio above a target threshold by the volatility of downside returns. If this quantity is inputted as \textit{sortinoRatio} the threshold for separate upside and downside value will assign as $0$. Otherwise the user can specify this quantity with a parameter \xmlAttr{threshold='X'}, where the \xmlAttr{X} represents the requested threshold \xmlAttr{median} or \xmlAttr{zero}. | ||
|
||
\item \textbf{gainLossRatio}: the gain-loss ratio, discounts the first-order higher partial moment of a portfolio's returns, by the first-order lower partial moment of a portfolio's returns. If this quantity is inputted as \textit{gainLossRatio} the threshold for separate upside and downside value will assign as $0$. Otherwise the user can specify this quantity with a parameter \xmlAttr{threshold='X'}, where the \xmlAttr{X} represents the requested threshold \xmlAttr{median} or \xmlAttr{zero}. | ||
|
||
|
||
\item \textbf{expectedShortfall}: the expected shortfall (Es) or conditional value at risk (CVaR), the expected return on the portfolio in the worst q of cases. If this quantity is inputted as \textit{ExpectedShortfall} the q value will assign as $5\%$. Otherwise the user can specify this quantity with a parameter \xmlAttr{threshold='X'}, where the \xmlAttr{X} represents the requested q value (a floating point value between 0.0 and 1.0) | ||
\begin{equation} | ||
ES_\alpha = -\frac{1}{\alpha} \int_0^\alpha \operatorname{VaR}_\gamma(X) \, d\gamma | ||
\end{equation} | ||
\item \textbf{valueAtRisk}: the value at risk for investments. Estimates the maximum possible loss after exclude worse outcomes whose combined probability is at most $\alpha$. If this quantity is inputted as \textit{ValueAtRisk} the $\alpha$ value will assign as $5\%$. Otherwise the user can specify this quantity with a parameter \xmlAttr{threshold='X'}, where the \xmlAttr{X} represents the requested $\alpha$ value (a floating point value between 0.0 and 1.0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do 0.0 to 1.0 represent 0% to 100%? (Also for expectedShortfall)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's basically like a quantile. |
||
|
||
\begin{equation} | ||
\operatorname{VaR}_\alpha(X)=-\inf\big\{x\in\mathbb{R}:F_X(x)>\alpha\big\} = F^{-1}_Y(1-\alpha). | ||
\end{equation} | ||
\end{itemize} | ||
This XML node needs to contain the attribute: | ||
\begin{itemize} | ||
\itemsep0em | ||
\item \xmlAttr{prefix}, \xmlDesc{required string attribute}, user-defined prefix for the given \textbf{metric}. | ||
For scalar quantifies, RAVEN will define a variable with name defined as: ``prefix'' + ``\_'' + ``parameter name''. | ||
For example, if we define ``mean'' as the prefix for \textbf{expectedValue}, and parameter ``x'', then variable | ||
``mean\_x'' will be defined by RAVEN. | ||
For matrix quantities, RAVEN will define a variable with name defined as: ``prefix'' + ``\_'' + ``target parameter name'' + ``\_'' + ``feature parameter name''. | ||
For example, if we define ``sen'' as the prefix for \textbf{sensitivity}, target ``y'' and feature ``x'', then | ||
variable ``sen\_y\_x'' will be defined by RAVEN. | ||
\nb These variable will be used by RAVEN for the internal calculations. It is also accessible by the user through | ||
\textbf{DataObjects} and \textbf{OutStreams}. | ||
\end{itemize} | ||
|
||
\end{itemize} | ||
|
||
|
||
\textbf{Example:} | ||
\begin{lstlisting}[style=XML,morekeywords={name,subType,class,type,steps}] | ||
<Simulation> | ||
... | ||
<Models> | ||
... | ||
<PostProcessor name="EconomicRatio" subType="EconomicRatio" verbosity="debug"> | ||
<sharpeRatio prefix="SR">x0,y0,z0,x,y,z</sharpeRatio> | ||
<sortinoRatio threshold='zero' prefix="stR">x01,y01,x,z</sortinoRatio> | ||
<sortinoRatio threshold='median' prefix="stR2">z01,x0,x01</sortinoRatio> | ||
<valueAtRisk threshold='0.07' prefix="VaR">z01,x0,x01</valueAtRisk> | ||
<expectedShortfall threshold='0.99' prefix="CVaR">z01,x0,x01</expectedShortfall> | ||
<gainLossRatio prefix="glR">x01,y01,z0,x,y,z</gainLossRatio> | ||
</PostProcessor> | ||
... | ||
</Models> | ||
... | ||
</Simulation> | ||
\end{lstlisting} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"threshold for separate upside and downside value will assign as$0$ ." I do not understand what this means?
Does this mean "the default threshold for the separate upside and downside value is$0$ " maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the financial data put in to calculation is usually the percentage change based on the original price. So 0 would be an ideal threshold, somehow in other calculation you could assign median as the gain or lose threshold.