예제 #1
0
        /// <inheritdoc/>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (Principal < 0.0)
            {
                AddToErrors(errors, ErrorLevel.Error, "Principal cannot be negative.");
            }

            CalcUtils.ValidateDates(errors, Accrual_Start_Date, Accrual_End_Date, false, "accrual start", "accrual end");
            CalcUtils.ValidateDates(errors, Reset_Date, Rate_Start_Date, false, "reset", "rate start");
            CalcUtils.ValidateDates(errors, Reset_Date, Payment_Date, false, "reset", "payment");

            if (Rate_1_End_Date > 0.0)
            {
                CalcUtils.ValidateDates(errors, Rate_Start_Date, Rate_1_End_Date, true, "rate start", "first rate end");
            }

            if (Rate_2_End_Date > 0.0)
            {
                CalcUtils.ValidateDates(errors, Rate_Start_Date, Rate_2_End_Date, true, "rate start", "second rate end");
            }

            if (!Rate_1_Tenor.IsPositiveOrZero())
            {
                AddToErrors(errors, ErrorLevel.Error, "First rate tenor must be positive or zero.");
            }

            if (!Rate_2_Tenor.IsPositiveOrZero())
            {
                AddToErrors(errors, ErrorLevel.Error, "Second rate tenor must be positive or zero.");
            }
        }
예제 #2
0
        public static void CopyCommonEventData(ICalendarData calendarData, Event theEvent, bool isMeeting, UserSmtpAddress userSmtpAddress)
        {
            EventSchema schema = theEvent.Schema;
            int         num    = (theEvent.PopupReminderSettings != null && theEvent.PopupReminderSettings.Count > 0) ? theEvent.PopupReminderSettings[0].ReminderMinutesBeforeStart : 0;

            if (theEvent.IsPropertySet(schema.BodyProperty) && theEvent.Body != null && theEvent.Body.Content != null)
            {
                calendarData.Body = new Body
                {
                    Data = theEvent.Body.Content,
                    Type = new byte?((byte)SyncCalendarUtils.GetEasBodyType(theEvent.Body.ContentType))
                };
            }
            if (theEvent.IsPropertySet(schema.StartProperty))
            {
                calendarData.StartTime = SyncCalendarUtils.ToStringDateTime(theEvent.Start);
            }
            if (theEvent.IsPropertySet(schema.EndProperty))
            {
                calendarData.EndTime = SyncCalendarUtils.ToStringDateTime(theEvent.End);
            }
            if (theEvent.IsPropertySet(schema.SubjectProperty))
            {
                calendarData.CalendarSubject = theEvent.Subject;
            }
            if (theEvent.IsPropertySet(schema.LocationProperty))
            {
                calendarData.Location = ((theEvent.Location != null) ? ((!string.IsNullOrEmpty(theEvent.Location.DisplayName)) ? theEvent.Location.DisplayName : null) : null);
            }
            if (theEvent.IsPropertySet(schema.PopupReminderSettingsProperty))
            {
                calendarData.Reminder = ((num > 0) ? new uint?((uint)num) : null);
            }
            if (theEvent.IsPropertySet(schema.IsAllDayProperty))
            {
                calendarData.AllDayEvent = new byte?(Convert.ToByte(theEvent.IsAllDay));
            }
            if (theEvent.IsPropertySet(schema.ShowAsProperty))
            {
                EasBusyStatus?busyStatus = SyncCalendarUtils.GetBusyStatus(theEvent.ShowAs);
                calendarData.BusyStatus = ((busyStatus != null) ? new byte?((byte)busyStatus.GetValueOrDefault()) : null);
            }
            if (theEvent.IsPropertySet(schema.SensitivityProperty))
            {
                calendarData.Sensitivity = new byte?((byte)theEvent.Sensitivity);
            }
            if (theEvent.IsPropertySet(schema.LastModifiedTimeProperty))
            {
                calendarData.DtStamp = SyncCalendarUtils.ToStringDateTime(theEvent.LastModifiedTime);
            }
            if (theEvent.IsPropertySet(schema.CategoriesProperty))
            {
                calendarData.CalendarCategories = SyncCalendarUtils.GetCategories(theEvent.Categories);
            }
            if (isMeeting && theEvent.IsPropertySet(schema.AttendeesProperty))
            {
                calendarData.Attendees = SyncCalendarUtils.GetAttendees(theEvent.Attendees, userSmtpAddress, theEvent.ResponseStatus);
            }
        }
