/// <summary> /// Evaluates the function with the given arguments. /// </summary> /// <param name="args">Arguments for the function evaluation</param> /// <returns> /// Result of the function applied to the arguments /// </returns> public override object Evaluate(object[] args) { double num = CalcConvert.ToDouble(args[0]); string str = CalcConvert.ToString(args[1]); string str2 = CalcConvert.ToString(args[2]); bool flag = CalcHelper.ArgumentExists(args, 3) ? CalcConvert.ToBool(args[3]) : false; int prec = CalcHelper.ArgumentExists(args, 4) ? CalcConvert.ToInt(args[4]) : 3; int digits = 0; if (prec >= 3) { if (!flag) { digits = FinancialHelper.displayPrecision(str2); } if (!CalcHelper.ArgumentExists(args, 4)) { prec = FinancialHelper.calcPrecision(str); } double num4 = 0.0; double num5 = FinancialHelper.one_euro(str, prec); double num6 = FinancialHelper.one_euro(str2, prec); if ((num5 >= 0.0) && (num6 >= 0.0)) { num4 = (num * num6) / num5; if (!flag) { num4 = Math.Round(num4, digits); } return((double)num4); } } return(CalcErrors.Value); }
public ActionResult BatchDonations(BatchDonationsViewModel model) { model.Donations.Add(new DonationViewModel()); model.DonorList = FinancialHelper.GetDonorList(); model.FundList = FinancialHelper.GetFundList(); return(View(model)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> price per $100 face value of a security that pays periodic interest. /// </summary> /// <param name="args"><para> /// The args contains 6 - 7 items: settlement, maturity, rate, yld, redemption, frequency, [basis]. /// </para> /// <para> /// Settlement is the security's settlement date. /// The security settlement date is the date after the issue date when the security is traded to the buyer. /// </para> /// <para> /// Maturity is the security's maturity date. The maturity date is the date when the security expires. /// </para> /// <para> /// Rate is the security's annual coupon rate. /// </para> /// <para> /// Yld is the security's annual yield. /// </para> /// <para> /// Redemption is the security's redemption value per $100 face value. /// </para> /// <para> /// Frequency is the number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4. /// </para> /// <para> /// Basis is the type of day count basis to use. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); DateTime time = CalcConvert.ToDateTime(args[0]); DateTime time2 = CalcConvert.ToDateTime(args[1]); double rate = CalcConvert.ToDouble(args[2]); double yield = CalcConvert.ToDouble(args[3]); double redemption = CalcConvert.ToDouble(args[4]); int freq = CalcConvert.ToInt(args[5]); int basis = CalcHelper.ArgumentExists(args, 6) ? CalcConvert.ToInt(args[6]) : 0; if (((yield < 0.0) || (rate < 0.0)) || (redemption == 0.0)) { return(CalcErrors.Number); } if ((basis < 0) || (basis > 4)) { return(CalcErrors.Number); } if (((freq != 1) && (freq != 2)) && (freq != 4)) { return(CalcErrors.Number); } if (DateTime.Compare(time, time2) > 0) { return(CalcErrors.Number); } return((double)FinancialHelper.price(time, time2, rate, yield, redemption, freq, basis)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> modified Macauley duration for a security with an assumed par value of $100. /// </summary> /// <param name="args"><para> /// The args contains 5 - 6 items: settlement, maturity, coupon, yld, frequency, [basis]. /// </para> /// <para> /// Settlement is the security's settlement date. /// The security settlement date is the date after the issue date when the security is traded to the buyer. /// </para> /// <para> /// Maturity is the security's maturity date. /// The maturity date is the date when the security expires. /// </para> /// <para> /// Coupon is the security's annual coupon rate. /// </para> /// <para> /// Yld is the security's annual yield. /// </para> /// <para> /// Frequency is the number of coupon payments per year. /// For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4. /// </para> /// <para> /// Basis is the type of day count basis to use. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); DateTime time = CalcConvert.ToDateTime(args[0]); DateTime time2 = CalcConvert.ToDateTime(args[1]); double fCoup = CalcConvert.ToDouble(args[2]); double fYield = CalcConvert.ToDouble(args[3]); int freq = CalcConvert.ToInt(args[4]); int nBase = CalcHelper.ArgumentExists(args, 5) ? CalcConvert.ToInt(args[5]) : 0; if ((nBase < 0) || (nBase > 4)) { return(CalcErrors.Number); } if (((freq != 1) && (freq != 2)) && (freq != 4)) { return(CalcErrors.Number); } if (DateTime.Compare(time, time2) > 0) { return(CalcErrors.Number); } double fNumOfCoups = FinancialHelper.coupnum(time, time2, freq); return((double)this.get_mduration(time, time2, fCoup, fYield, freq, nBase, fNumOfCoups)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> amount received at maturity for a fully invested security. /// </summary> /// <param name="args"><para> /// The args contains 4 - 5 items: settlement, maturity, investment, discount, [basis]. /// </para> /// <para> /// Settlement is the security's settlement date. /// The security settlement date is the date after the issue date when the security is traded to the buyer. /// </para> /// <para> /// Maturity is the security's maturity date. The maturity date is the date when the security expires. /// </para> /// <para> /// Investment is the amount invested in the security. /// </para> /// <para> /// Discount is the security's discount rate. /// </para> /// <para> /// Basis is the type of day count basis to use. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); DateTime time = CalcConvert.ToDateTime(args[0]); DateTime time2 = CalcConvert.ToDateTime(args[1]); double num = CalcConvert.ToDouble(args[2]); double num2 = CalcConvert.ToDouble(args[3]); int basis = CalcHelper.ArgumentExists(args, 4) ? CalcConvert.ToInt(args[4]) : 0; if (DateTime.Compare(time, time2) >= 0) { return(CalcErrors.Number); } if (((num <= 0.0) || (num2 <= 0.0)) || ((basis < 0) || (4 < basis))) { return(CalcErrors.Number); } double num4 = FinancialHelper.days_monthly_basis(time, time2, basis); double num5 = FinancialHelper.annual_year_basis(time, basis); if ((num4 <= 0.0) || (num5 <= 0.0)) { return(CalcErrors.Number); } double num6 = 1.0 - ((num2 * num4) / num5); if (num6 <= 0.0) { return(CalcErrors.Number); } return((double)(num / num6)); }
private double get_cumipmt(double fRate, int nNumPeriods, double fVal, int nStart, int nEnd, int nPayType) { double fRmz = FinancialHelper.GetRmz(fRate, (double)nNumPeriods, fVal, 0.0, nPayType); double num2 = 0.0; if (nStart == 1) { if (nPayType <= 0) { num2 = -fVal; } nStart++; } for (int i = nStart; i <= nEnd; i++) { if (nPayType > 0) { num2 += FinancialHelper.GetZw(fRate, (double)(i - 2), fRmz, fVal, 1) - fRmz; } else { num2 += FinancialHelper.GetZw(fRate, (double)(i - 1), fRmz, fVal, 0); } } return(num2 * fRate); }
internal bool goal_seek_newton(ref GoalSeekData data, DateTime[] dates, double[] values, double x0) { double num2 = data.precision / 2.0; for (int i = 0; i < 20; i++) { double num7; double y = 0.0; double dfx = 0.0; bool flag = xirr_f(x0, ref y, dates, values); if (!flag) { return(flag); } if (FinancialHelper.update_data(x0, y, ref data)) { return(true); } if (Math.Abs(x0) < 1E-10) { if (data.havexneg && data.havexpos) { num7 = Math.Abs((double)(data.xpos - data.xneg)) / 1000000.0; } else { num7 = (data.xmax - data.xmin) / 1000000.0; } } else { num7 = Math.Abs(x0) / 1000000.0; } flag = this.fake_df(x0, ref dfx, num7, ref data, dates, values); if (!flag) { return(flag); } if (dfx == 0.0) { return(false); } double num3 = x0 - ((1.000001 * y) / dfx); if (num3 == x0) { data.root = x0; return(true); } double num4 = Math.Abs((double)(num3 - x0)) / (Math.Abs(x0) + Math.Abs(num3)); x0 = num3; if (num4 < num2) { data.root = x0; return(true); } } return(false); }
/// <summary> /// Returns the <see cref="T:System.Double" /> interest rate per period of an annuity. /// </summary> /// <param name="args"><para> /// The args contains 3 - 6 items: nper, pmt, pv, [fv], [type], [guess]. /// </para> /// <para> /// Nper is the total number of payment periods in an annuity. /// </para> /// <para> /// Pmt is the payment made each period and cannot change over the life of the annuity. /// </para> /// <para> /// Pv is the present value ¡ª the total amount that a series of future payments is worth now. /// </para> /// <para> /// Fv is the future value, or a cash balance you want to attain after the last payment is made. /// If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0). /// </para> /// <para> /// Type is the number 0 or 1 and indicates when payments are due. /// </para> /// <para> /// Guess is your guess for what the rate will be. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); double num = CalcConvert.ToDouble(args[0]); double num2 = CalcConvert.ToDouble(args[1]); double num3 = CalcConvert.ToDouble(args[2]); double num4 = CalcHelper.ArgumentExists(args, 3) ? CalcConvert.ToDouble(args[3]) : 0.0; int num5 = CalcHelper.ArgumentExists(args, 4) ? CalcConvert.ToInt(args[4]) : 0; double num6 = CalcHelper.ArgumentExists(args, 5) ? CalcConvert.ToDouble(args[5]) : 0.1; if (num > 0.0) { GoalSeekData data; RateData data2; if (num5 < 0) { return(CalcErrors.Value); } if (num5 > 1) { num5 = 1; } data.xmin = 0.0; data.xmax = 0.0; data.precision = 0.0; data.havexpos = false; data.xpos = 0.0; data.ypos = 0.0; data.havexneg = false; data.xneg = 0.0; data.yneg = 0.0; data.root = 0.0; FinancialHelper.goal_seek_initialise(ref data); data.xmin = Math.Max(data.xmin, -Math.Pow(1.7976931348623157E+298, 1.0 / ((double)num)) + 1.0); data.xmax = Math.Min(data.xmax, Math.Pow(1.7976931348623157E+298, 1.0 / ((double)num)) - 1.0); data2.nper = (double)num; data2.pmt = (double)num2; data2.pv = (double)num3; data2.fv = (double)num4; data2.type = num5; bool flag = this.goal_seek_newton(ref data, ref data2, (double)num6); if (!flag) { for (int i = 2; (!data.havexneg || !data.havexpos) && (i < 100); i *= 2) { this.goal_seek_point(ref data, ref data2, ((double)num6) * i); this.goal_seek_point(ref data, ref data2, ((double)num6) / ((double)i)); } flag = this.goal_seek_bisection(ref data, ref data2); } if (flag) { return((double)data.root); } } return(CalcErrors.Number); }
private void NumQuotaString_TextChanged(object sender, TextChangedEventArgs e) { double inValue; if (double.TryParse(NumQuotaString.Text, out inValue)) { string quotaString = FinancialHelper.ConvertQuotaToText(inValue); QuotaText.Text = quotaString; } }
public ActionResult BatchDonations(int?count) { var model = new BatchDonationsViewModel(count ?? 5) { DonorList = FinancialHelper.GetDonorList(), FundList = FinancialHelper.GetFundList() }; return(View(model)); }
public ActionResult CreateDonation(int?personId, int?organizationId) { var model = new DonationViewModel { PersonId = personId, OrganizationId = organizationId }; ViewBag.FundList = FinancialHelper.GetFundList(); return(PartialView(model)); }
/// <summary> /// Evaluates the function with the given arguments. /// </summary> /// <param name="args">Arguments for the function evaluation</param> /// <returns> /// Result of the function applied to the arguments /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); double num = FinancialHelper.one_euro(CalcConvert.ToString(args[0]), 2); if (num >= 0.0) { return((double)num); } return(CalcErrors.Number); }
/// <summary> /// Returns the <see cref="T:System.Double" /> yield of a security that has an odd (short or long) first period. /// </summary> /// <param name="args"><para> /// The args contains 8 - 9 items: settlement, maturity, issue, first_coupon, rate, pr, redemption, frequency, [basis]. /// </para> /// <para> /// Settlement is the security's settlement date. /// The security settlement date is the date after the issue date when the security is traded to the buyer. /// </para> /// <para> /// Maturity is the security's maturity date. /// The maturity date is the date when the security expires. /// </para> /// <para> /// Issue is the security's issue date. /// </para> /// <para> /// First_coupon is the security's first coupon date. /// </para> /// <para> /// Rate is the security's interest rate. /// </para> /// <para> /// Pr is the security's price. /// </para> /// <para> /// Redemption is the security's redemption value per $100 face value. /// </para> /// <para> /// Frequency is the number of coupon payments per year. /// For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4. /// </para> /// <para> /// Basis is the type of day count basis to use. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { GoalSeekData data; base.CheckArgumentsLength(args); DateTime time = CalcConvert.ToDateTime(args[0]); DateTime time2 = CalcConvert.ToDateTime(args[1]); DateTime time3 = CalcConvert.ToDateTime(args[2]); DateTime time4 = CalcConvert.ToDateTime(args[3]); double rate = CalcConvert.ToDouble(args[4]); double price = CalcConvert.ToDouble(args[5]); double redem = CalcConvert.ToDouble(args[6]); int freq = CalcConvert.ToInt(args[7]); int basis = CalcHelper.ArgumentExists(args, 8) ? CalcConvert.ToInt(args[8]) : 0; double num6 = 0.1; if ((((basis < 0) || (basis > 4)) || (((freq != 1) && (freq != 2)) && (freq != 4))) || (((DateTime.Compare(time3, time) > 0) || (DateTime.Compare(time, time4) > 0)) || (DateTime.Compare(time4, time2) > 0))) { return(CalcErrors.Number); } if (((rate < 0.0) || (price <= 0.0)) || (redem <= 0.0)) { return(CalcErrors.Number); } data.xmin = 0.0; data.xmax = 0.0; data.precision = 0.0; data.havexpos = false; data.xpos = 0.0; data.ypos = 0.0; data.havexneg = false; data.xneg = 0.0; data.yneg = 0.0; data.root = 0.0; FinancialHelper.goal_seek_initialise(ref data); data.xmin = Math.Max(data.xmin, 0.0); data.xmax = Math.Min(data.xmax, 1000.0); bool flag = this.goal_seek_newton(ref data, time, time2, time3, time4, rate, price, redem, freq, basis, num6); if (flag) { for (num6 = 1E-10; num6 < data.xmax; num6 *= 2.0) { this.goal_seek_point(ref data, time, time2, time3, time4, rate, price, redem, freq, basis, num6); } flag = this.goal_seek_bisection(ref data, time, time2, time3, time4, rate, price, redem, freq, basis); } if (!flag) { return(CalcErrors.Number); } return((double)data.root); }
public ActionResult CreateDonation([Bind(Include = "Id,DonationDate,Amount,Fund,Designation,CheckNumber,PersonId,OrganizationId")] DonationViewModel model) { if (ModelState.IsValid) { var donation = model.MapToDonation(); Database.Donations.Add(donation); Database.SaveChanges(); return(ReturnToSender(model.PersonId, model.OrganizationId)); } ViewBag.FundList = FinancialHelper.GetFundList(); return(View(model)); }
private double calc_oddlprice(DateTime settlement, DateTime maturity, DateTime last_interest, double rate, double yield, double redemption, int freq, int basis) { DateTime time = new DateTime(last_interest.Year, last_interest.Month, last_interest.Day); do { time = time.AddMonths(12 / freq); }while (DateTime.Compare(time, maturity) < 0); double num = FinancialHelper.date_ratio(last_interest, settlement, time, freq, basis); double num2 = FinancialHelper.date_ratio(last_interest, maturity, time, freq, basis); double num3 = FinancialHelper.date_ratio(settlement, maturity, time, freq, basis); return(((redemption * freq) + ((100.0 * rate) * (num2 - (num * (1.0 + ((yield * num3) / ((double)freq))))))) / ((yield * num3) + freq)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> internal rate of return for a schedule of cash flows that is not necessarily periodic. /// </summary> /// <param name="args"><para> /// The args contains 2 - 3 items: values, dates, [guess]. /// </para> /// <para> /// Values is a series of cash flows that corresponds to a schedule of payments in dates. /// </para> /// <para> /// Dates is a schedule of payment dates that corresponds to the cash flow payments. /// </para> /// <para> /// Guess is a number that you guess is close to the result of XIRR. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); double[] values = new double[ArrayHelper.GetLength(args[0], 0)]; DateTime[] dates = new DateTime[ArrayHelper.GetLength(args[1], 0)]; double num = CalcHelper.ArgumentExists(args, 2) ? CalcConvert.ToDouble(args[2]) : 0.1; if (ArrayHelper.GetLength(args[0], 0) == ArrayHelper.GetLength(args[1], 0)) { GoalSeekData data; for (int i = 0; i < ArrayHelper.GetLength(args[0], 0); i++) { values[i] = CalcConvert.ToDouble(ArrayHelper.GetValue(args[0], i, 0)); } for (int j = 0; j < ArrayHelper.GetLength(args[1], 0); j++) { dates[j] = CalcConvert.ToDateTime(ArrayHelper.GetValue(args[1], j, 0)); } data.xmin = 0.0; data.xmax = 0.0; data.precision = 0.0; data.havexpos = false; data.xpos = 0.0; data.ypos = 0.0; data.havexneg = false; data.xneg = 0.0; data.yneg = 0.0; data.root = 0.0; FinancialHelper.goal_seek_initialise(ref data); data.xmin = -1.0; data.xmax = Math.Min(1000.0, data.xmax); if (this.goal_seek_newton(ref data, dates, values, num)) { return((double)data.root); } for (int k = 1; k <= 0x400; k += k) { double num5 = Convert.ToDouble(k); double y = 9.0 / (num5 + 9.0); this.goal_seek_point(ref data, num, ref y, dates, values); y = num5; this.goal_seek_point(ref data, num, ref y, dates, values); if (this.goal_seek_bisection(ref data, dates, values)) { return((double)data.root); } } } return(CalcErrors.Number); }
public ActionResult CreatePledge([Bind(Include = "Id,Year,Amount,Frequency,Fund,PersonId")] PledgeViewModel model) { if (ModelState.IsValid) { var pledge = model.MapToPledge(); Database.Pledges.Add(pledge); Database.SaveChanges(); return(ReturnToSender(model.PersonId)); } ViewBag.YearList = FinancialHelper.GetPledgeYearList(); ViewBag.FrequencyList = FinancialHelper.GetFrequencyList(); ViewBag.FundList = FinancialHelper.GetFundList(); return(View(model)); }
internal double Yearfrac(DateTime from, DateTime to, int basis) { double num2; int num = FinancialHelper.Days_Between_Basis(from, to, basis); if (num < 0) { num = -num; DateTime time = from; from = to; to = time; } if (basis == 1) { int num5; int num6; int year = from.Year; int num4 = to.Year; DateTime time2 = from; time2.AddYears(1); if (DateTime.Compare(to, time2) > 0) { num6 = (num4 + 1) - year; time2 = new DateTime(year, 1, 1); DateTime @this = new DateTime(num4 + 1, 1, 1); num5 = Convert.ToInt32((double)(@this.ToOADate() - time2.ToOADate())) - (0x16d * ((num4 + 1) - year)); } else { num6 = 1; if ((DateTime.IsLeapYear(year) && (from.Month < 3)) || (DateTime.IsLeapYear(num4) && (((to.Month * 0x100) + to.Day) >= 0x21d))) { num5 = 1; } else { num5 = 0; } } double num7 = ((double)num5) / ((double)num6); num2 = 365.0 + num7; } else { num2 = FinancialHelper.Annual_Year_Basis(DateTime.Today, basis); } return(((double)num) / num2); }
internal bool goal_seek_point(ref GoalSeekData data, double x0, ref double y, DateTime[] dates, double[] values) { double num = 0.0; if ((x0 < data.xmin) || (x0 > data.xmax)) { return(false); } bool flag = xirr_f(x0, ref y, dates, values); if (!flag) { return(flag); } return(FinancialHelper.update_data(x0, num, ref data)); }
internal bool goal_seek_point(ref GoalSeekData data, double[] vals, double x0) { double y = 0.0; if ((x0 < data.xmin) || (x0 > data.xmax)) { return(false); } bool flag = this.irr_npv(x0, ref y, vals); if (!flag) { return(flag); } return(FinancialHelper.update_data(x0, y, ref data)); }
/// <summary> /// /// </summary> public DataReaderWriter <DataBar> GetDataBarReaderWriter() { if (DataType != EntryDataTypeEnum.DataBar) { return(null); } if (string.IsNullOrEmpty(_fileName) == false) { return(FinancialHelper.CreateDataBarFileReaderWriter(FilePath)); } else { return(null); } }
internal bool goal_seek_point(ref GoalSeekData data, ref RateData user_data, double x0) { double y = 0.0; if ((x0 < data.xmin) || (x0 > data.xmax)) { return(false); } bool flag = this.rate_f(x0, ref y, ref user_data); if (!flag) { return(flag); } return(FinancialHelper.update_data(x0, y, ref data)); }
private bool goal_seek_point(ref GoalSeekData data, DateTime settle, DateTime maturity, DateTime issue, DateTime first_coupon, double rate, double price, double redem, int freq, int basis, double x0) { double y = 0.0; if ((x0 < data.xmin) || (x0 > data.xmax)) { return(false); } bool flag = this.oddyield_f(x0, ref y, settle, maturity, issue, first_coupon, rate, price, redem, freq, basis); if (!flag) { return(flag); } return(FinancialHelper.update_data(x0, y, ref data)); }
public ActionResult EditDonation([Bind(Include = "Id,DonationDate,Amount,Fund,Designation,CheckNumber,PersonId,OrganizationId")] DonationViewModel model) { if (!ModelState.IsValid || model.DonationDate == null || model.Amount == null) { ViewBag.FundList = FinancialHelper.GetFundList(); return(PartialView(model)); } if (ModelState.IsValid) { var donation = Database.Donations.Find(model.Id); model.UpdateDonation(donation); Database.SaveChanges(); } return(ReturnToSender(model.PersonId, model.OrganizationId)); }
internal bool goal_seek_newton(ref GoalSeekData data, ref RateData user_data, double x0) { double num2 = data.precision / 2.0; for (int i = 0; i < 100; i++) { double y = 0.0; double num6 = 0.0; if ((x0 < data.xmin) || (x0 > data.xmax)) { return(false); } bool flag = this.rate_f(x0, ref y, ref user_data); if (!flag) { return(flag); } if (FinancialHelper.update_data(x0, y, ref data)) { return(true); } flag = this.rate_df(x0, ref num6, ref user_data); if (!flag) { return(flag); } if (num6 == 0.0) { return(false); } double num3 = x0 - ((1.000001 * y) / num6); if (num3 == x0) { data.root = x0; return(true); } double num4 = Math.Abs((double)(num3 - x0)) / (Math.Abs(x0) + Math.Abs(num3)); x0 = num3; if (num4 < num2) { data.root = x0; return(true); } } return(false); }
/// <summary> /// Returns the <see cref="T:System.Double" /> interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate. /// </summary> /// <param name="args"><para> /// The args contains 4 - 6 items: rate, per, nper, pv, [fv], [type]. /// </para> /// <para> /// Rate is the interest rate per period. /// </para> /// <para> /// Per is the period for which you want to find the interest and must be in the range 1 to nper. /// </para> /// <para> /// Nper is the total number of payment periods in an annuity. /// </para> /// <para> /// Pv is the present value, or the lump-sum amount that a series of future payments is worth right now. /// </para> /// <para> /// Fv is the future value, or a cash balance you want to attain after the last payment is made. /// If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0). /// </para> /// <para> /// Type is the number 0 or 1 and indicates when payments are due. /// If type is omitted, it is assumed to be 0. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); double rate = CalcConvert.ToDouble(args[0]); double num2 = CalcConvert.ToDouble(args[1]); double nper = CalcConvert.ToDouble(args[2]); double pv = CalcConvert.ToDouble(args[3]); double fv = CalcHelper.ArgumentExists(args, 4) ? CalcConvert.ToDouble(args[4]) : 0.0; int type = CalcHelper.ArgumentExists(args, 5) ? CalcConvert.ToInt(args[5]) : 0; if (((num2 < 1.0) || (num2 >= (nper + 1.0))) || (nper < 1.0)) { return(CalcErrors.Number); } double pmt = FinancialHelper.calculate_pmt(rate, nper, pv, fv, type); return((double)FinancialHelper.calculate_interest_part(pv, pmt, rate, num2 - 1.0)); }
// GET: /Financial/CreatePledge public ActionResult CreatePledge(int?personId) { if (personId == null || !UserHelper.UserCanEditPerson(User, personId)) { return(HttpNotFound()); } var model = new PledgeViewModel { PersonId = (int)personId, Year = DateTime.Now.Year }; ViewBag.YearList = FinancialHelper.GetPledgeYearList(); ViewBag.FrequencyList = FinancialHelper.GetFrequencyList(); ViewBag.FundList = FinancialHelper.GetFundList(); return(PartialView(model)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> accrued interest for a security that pays periodic interest. /// </summary> /// <param name="args"><para> /// The args contains 6 - 8 items: issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method]. /// </para> /// <para> /// Issue is the security's issue date. /// </para> /// <para> /// First_interest is the security's first interest date. /// </para> /// <para> /// Settlement is the security's settlement date. /// The security settlement date is the date after the issue date when the security is traded to the buyer. /// </para> /// <para> /// Rate is the security's annual coupon rate. /// </para> /// <para> /// Par is the security's par value. If you omit par, ACCRINT uses $1,000. /// </para> /// <para> /// Frequency is the number of coupon payments per year. /// For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4. /// </para> /// <para> /// Basis is the type of day count basis to use. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); DateTime time = CalcConvert.ToDateTime(args[0]); CalcConvert.ToDateTime(args[1]); DateTime time2 = CalcConvert.ToDateTime(args[2]); double num = CalcConvert.ToDouble(args[3]); double num2 = CalcHelper.ArgumentExists(args, 4) ? CalcConvert.ToDouble(args[4]) : 1000.0; int num3 = CalcConvert.ToInt(args[5]); int basis = CalcHelper.ArgumentExists(args, 6) ? CalcConvert.ToInt(args[6]) : 0; if (CalcHelper.ArgumentExists(args, 7)) { CalcConvert.ToBool(args[7]); } if ((num <= 0.0) || (num2 <= 0.0)) { return(CalcErrors.Number); } if ((basis < 0) || (4 < basis)) { return(CalcErrors.Number); } if (((num3 != 1) && (num3 != 2)) && (num3 != 4)) { return(CalcErrors.Number); } if (DateTime.Compare(time, time2) >= 0) { return(CalcErrors.Number); } double num5 = FinancialHelper.days_monthly_basis(time, time2, basis); double num6 = FinancialHelper.annual_year_basis(time, basis); if ((num5 < 0.0) || (num6 <= 0.0)) { return(CalcErrors.Number); } double num7 = (num2 * num) / Convert.ToDouble(num3); double num8 = num5 / num6; return((double)((num7 * Convert.ToDouble(num3)) * num8)); }
public ActionResult EditDonation(int?id, int?personId) { if (id == null) { return(HttpNotFound()); } var donation = Database.Donations.Find(id); if (donation == null) { return(HttpNotFound()); } var model = new DonationViewModel(donation); ViewBag.FundList = FinancialHelper.GetFundList(); return(PartialView(model)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> price per $100 face value of a security having an odd (short or long) first period. /// </summary> /// <param name="args"><para> /// The args contains 8 - 9 items: settlement, maturity, issue, first_coupon, rate, yld, redemption, frequency, [basis]. /// </para> /// <para> /// Settlement is the security's settlement date. /// The security settlement date is the date after the issue date when the security is traded to the buyer. /// </para> /// <para> /// Maturity is the security's maturity date. The maturity date is the date when the security expires. /// </para> /// <para> /// Issue is the security's issue date. /// </para> /// <para> /// First_coupon is the security's first coupon date. /// </para> /// <para> /// Rate is the security's interest rate. /// </para> /// <para> /// Yld is the security's annual yield. /// </para> /// <para> /// Redemption is the security's redemption value per $100 face value. /// </para> /// <para> /// Frequency is the number of coupon payments per year. /// For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4. /// </para> /// <para> /// Basis is the type of day count basis to use. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); DateTime time = CalcConvert.ToDateTime(args[0]); DateTime time2 = CalcConvert.ToDateTime(args[1]); DateTime time3 = CalcConvert.ToDateTime(args[2]); DateTime time4 = CalcConvert.ToDateTime(args[3]); double rate = CalcConvert.ToDouble(args[4]); double yield = CalcConvert.ToDouble(args[5]); double redemption = CalcConvert.ToDouble(args[6]); int freq = CalcConvert.ToInt(args[7]); int basis = CalcHelper.ArgumentExists(args, 8) ? CalcConvert.ToInt(args[8]) : 0; if (((((basis >= 0) && (basis <= 4)) && (((freq == 1) || (freq == 2)) || (freq == 4))) && (((DateTime.Compare(time3, time) <= 0) && (DateTime.Compare(time, time4) <= 0)) && (DateTime.Compare(time4, time2) <= 0))) && (((rate >= 0.0) && (yield >= 0.0)) && (redemption > 0.0))) { return((double)FinancialHelper.calc_oddfprice(time, time2, time3, time4, rate, yield, redemption, freq, basis)); } return(CalcErrors.Number); }