//internal static void Test遠期利率() //{ // double V1 = 0.953516; // double V2 = 0.909091; // int F = 2; // double Rtn = Rate.遠期利率(V1, V2, F); // Console.WriteLine(Rtn); // V1 = 0.93457944; // V2 = 0.86922423; // F = 1; // Rtn = Rate.遠期利率(V1, V2, F); // Console.WriteLine(Rtn); //} internal static void Test單利() { //# 單利公式 double PV = 1; //# 本金 double R = 0.5; //# 年利率 double d = 1; //# 天數 double FV = RateAx.單利終值_D(PV, R, d); Console.WriteLine($"單利終值:{FV}"); double DF = RateAx.折現因子_D_R(R, d); Console.WriteLine($"折現因子為:{DF}"); double newPV = RateAx.現值_折現因子(FV, DF); Console.WriteLine($"驗證折現因子推現值:{newPV}"); double newFV = RateAx.終值_折現因子(PV, DF); Console.WriteLine($"驗證折現因子推終值:{newFV}"); Console.WriteLine("".PadRight(10, '-')); //# 零息利率公式 double zero = RateAx.零息利率_D_R(R, d); Console.WriteLine($"零息利率為:{zero}", zero); newPV = RateAx.現值_D_零息利率(FV, zero, d); Console.WriteLine($"驗證零息利率推現值:{newPV}"); newFV = RateAx.終值_D_零息利率(PV, zero, d); Console.WriteLine($"驗證零息利率推終值:{newFV}"); double newDF = RateAx.折現因子_D_Z(zero, d); Console.WriteLine($"從零息利率找折現因子:{newDF}"); double newZero = RateAx.零息利率_D_折現因子(DF, d); Console.WriteLine($"從折現因子找零息利率:{newZero}"); }
internal static void Test單複利() { double r1 = 3; double d = 50; double FV1 = RateAx.單利終值_D(1, r1, d); Console.WriteLine(FV1); }
internal static void Test遠期利率() { double r1 = 0.6916437211111013; double t1 = 2375; double n = 90; double r2 = 1.0334337150205943; double t2 = t1 + n; double rf = RateAx.遠期利率e(r1, t1 / 365d, r2, t2 / 365d); Console.WriteLine(rf); double FV = RateAx.終值_遠期利率e(r1, t1 / 365d, rf, (t2 - t1) / 365d); Console.WriteLine(FV); double FV2 = RateAx.終值_D_零息利率(1, r2, t2); Console.WriteLine(FV2); }