예제 #3
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            bool payoffInAssetCurrency = string.IsNullOrEmpty(fPayoffCurrency) || fPayoffCurrency == Currency;

            Known_Prices.Validate(errors, !payoffInAssetCurrency && Payoff_Type == PayoffType.Compo, "Known prices");
        }
예제 #4
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            CalcUtils.ValidateDates(errors, Effective_Date, Maturity_Date, false);

            Amortisation.Validate(errors);
        }
예제 #5
0
        /// <summary>
        /// Validates the specified errors.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (String.IsNullOrEmpty(Index_Calendars))
            {
                AddToErrors(errors, "At least one calendar must be specified");
            }
        }
예제 #6
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (Maturity_Date <= Effective_Date)
            {
                AddToErrors(errors, "Effective date must be before maturity date");
            }
        }
예제 #7
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (string.IsNullOrWhiteSpace(Contract))
            {
                AddToErrors(errors, ErrorLevel.Error, string.Format("Contract of Bond Future must be specified."));
            }
        }
예제 #8
0
        /// <inheritdoc />
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            // Validate the existence of commodity.
            if (string.IsNullOrWhiteSpace(Commodity))
            {
                AddToErrors(errors, "Commodity must be specified on the deal.");
            }
        }
예제 #9
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            CalcUtils.ValidateDates(errors, Effective_Date, Maturity_Date, true);

            if (Moneyness <= 0.0)
            {
                AddToErrors(errors, "Moneyness must be greater than zero");
            }
        }
예제 #10
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (string.IsNullOrEmpty(Reference_Type))
            {
                AddToErrors(errors, "An invalid or no reference type has been provided.");
            }

            if (Contract_Size <= 0)
            {
                AddToErrors(errors, "The contract size must be positive.");
            }

            if (Units <= 0)
            {
                AddToErrors(errors, "The number of units must be positive.");
            }

            if (Realized_Average_1 < 0 || Realized_Average_2 < 0)
            {
                AddToErrors(errors, "Realized averages must be positive.");
            }

            if (Settlement_Date < Period_End_1)
            {
                errors.Add(ErrorLevel.Error, "Settlement date must lie on or after period end: " + Period_End_1);
            }

            if (Period_End_1 >= Period_End_2)
            {
                errors.Add(ErrorLevel.Error, "End of sampling period 2 must be after end of sampling period 1." + Period_End_2);
            }

            if (Period_End_1 < Period_Start_1)
            {
                errors.Add(ErrorLevel.Error, "Period end date must lie on or after period start: " + Period_Start_1);
            }

            if (Period_End_2 < Period_Start_2)
            {
                errors.Add(ErrorLevel.Error, "Period end date must lie on or after period start: " + Period_Start_2);
            }

            // Check that the reference price does not have a parent, e.g. SPREAD.GAS
            var dummyFactorID = new FactorID(Reference_Type);

            if (dummyFactorID.Count > 1)
            {
                errors.Add(ErrorLevel.Error, string.Format("Calendar Spread Option valid only on contracts with one suffix, e.g., ForwardPrice.GAS and not on ForwardPrice.{0}",
                                                           Reference_Type));
            }
        }
예제 #11
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (Reset_Frequency <= 0.0)
            {
                AddToErrors(errors, "Reset_Frequency must be greater than zero");
            }

            if (Period.TermToValue(Investment_Horizon) < Reset_Frequency)
            {
                AddToErrors(errors, "Investment_Horizon must be greater than or equal to Reset_Frequency");
            }
        }
예제 #12
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            InitialiseHolidayCalendars(calendar);
            var parameters = new CashflowListDateGenerationParameters
            {
                AccrualCalendar      = AccrualHolidayCalendar(),
                RateCalendar         = RateHolidayCalendar(),
                RateOffset           = Rate_Offset,
                RateAdjustmentMethod = Rate_Adjustment_Method,
                RateStickyMonthEnd   = Rate_Sticky_Month_End
            };

            if (fCashflows.FinishBuild(parameters))
            {
                AddToErrors(errors, ErrorLevel.Info, "Missing cashflow properties have been calculated (Accrual_Year_Fraction, Rate_Start_Date, Rate_End_Date, Rate_Year_Fraction)");
            }

            base.Validate(calendar, errors);

            if (Settlement_Style == SettlementType.Cash && Settlement_Date == 0.0)
            {
                AddToErrors(errors, "Settlement_Date must be specified when Settlement_Style is Cash");
            }

            if (Settlement_Amount != 0.0 && Settlement_Date == 0.0)
            {
                AddToErrors(errors, ErrorLevel.Warning, "Settlement_Amount is not zero but Settlement_Date is not specified so Settlement_Amount has been ignored.");
            }

            if (fCashflows.Items.Any(cashflow => cashflow.Payment_Date <= Settlement_Date))
            {
                AddToErrors(errors, "Cashflows must have Payment_Date after Settlement_Date");
            }

            if (fCashflows.Items.Any(cashflow => cashflow.FX_Reset_Date > 0.0 || cashflow.Known_FX_Rate > 0.0))
            {
                // Do not support forward deals on cashflow lists with FX_Reset_Date or Known_FX_Rate
                if (Settlement_Date > 0.0)
                {
                    AddToErrors(errors, "Cashflow list deal with Settlement_Date cannot have cashflows with FX_Reset_Date or Known_FX_Rate");
                }

                // Do not support cashflow lists with FX_Reset_Date or Known_FX_Rate under Use_Survival_Probability or Respect_Default
                if (!string.IsNullOrEmpty(Issuer))
                {
                    AddToErrors(errors, "Cashflow list deal with Issuer cannot have cashflows with FX_Reset_Date or Known_FX_Rate");
                }
            }
        }
        /// <summary>
        /// Validate the deal.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);
            fCashflows.Validate(errors);

            if (Is_Forward_Deal == YesNo.Yes && Settlement_Date == 0.0)
            {
                AddToErrors(errors, "Must specify a settlement date for a forward inflation bond cashflow list deal");
            }

            if (NeedInflationRate() && String.IsNullOrEmpty(Index))
            {
                AddToErrors(errors, "Must specify an index for an inflation cashflow list deal");
            }
        }
예제 #14
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            if (Notional < CalcUtils.MinAssetPrice)
            {
                AddToErrors(errors, string.Format("Bond Notional must be at least {0}", CalcUtils.MinAssetPrice));
            }

            CalcUtils.ValidateDates(errors, Issue_Date, Bond_Maturity_Date, First_Coupon_Date, Penultimate_Coupon_Date, false, "Issue", "bond maturity");

            Coupon_Rate_Schedule.Validate(errors, false, "Fixed rate schedule");
            Amortisation.Validate(errors);

            CalcUtils.ValidateDates(errors, Issue_Date, Bond_Maturity_Date, true, "Issue", "bond maturity");

            if (Settlement_Date != 0.0)
            {
                CalcUtils.ValidateDates(errors, Settlement_Date, Bond_Maturity_Date, true, "Settlement", "bond maturity");
            }

            CalcUtils.ValidateDates(errors, First_Call_Date, Last_Call_Date, false, "First call", "last call");

            Call_Prices.Validate(errors, true, "Call prices");

            if (IsForward())
            {
                if (Settlement_Date == 0.0)
                {
                    AddToErrors(errors, "Settlement_Date must be specified");
                }

                if (Price == 0.0)
                {
                    AddToErrors(errors, ErrorLevel.Info, "Settlement price (Price) is zero.");
                }
            }
            else
            {
                if (Price != 0.0 && Settlement_Date == 0.0)
                {
                    AddToErrors(errors, ErrorLevel.Warning, "Settlement price (Price) is not zero but Settlement_Date is not specified so Price has been ignored.");
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Validates the specified errors.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            InitialiseHolidayCalendars(calendar);
            var parameters = new CashflowListDateGenerationParameters()
            {
                AccrualDayCount      = Accrual_Day_Count,
                AccrualCalendar      = AccrualHolidayCalendar(),
                RateDayCount         = Rate_Day_Count,
                RateCalendar         = RateHolidayCalendar(),
                RateOffset           = Rate_Offset,
                RateAdjustmentMethod = Rate_Adjustment_Method,
                RateStickyMonthEnd   = Rate_Sticky_Month_End,
            };

            if (fCashflows.FinishBuild(parameters))
            {
                AddToErrors(errors, ErrorLevel.Info, "Missing cashflow properties have been calculated (Accrual_Year_Fraction, Rate_Start_Date, Rate_End_Date, Rate_Year_Fraction)");
            }

            base.Validate(calendar, errors);

            if (string.IsNullOrWhiteSpace(Equity))
            {
                AddToErrors(errors, "Equity must be specified on the deal.");
            }

            if (string.IsNullOrWhiteSpace(Equity_Currency))
            {
                AddToErrors(errors, "Equity_Currency must be specified on the deal.");
            }

            bool equityPayoffInAssetCurrency = string.IsNullOrEmpty(Equity_Payoff_Currency) || Equity_Payoff_Currency == Equity_Currency;

            if (!equityPayoffInAssetCurrency && Equity_Payoff_Type == PayoffType.Standard)
            {
                AddToErrors(errors, ErrorLevel.Error, "Equity_Payoff_Type cannot be Standard when Equity_Payoff_Currency and Equity_Currency are different");
            }
            else if (equityPayoffInAssetCurrency && Equity_Payoff_Type != PayoffType.Standard)
            {
                AddToErrors(errors, ErrorLevel.Info, "Payoff_Currency and Currency are the same but Payoff_Type is not Standard");
            }

            fCashflows.ValidateQuantoCompo(GetEquityPayoffType(), IsCrossCurrency(), errors);
        }
예제 #16
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            InitialiseHolidayCalendars(calendar);
            var accrualCalendar = GetHolidayCalendar();

            if (fCashflows.FinishBuild(accrualCalendar))
            {
                AddToErrors(errors, ErrorLevel.Info, "Missing cashflow properties have been calculated (Accrual_Year_Fraction)");
            }

            base.Validate(calendar, errors);

            if (Settlement_Style == SettlementType.Cash && Settlement_Date == 0.0)
            {
                AddToErrors(errors, "Settlement_Date must be specified when Settlement_Style is Cash");
            }

            if (Settlement_Amount != 0.0 && Settlement_Date == 0.0)
            {
                AddToErrors(errors, ErrorLevel.Warning, "Settlement_Amount is not zero but Settlement_Date is not specified so Settlement_Amount has been ignored.");
            }

            if (fCashflows.Items.Any <CFFixedInterest>(cashflow => cashflow.Payment_Date <= Settlement_Date))
            {
                AddToErrors(errors, "Cashflows must have Payment_Date after Settlement_Date");
            }

            if (fCashflows.Items.Any <CFFixedInterest>(cashflow => cashflow.FX_Reset_Date > 0.0 || cashflow.Known_FX_Rate > 0.0))
            {
                // Do not support forward deals on cashflow lists with FX_Reset_Date or Known_FX_Rate
                if (Settlement_Date > 0.0)
                {
                    AddToErrors(errors, "Cashflow list deal with Settlement_Date cannot have cashflows with FX_Reset_Date or Known_FX_Rate");
                }

                // Do not support cashflow lists with FX_Reset_Date or Known_FX_Rate under Use_Survival_Probability or Respect_Default
                if (!string.IsNullOrEmpty(Issuer))
                {
                    AddToErrors(errors, "Cashflow list deal with Issuer cannot have cashflows with FX_Reset_Date or Known_FX_Rate");
                }
            }
        }
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            InitialiseHolidayCalendars(calendar);
            var parameters = new CashflowListDateGenerationParameters()
            {
                AccrualCalendar      = AccrualHolidayCalendar(),
                RateCalendar         = Rate1HolidayCalendar(),
                Rate1Calendar        = Rate1HolidayCalendar(),
                Rate2Calendar        = Rate2HolidayCalendar(),
                RateOffset           = Rate_Offset,
                RateAdjustmentMethod = Rate_Adjustment_Method,
                RateStickyMonthEnd   = Rate_Sticky_Month_End,
            };

            if (fCashflows.FinishBuild(parameters))
            {
                AddToErrors(errors, ErrorLevel.Info, "Missing cashflow properties have been calculated (Accrual_Year_Fraction, Rate_Start_Date, Rate1_End_Date, Rate1_Year_Fraction, Rate2_End_Date, Rate2_Year_Fraction)");
            }

            base.Validate(calendar, errors);
        }
