Create a gist now

Instantly share code, notes, and snippets.

[ Posted by Nishant Nair ] verguard : Assignment
<?php
/*
Author: Nishant Nair
Date: 25-Dec-2016
Input: Array of data consiting od mutual fund details.
Output: Best mutual fund depending upon the oondition.
Program to find out the best mutual fund with below criteria.
1. Fund launch date before 2009
2. Assets greater than 500 crores and less than 10,000 crores
3. Fund standard deviation less than 15%
4. Fund 5 years return greater than 14% CAGR
5. Fund 5 year return should be at least 1.5 times the category average returns for 5 years.
*/
class Everguard {
private $launch_date = 2009;
private $lower_assets = 500;
private $upper_assets = 10000;
private $sd = 15;
private $return_5yrs = 14;
function shorlistMutualFund($mutal_fund) {
$shorlist_mutual_fund=[];
foreach($mutal_fund as $value){
if($value->launch_date <= $this->launch_date )
{
if(($value->assets > $this->lower_assets) && ($value->assets < $this->upper_assets)){
if($value->sd < $this->sd){
if($value->return_5yrs > $this->return_5yrs){
if($value->return_5yrs >=(1.5* $value->cat_avg)){
$shorlist_mutual_fund[] = $value;
}
}
}
}
}
}
return $shorlist_mutual_fund;
}
}
$mutual_fund[] = (object) array('launch_date' => 2006, 'assets' => 6412 ,'sd'=> 12 ,'return_5yrs' => 19.1 ,'cat_avg' => 12.1 ,'fund_name'=>'SBI Blue Chip Fund (G)');
$mutual_fund[] = (object) array('launch_date' => 2009, 'assets' => 4726 ,'sd'=> 13 ,'return_5yrs' => 19.3 ,'cat_avg' => 12.1 ,'fund_name'=>'Kotak Select Focus Fund - Regular Plan (G)');
$mutual_fund[] = (object) array('launch_date' => 2002, 'assets' => 10717 ,'sd'=> 11 ,'return_5yrs' => 17.5 ,'cat_avg' => 12.1 ,'fund_name'=>'Birla Sun Life Frontline Equity Fund (G)');
$mutual_fund[] = (object) array('launch_date' => 2008, 'assets' => 9738 ,'sd'=> 15 ,'return_5yrs' => 15.3 ,'cat_avg' => 12.1 ,'fund_name'=>'ICICI Prudential Focused Bluechip Equity Fund (G)');
$mutual_fund[] = (object) array('launch_date' => 2008, 'assets' => 563.47 ,'sd'=> 14.5 ,'return_5yrs' => 27.6 ,'cat_avg' => 9.1 ,'fund_name'=>'Principal Emerging Bluechip Fund G');
$mutual_fund[] = (object) array('launch_date' => 2009, 'assets' => 1500.38 ,'sd'=> 13.4 ,'return_5yrs' => 24.9 ,'cat_avg' => 9.1 ,'fund_name'=>'L&T India Value Fund (G)');
$mutual_fund[] = (object) array('launch_date' => 1992, 'assets' => 4564.61 ,'sd'=> 12 ,'return_5yrs' => 15.4 ,'cat_avg' => 12.1 ,'fund_name'=>'uti-equity-fund');
$mutual_fund[] = (object) array('launch_date' => 2003, 'assets' => 2,612.03,'sd'=> 15 ,'return_5yrs' => 12.4 ,'cat_avg' => 12.1 ,'fund_name'=>'DSP BlackRock Top 100 Equity Fund - Regular Plan (G)');
$mutual_fund[] = (object) array('launch_date' => 2007, 'assets' => 2,103.06,'sd'=> 13 ,'return_5yrs' => 17.7 ,'cat_avg' => 12.1 ,'fund_name'=>'Reliance Top 200 fund rp');
$mutual_fund[] = (object) array('launch_date' => 2008, 'assets' => 9738 ,'sd'=> 15 ,'return_5yrs' => 15.3 ,'cat_avg' => 12.1 ,'fund_name'=>'ICICI Prudential Focused Bluechip Equity Fund (G)');
$life = new Everguard;
$shorlisted_fund = $life->shorlistMutualFund($mutual_fund);
echo "<pre>";
print_r($shorlisted_fund);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment