基金指數C持有多長時間比指數A划算?計算方法
阿新 • • 發佈:2020-07-25
<?php header("content-type:text/html;charset=utf-8"); //以投資1萬元為例 $money = 10000; //指數A $a_mairu = 0.0015; $a_guanli = 0.006; $a_tuoguan = 0.001; $a_xiaoshou = 0; $a_maichu_level = [0,7,30,180,365];//定義賣出時間範圍 $a_maichu_arr = array(0.015,0.0075,0.0050,0.0025,0);//定義賣出時間範圍的費率 $a_sum_guanli = 0; //指數C $c_mairu = 0; $c_guanli = 0.006; $c_tuoguan = 0.001; $c_xiaoshou = 0.003; $c_maichu_level = [0,7,30]; $c_maichu_arr = array(0.0015,0.0075,0); $c_sum_guanli = 0; for($day = 1;$day<=365;$day++){ echo "投資第".$day."天"; //第一天有申購費率 if($day==1){ echo " 指數A申購費用".$money*$a_mairu."元"; echo " 指數C申購費用".$money*$c_mairu."元"; $a_sum_guanli = $a_sum_guanli + $money*$a_mairu; $c_sum_guanli = $c_sum_guanli + $money*$c_mairu; } //運作費率 $a = round(($a_guanli+$a_tuoguan+$a_xiaoshou)/365*10000,2); $c = round(($c_guanli+$c_tuoguan+$c_xiaoshou)/365*10000,2); $a_sum_guanli = $a_sum_guanli + $a; $c_sum_guanli = $c_sum_guanli + $c; echo " 指數A總運作費用".$a_sum_guanli."元"; echo " 指數C總運作費用".$c_sum_guanli."元"; //贖回費 //贖回A for($j=0;$j<count($a_maichu_level);$j++){ if($j == count($a_maichu_level) - 1){ if($day >= $a_maichu_level[$j]){ //這裡通過$j 取得你對應的等級 ,前面我省略了$i對應店鋪等級的對映關係 $a_sh_temp = round($a_maichu_arr[$j]*10000,2); echo " 指數A今日贖回費用".$a_sh_temp."元"; } }else{ if($day >= $a_maichu_level[$j] && $day < $a_maichu_level[$j+1]) { //這裡通過$j 取得你對應的等級 $a_sh_temp = round($a_maichu_arr[$j]*10000,2); echo " 指數A今日贖回費用".$a_sh_temp."元"; } } } //贖回C for($j=0;$j<count($c_maichu_level);$j++){ if($j == count($c_maichu_level) - 1){ if($day >= $c_maichu_level[$j]){ //這裡通過$j 取得你對應的等級 ,前面我省略了$i對應店鋪等級的對映關係 $c_sh_temp = round($c_maichu_arr[$j]*10000,2); echo " 指數C今日贖回費用".$c_sh_temp."元"; } }else{ if($day >= $c_maichu_level[$j] && $day < $c_maichu_level[$j+1]) { //這裡通過$j 取得你對應的等級 $c_sh_temp = round($c_maichu_arr[$j]*10000,2); echo " 指數C今日贖回費用".$c_sh_temp."元"; } } } echo " 指數A總費用".($a_sum_guanli+$a_sh_temp)."元"; echo " 指數C總費用".($c_sum_guanli+$c_sh_temp)."元"; echo '<br />'; }