예제 #18
0
        /// <summary>
        /// Validations.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            CalcUtils.ValidateDates(errors, Effective_Date, Maturity_Date, true);

            // pay frequency (period) must not be greater than entire swap tenor
            double swapTenor = CalcUtils.DaysToYears(fMaturityDate - fEffectiveDate);

            if (fPayFrequency > swapTenor)
            {
                AddToErrors(errors, "Period between payments cannot be greater than period from Effective Date to Maturity Date (pay side)");
            }

            // attachment must be on [0,1), detachment on (0,1], attachment < detachment
            if ((fAttachment < 0) || (fAttachment >= 1))
            {
                AddToErrors(errors, "Attachment point must be less than one and cannot be less than zero");
            }

            if ((fDetachment <= 0) || (fDetachment > 1))
            {
                AddToErrors(errors, "Detachment point must be greater than zero and cannot be greater than one");
            }

            if (fDetachment <= fAttachment)
            {
                AddToErrors(errors, "Attachment point must be less than detachment point");
            }

            if (Upfront_Amount != 0 && Upfront_Date == 0.0)
            {
                AddToErrors(errors, "Upfront date must be specified if there is an upfront payment");
            }

            if (string.IsNullOrEmpty(Reference_Index))
            {
                AddToErrors(errors, "Reference Index must be specified");
            }
        }
        /// <summary>
        /// Validate deal parameters.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            Sampling_Data.Validate(errors, false, true);

            int nSamples = Sampling_Data.Count;

            if (nSamples > 0 && Sampling_Data[nSamples - 1].Date > Maturity_Date)
            {
                AddToErrors(errors, "last sample date in Sampling_Data cannot be after the Maturity_Date");
            }

            if (Tenor < 0)
            {
                AddToErrors(errors, "Underlying forward tenor can not be negative");
            }

            if (GetUnits() < 0.0)
            {
                AddToErrors(errors, ErrorLevel.Warning, "Units/Underlying_Amount is negative");
            }
        }
예제 #20
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            CalcUtils.ValidateDates(errors, Issue_Date, Bond_Maturity_Date, First_Coupon_Date, Penultimate_Coupon_Date, true, "issue", "bond maturity");

            if (Coupon_Interval <= 0.0)
            {
                AddToErrors(errors, "Coupon interval must be greater than zero");
            }

            if (Expiry_Date >= Bond_Maturity_Date)
            {
                AddToErrors(errors, "Expiry date must lie before bond maturity date: " + Bond_Maturity_Date.ToString());
            }

            if (Strike_Price <= 0.0)
            {
                AddToErrors(errors, "Strike price must be positive");
            }

            Amortisation.Validate(errors);
        }
예제 #21
0
 /// <summary>
 /// Initialise the holiday calendars for the ValuationCalendarSupport object.
 /// </summary>
 /// <remarks>
 /// Method to be called by the valuation in HeadNoteInitialize
 /// </remarks>
 public void InitialiseHolidayCalendars(ICalendarData calendarData)
 {
     fCalendarsSupport.InitialiseHolidayCalendars(calendarData);
 }
예제 #22
0
 /// <summary>
 /// Validate the deal properties and component deals.
 /// </summary>
 protected override void DoValidate(ICalendarData calendar, IStaticDataObjects staticData, ErrorList errors)
 {
     Exercise_Dates.Validate(errors, EndDate());
     fItems.Validate(calendar, staticData, errors);
 }
예제 #23
0
 /// <summary>
 /// Validate the deal.
 /// </summary>
 public override void Validate(ICalendarData calendar, ErrorList errors)
 {
     base.Validate(calendar, errors);
     fCashflows.Validate(errors);
 }
예제 #24
0
        /// <summary>
        /// Validate deal properties.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            CalcUtils.ValidateDates(errors, Issue_Date, Bond_Maturity_Date, First_Coupon_Date, Penultimate_Coupon_Date, true, "issue", "bond maturity");
        }
 public CalendarController(
     ICalendarData calendarData)
 {
     _calendarData = calendarData;
 }
예제 #26
0
        /// <summary>
        /// Validates that a commodity ID has been entered.
        /// </summary>
        public override void Validate(ICalendarData calendar, ErrorList errors)
        {
            base.Validate(calendar, errors);

            GetCommodityDealHelper().Validate(errors);
        }
예제 #27
0
 /// <summary>
 /// Validate deal properties.
 /// </summary>
 public override void Validate(ICalendarData calendar, ErrorList errors)
 {
     base.Validate(calendar, errors);
     ValidateOpenRepo(errors, Known_Repo_Rate_Date, Reset_Frequency, Investment_Horizon);
 }
예제 #28
0
 /// <summary>
 /// Validate the holiday calendars for the ValuationCalendarSupport object.
 /// </summary>
 /// <remarks>
 /// Method to be called by the valuation in RegisterFactors
 /// </remarks>
 public void ValidateHolidayCalendars(ICalendarData calendarData, ErrorList errors)
 {
     fCalendarsSupport.ValidateHolidayCalendars(calendarData, errors);
 }