/// <summary> /// Check whether the rate is within the range /// </summary> /// <param name="session"></param> /// <param name="checkRate"></param> /// <returns></returns> public static bool CheckHistoricalExRate(IDalSession session, IHistoricalExRate checkRate, out string errMessage) { bool success = true; errMessage = ""; if (checkRate != null) { IList<IHistoricalExRate> previousRates = GetHistoricalExRates(session, checkRate.Currency, checkRate.RateDate.AddDays(-5), checkRate.RateDate.AddDays(-1)); if (previousRates != null && previousRates.Count > 0) { decimal prevRate = previousRates.OrderByDescending(x => x.RateDate).FirstOrDefault().Rate; if (prevRate != 0M) { decimal diff = Math.Abs((prevRate - checkRate.Rate) / prevRate); if (diff > 0.05M) { errMessage = string.Format("The new Exchange Rate is {0}% different from the previous Exchange Rate.", (diff * 100).ToString("0.0")); success = false; } } } } return success; }
public static bool CheckNewRate(IDalSession session, IHistoricalExRate newRate, bool raiseErr, out string errMessage) { bool success = true; errMessage = ""; if (!HistoricalExRateMapper.CheckHistoricalExRate(session, newRate, out errMessage) && !string.IsNullOrEmpty(errMessage)) { if (raiseErr) throw new ApplicationException(errMessage); else success = false; } return success; }
public NavCashPosition(InstrumentSize Size, decimal ExchangeRateUsed, IHistoricalExRate ExchangeRateRecord) : base(Size, ExchangeRateUsed, ExchangeRateRecord) { }
public static bool CheckNewRate(IDalSession session, IHistoricalExRate newRate) { string errMessage = ""; return CheckNewRate(session, newRate, true, out errMessage); }
public static bool Update(IDalSession session, IHistoricalExRate historicalExRate) { session.InsertOrUpdate(historicalExRate); return true; }
public NavFundPosition(InstrumentSize Size, Price ClosingPriceUsed, decimal ExchangeRateUsed, IPriceDetail ClosingPriceRecord, IHistoricalExRate ExchangeRateRecord) : base(Size, ClosingPriceUsed, ExchangeRateUsed, ClosingPriceRecord, ExchangeRateRecord) { }