Performance Module:Statistics
From ExtractValue Wiki
The Statistics Module of the Performance Module is intended to produce statistical results on performance data. Some statistics may also be applied to data mining for other modules such as the Granular Analytics module.
Contents |
Version 1.0 - Financial Math
Note the following deficiencies of Version 1.0:
- The statistics calculator is a class originally built for the CodeIgniter 1.6.3 framework.
- The raw data is in a monthly rate of return format
- Note that this is a calculated number: Failed to parse (Can't write to or create math temp directory): RoR(t) = (x_t - x_{t-1})/2
The following methods have been built into the class:
- getAnnualReturn()
- getAnnualROR()
- getAverageGain()
- getAverageLoss()
- getCalmarRatio()
- getCompoundedAnnualROR()
- getCompoundedMonthlyROR()
- getDownsideDeviation()
- getMaxAnnualDrawdown()
- getMaxDrawdown()
- getMaxMonthlyROR()
- getMaxMonths2Recovery()
- getMean()
- getMedian()
- getMinMonthlyROR()
- getMonthlyROR()
- getPercentageOfProfitableMonths()
- getSharpeRatio()
- getStandardDeviationMonthlyROR()
- getStandardVarianceMonthlyROR()
- getSterlingRatio()
- getTotalReturn()
- getVAMI()
Version 2.0 - Dynamic Risk-free Rate
- Use historical risk free interest rates from Yahoo Finance
- Use a dynamic feed for the risk-free interest rate by using the 13-week Treasury Bill Coupon Rate from the US Treasury
Configuration
Hypothetical Investment
This is the hypothetical investment amount that you invest at the beginning of your investment
$config['hypo_investment'] = 1000;
Market Rate
The safe market rate value. This is usually tied to the U.S. Treasury Bill. The figure is represented by a percentage as a whole number. For example, if the T-Bill rate is 5%, the market_rate must be set at 5.
$config['market_rate'] = 5;
Minimum Rate
...enter description here...
$config['minimum_rate'] = 30;
Performance Array
Please see Performance Module:Database#Performance_Array
Initializing class & setting an object
$performance = new StatisticCalc($config);
You can now access any method of the object to retrieve performance statistics. For example:
$sharpeRatio = $performance->getSharpRatio();
Version 1.5 Specifications
- This monthly rate of return will need to be converted
Version 2.0 Specifications
The second version of this library must build out a new class in order to incorporate the new methods required.
The new class must:
- Incorporate all of the statistical formulae found at http://www.hedgefund.net/pertraconline/statbody.cfm.
- Some statistics have already been included in the original class in version 1.0 (e.g. Mean, VAMI, Standard Deviation etc.), in which case:
- The second class (version 2.0) must inherent the original class as a parent and thus the already created methods. DO NOT recreate methods already included in the Version 1.0 class.
- Convert Version 1.0 of the statistics calculator class to adhere to the Kohana Framework requirements. The requirements may be found at the Kohana website here
- The new class (Version 2.0) and the old class (Version 1.0) must adhere to PHP 5.2+ OOP programming principles.
- The class must be built to scale and ultra-portable. This class WILL BE USED in the Kohana framework, therefore please follow these strict regulations found at the Kohana website.
