public override bool isBusinessDay(Date date) { DayOfWeek w = date.DayOfWeek; int d = date.Day, dd = date.DayOfYear; Month m = (Month)date.Month; int y = date.Year; int em = easterMonday(y); if (isWeekend(w) // New Year's Day (possibly moved to Monday) || (d == 1 && m == Month.January) // Australia Day, January 26th (possibly moved to Monday) || ((d == 26 || ((d == 27 || d == 28) && w == DayOfWeek.Monday)) && m == Month.January) // Good Friday || (dd == em-3) // Easter Monday || (dd == em) // ANZAC Day, April 25th (possibly moved to Monday) || ((d == 25 || (d == 26 && w == DayOfWeek.Monday)) && m == Month.April) // Queen's Birthday, second Monday in June || ((d > 7 && d <= 14) && w == DayOfWeek.Monday && m == Month.June) // Bank Holiday, first Monday in August || (d <= 7 && w == DayOfWeek.Monday && m == Month.August) // Labour Day, first Monday in October || (d <= 7 && w == DayOfWeek.Monday && m == Month.October) // Christmas, December 25th (possibly Monday or Tuesday) || ((d == 25 || (d == 27 && (w == DayOfWeek.Monday || w == DayOfWeek.Tuesday))) && m == Month.December) // Boxing Day, December 26th (possibly Monday or Tuesday) || ((d == 26 || (d == 28 && (w == DayOfWeek.Monday || w == DayOfWeek.Tuesday))) && m == Month.December)) return false; return true; }
public override bool isBusinessDay(Date date) { DayOfWeek w = date.DayOfWeek; int d = date.Day, dd = date.DayOfYear; Month m = (Month)date.Month; int y = date.Year; int em = easterMonday(y); if (isWeekend(w) // New Year's Day || (d == 1 && m == Month.January) // Epiphany || (d == 6 && m == Month.January) // Good Friday || (dd == em - 3) // Easter Monday || (dd == em) // Ascension Thursday || (dd == em + 38) // Labour Day || (d == 1 && m == Month.May) // Midsummer Eve (Friday between June 18-24) || (w == DayOfWeek.Friday && (d >= 18 && d <= 24) && m == Month.June) // Independence Day || (d == 6 && m == Month.December) // Christmas Eve || (d == 24 && m == Month.December) // Christmas || (d == 25 && m == Month.December) // Boxing Day || (d == 26 && m == Month.December)) return false; return true; }
public void CanAddNegativeYears_FromLeapDay_ToNonLeapYear() { var dt = new Date(2000, 2, 29); var actual = dt.AddYears(-1); var expected = new Date(1999, 2, 28); Assert.Equal(expected, actual); }
// constructors public FixedRateCoupon(double nominal, Date paymentDate, double rate, DayCounter dayCounter, Date accrualStartDate, Date accrualEndDate, Date refPeriodStart = null, Date refPeriodEnd = null,double? amount = null) : base(nominal, paymentDate, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd, amount) { rate_ = new InterestRate(rate, dayCounter, Compounding.Simple,Frequency.Annual); }
public void CanAddPositiveYears_FromLeapDay_ToLeapYear() { var dt = new Date(2000, 2, 29); var actual = dt.AddYears(4); var expected = new Date(2004, 2, 29); Assert.Equal(expected, actual); }
public void CanAddNegativeYears() { var dt = new Date(2000, 1, 1); var actual = dt.AddYears(-1); var expected = new Date(1999, 1, 1); Assert.Equal(expected, actual); }
public void CanAddZeroYears() { var dt = new Date(2000, 1, 1); var actual = dt.AddYears(0); var expected = new Date(2000, 1, 1); Assert.Equal(expected, actual); }
public override bool isBusinessDay(Date date) { DayOfWeek w = date.DayOfWeek; int d = date.Day, dd = date.DayOfYear; Month m = (Month)date.Month; int y = date.Year; int em = easterMonday(y); if (isWeekend(w) // Maunday Thursday || (dd == em - 4) // Good Friday || (dd == em - 3) // Easter Monday || (dd == em) // General Prayer Day || (dd == em + 25) // Ascension || (dd == em + 38) // Whit Monday || (dd == em + 49) // New Year's Day || (d == 1 && m == Month.January) // Constitution Day, June 5th || (d == 5 && m == Month.June) // Christmas || (d == 25 && m == Month.December) // Boxing Day || (d == 26 && m == Month.December)) return false; return true; }
public void CanAddPositiveYears() { var dt = new Date(2000, 1, 1); var actual = dt.AddYears(1); var expected = new Date(2001, 1, 1); Assert.Equal(expected, actual); }
public SwaptionVolatilityDiscrete(List<Period> optionTenors, List<Period> swapTenors, Date referenceDate, Calendar cal, BusinessDayConvention bdc, DayCounter dc) : base(referenceDate, cal, bdc, dc) { nOptionTenors_ = optionTenors.Count; optionTenors_ = optionTenors; optionDates_ = new InitializedList<Date>(nOptionTenors_); optionTimes_ = new InitializedList<double>(nOptionTenors_); optionDatesAsReal_ = new InitializedList<double>(nOptionTenors_); nSwapTenors_ = swapTenors.Count; swapTenors_ = swapTenors; swapLengths_ = new InitializedList<double>(nSwapTenors_); checkOptionTenors(); initializeOptionDatesAndTimes(); checkSwapTenors(); initializeSwapLengths(); optionInterpolator_ = new LinearInterpolation(optionTimes_, optionTimes_.Count, optionDatesAsReal_); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); }
//! fixed-rate bond /*! \ingroup instruments \test calculations are tested by checking results against cached values. */ //! simple annual compounding coupon rates public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,List<double> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, double redemption = 100, Date issueDate = null,Calendar paymentCalendar = null, Period exCouponPeriod = null, Calendar exCouponCalendar = null, BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted, bool exCouponEndOfMonth = false) : base(settlementDays, paymentCalendar == null ? schedule.calendar() : paymentCalendar, issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, accrualDayCounter) .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth) .withPaymentCalendar(calendar_) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List<double>() { redemption }); if (cashflows().Count == 0) throw new ApplicationException("bond with no cashflows!"); if (redemptions_.Count != 1) throw new ApplicationException("multiple redemptions created"); }
public DiscretizedSwap(VanillaSwap.Arguments args, Date referenceDate, DayCounter dayCounter) { arguments_ = args; fixedResetTimes_ = new InitializedList<double>(args.fixedResetDates.Count); for (int i = 0; i < fixedResetTimes_.Count; ++i) fixedResetTimes_[i] = dayCounter.yearFraction(referenceDate, args.fixedResetDates[i]); fixedPayTimes_ = new InitializedList<double>(args.fixedPayDates.Count); for (int i = 0; i < fixedPayTimes_.Count; ++i) fixedPayTimes_[i] = dayCounter.yearFraction(referenceDate, args.fixedPayDates[i]); floatingResetTimes_ = new InitializedList<double>(args.floatingResetDates.Count); for (int i = 0; i < floatingResetTimes_.Count; ++i) floatingResetTimes_[i] = dayCounter.yearFraction(referenceDate, args.floatingResetDates[i]); floatingPayTimes_ = new InitializedList<double>(args.floatingPayDates.Count); for (int i = 0; i < floatingPayTimes_.Count; ++i) floatingPayTimes_[i] = dayCounter.yearFraction(referenceDate, args.floatingPayDates[i]); }
public SwaptionVolatilityDiscrete(List<Period> optionTenors, List<Period> swapTenors, int settlementDays, Calendar cal, BusinessDayConvention bdc, DayCounter dc) : base(settlementDays, cal, bdc, dc) { nOptionTenors_ = optionTenors.Count; optionTenors_ = optionTenors; optionDates_ = new InitializedList<Date>(nOptionTenors_); optionTimes_ = new InitializedList<double>(nOptionTenors_); optionDatesAsReal_ = new InitializedList<double>(nOptionTenors_); nSwapTenors_ = swapTenors.Count; swapTenors_ = swapTenors; swapLengths_ = new InitializedList<double>(nSwapTenors_); checkOptionTenors(); initializeOptionDatesAndTimes(); checkSwapTenors(); initializeSwapLengths(); optionInterpolator_ = new LinearInterpolation(optionTimes_, optionTimes_.Count, optionDatesAsReal_); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); evaluationDate_ = Settings.evaluationDate(); Settings.registerWith(update); }
public static Date date(string immCode, Date refDate) { if (!isIMMcode(immCode, false)) throw new ArgumentException(immCode + " is not a valid IMM code"); Date referenceDate = (refDate != null ? refDate : Settings.evaluationDate()); int m = "FGHJKMNQUVXZ".IndexOf(immCode.ToUpper()[0]) + 1; if (m == 0) throw new ArgumentException("invalid IMM month letter"); if (!Char.IsDigit(immCode[1])) throw new ArgumentException(immCode + " is not a valid IMM code"); int y = immCode[1] - '0'; y += referenceDate.Year - (referenceDate.Year % 10); /* year<10 are not valid years: to avoid a run-time exception in few lines below we need to add 10 years right away */ if (y == 0 && referenceDate.Year <= 1909) y += 10; Date result = IMM.nextDate(new Date(1, m, y), false); if (result<referenceDate) result = IMM.nextDate(new Date(1, m, y + 10), false); return result; }
public AmericanExercise(Date latest, bool payoffAtExpiry) : base(Type.American, payoffAtExpiry) { dates_ = new InitializedList<Date>(2); dates_[0] = Date.minDate(); dates_[1] = latest; }
public AmortizingFixedRateBond( int settlementDays, Calendar calendar, double faceAmount, Date startDate, Period bondTenor, Frequency sinkingFrequency, double coupon, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, Date issueDate = null) :base(settlementDays, calendar, issueDate) { frequency_ = sinkingFrequency; dayCounter_ = accrualDayCounter; Utils.QL_REQUIRE( bondTenor.length() > 0,() => "bond tenor must be positive. " + bondTenor + " is not allowed." ); maturityDate_ = startDate + bondTenor; maturityDate_ = startDate + bondTenor; schedule_ = sinkingSchedule(startDate, bondTenor, sinkingFrequency, calendar); cashflows_ = new FixedRateLeg(schedule_) .withCouponRates(coupon, accrualDayCounter) .withNotionals(sinkingNotionals(bondTenor, sinkingFrequency, coupon, faceAmount)) .withPaymentAdjustment(paymentConvention).value(); addRedemptionsToCashflows(); }
public void CalculateDifference_ShouldNotChangePeriod() { var period = new Date(2000, 1, 1); var period1 = new Date(2001, 1, 1); period.CalculateDifference(period1); Assert.AreEqual(period, new Date(2000,1,1)); }
public override bool isBusinessDay(Date date) { DayOfWeek w = date.DayOfWeek; int d = date.Day, dd = date.DayOfYear; Month m = (Month)date.Month; int y = date.Year; int em = easterMonday(y); if (isWeekend(w) // New Year's Day || (d == 1 && m == Month.January) // Good Friday || (dd == em - 3 && y >= 2000) // Easter Monday || (dd == em && y >= 2000) // Labour Day || (d == 1 && m == Month.May && y >= 2000) // Christmas || (d == 25 && m == Month.December) // Day of Goodwill || (d == 26 && m == Month.December && y >= 2000) // December 31st, 1998, 1999, and 2001 only || (d == 31 && m == Month.December && (y == 1998 || y == 1999 || y == 2001))) return false; return true; }
public AmortizingFixedRateBond( int settlementDays, List<double> notionals, Schedule schedule, List<double> coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following, Date issueDate = null) :base(settlementDays, schedule.calendar(), issueDate) { frequency_ = schedule.tenor().frequency(); dayCounter_ = accrualDayCounter; schedule_ = schedule; maturityDate_ = schedule.endDate(); cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, accrualDayCounter) .withNotionals(notionals) .withPaymentAdjustment(paymentConvention).value(); addRedemptionsToCashflows(); if ( cashflows().empty()) throw new ApplicationException("bond with no cashflows!"); }
public PartialViewResult CreateDate(DateTime dateTime, int timeSlotId) { Contact contact = SessionHelper.GetInstance().CurrentUser; if (contact != null) { TimeSlot timeSlot = SlotRepository.GetById(timeSlotId); try { Guid confirmationId = Guid.NewGuid(); Date date = new Date{ Contact = contact, TimeSlot = timeSlot, Day = dateTime, IsConfirmed = false, ConfirmationId = confirmationId.ToString() }; DateRepository.Save(date); string serverAddress = Constants.GetInstance().ServerAddress(Request); Email.GetInstance().SendForPatientPropose(date, serverAddress); Email.GetInstance().SendForAdminPropose(date); return PartialView("CreateDate", date); } catch (Exception ex) { ViewBag.ResultMessage = DateResource.ErrorOccured; return PartialView("CreateDate"); } } return PartialView("/Views/Login/Index.cshtml"); }
public double getCPR(Date valDate) { Thirty360 dayCounter = new Thirty360(); int d = dayCounter.dayCount(_startDate,valDate)/30 + 1; return (d <= 30 ? 0.06 * (d / 30d) : 0.06) * _multi; }
public CallableBondConstantVolatility(Date referenceDate, double volatility, DayCounter dayCounter) :base(referenceDate) { volatility_ = new Handle<Quote>(new SimpleQuote(volatility)); dayCounter_ = dayCounter; maxBondTenor_ = new Period(100,TimeUnit.Years); }
public override bool isBusinessDay(Date date) { DayOfWeek w = date.DayOfWeek; int d = date.Day, dd = date.DayOfYear; Month m = (Month)date.Month; int y = date.Year; int em = easterMonday(y); if (isWeekend(w) // Holy Thursday || (dd == em-4) // Good Friday || (dd == em-3) // Easter Monday || (dd == em) // Ascension Thursday || (dd == em+38) // Whit Monday || (dd == em+49) // New Year's Day || (d == 1 && m == Month.January) // May Day || (d == 1 && m == Month.May) // National Independence Day || (d == 17 && m == Month.May) // Christmas || (d == 25 && m == Month.December) // Boxing Day || (d == 26 && m == Month.December)) return false; return true; }
public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, int fixingDays, List<double> gearings, List<double> spreads, List<double> caps, List<double> floors, bool inArrears, double redemption, Date issueDate) : base(settlementDays, schedule.calendar(), issueDate) { maturityDate_ = schedule.endDate(); cashflows_ = new IborLeg(schedule, index) .withPaymentDayCounter(paymentDayCounter) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears) .withNotionals(faceAmount) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(new List<double>() { redemption }); if (cashflows().Count == 0) throw new ApplicationException("bond with no cashflows!"); if (redemptions_.Count != 1) throw new ApplicationException("multiple redemptions created"); index.registerWith(update); }
// todo // cleanup // SavedSettings backup; // setup public CommonVars() { calendar = new TARGET(); today = calendar.adjust(Date.Today); Settings.setEvaluationDate(today); faceAmount = 1000000.0; }
public void WriteRawValueWritesDate() { RawValueWriter target = new RawValueWriter(this.settings, this.stream, new UTF32Encoding()); Date value = new Date(2014, 9, 18); target.WriteRawValue(value); this.StreamAsString(target).Should().Be("2014-09-18"); }
//! \name Volatility /*! by default, inflation is observed with the lag of the term structure. Because inflation is highly linked to dates (for interpolation, periods, etc) time-based overload of the methods are not provided. */ //@{ //! Returns the volatility for a given maturity date and strike rate. double volatility(Date maturityDate, double strike, Period obsLag = null, bool extrapolate = false) { if (obsLag == null) obsLag = new Period(-1, TimeUnit.Days); Period useLag = obsLag; if (obsLag == new Period(-1, TimeUnit.Days)) { useLag = observationLag(); } if (indexIsInterpolated()) { checkRange(maturityDate - useLag, strike, extrapolate); double t = timeFromReference(maturityDate - useLag); return volatilityImpl(t, strike); } else { KeyValuePair<Date, Date> dd = Utils.inflationPeriod(maturityDate - useLag, frequency()); checkRange(dd.Key, strike, extrapolate); double t = timeFromReference(dd.Key); return volatilityImpl(t, strike); } }
public void testAmortizingBond1() { // Input Values double faceValue = 40000; double marketValue = 43412; double couponRate = 0.06; Date issueDate = new Date(1, Month.January, 2001); Date maturirtyDate = new Date(1, Month.January, 2005); Date tradeDate = new Date(1, Month.January, 2004); Frequency paymentFrequency = Frequency.Semiannual; DayCounter dc = new Thirty360(Thirty360.Thirty360Convention.USA); // Build Bond AmortizingBond bond = BondFactory.makeAmortizingBond(faceValue, marketValue, couponRate, issueDate, maturirtyDate, tradeDate, paymentFrequency, dc, AmortizingMethod.EffectiveInterestRate); // Amortizing Yield ( Effective Rate ) double y1 = bond.Yield(); Assert.AreEqual(-0.0236402, y1, 0.001, "Amortizing Yield is different"); // Amortized Cost at Date double Amort1 = bond.AmortizationValue(new Date(31, Month.August, 2004)); Assert.AreEqual(41126.01, Amort1, 100, "Amortized Cost at 08/31/2004 is different"); double Amort2 = bond.AmortizationValue(new Date(30, Month.September, 2004)); Assert.AreEqual(40842.83, Amort2, 100, "Amortized Cost at 09/30/2004 is different"); }
public FixedRateCoupon(double nominal, Date paymentDate, InterestRate interestRate, Date accrualStartDate, Date accrualEndDate, Date refPeriodStart = null, Date refPeriodEnd = null,double? amount = null) : base(nominal, paymentDate, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd, amount) { rate_ = interestRate; }
public BlackVanillaOptionPricer(double forwardValue, Date expiryDate, Period swapTenor, SwaptionVolatilityStructure volatilityStructure) { forwardValue_ = forwardValue; expiryDate_ = expiryDate; swapTenor_ = swapTenor; volatilityStructure_ = volatilityStructure; smile_ = volatilityStructure_.smileSection(expiryDate_, swapTenor_); }
public bool IsWithin(Date date) { return(date >= Begin && date < End); }
public override void ToStream(Stream output) { output.Write(TLUtils.SignatureToBytes(Signature)); Date.ToStream(output); Seq.ToStream(output); }
public override string ToString() { return(Date.ToString()); }
public FlatSmileSection(Date d, double vol, DayCounter dc, Date referenceDate = null, double?atmLevel = null) : base(d, dc, referenceDate) { vol_ = vol; atmLevel_ = atmLevel; }
public void TestCreateDataFrame() { // Calling CreateDataFrame with schema { var data = new List <GenericRow> { new GenericRow(new object[] { "Alice", 20, new Date(2020, 1, 1) }), new GenericRow(new object[] { "Bob", 30, new Date(2020, 1, 2) }) }; var schema = new StructType(new List <StructField>() { new StructField("Name", new StringType()), new StructField("Age", new IntegerType()), new StructField("Date", new DateType()) }); DataFrame df = _spark.CreateDataFrame(data, schema); ValidateDataFrame(df, data.Select(a => a.Values), schema); } // Calling CreateDataFrame(IEnumerable<string> _) without schema { var data = new string[] { "Alice", "Bob", null }; StructType schema = SchemaWithSingleColumn(new StringType()); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<int> _) without schema { var data = new int[] { 1, 2 }; StructType schema = SchemaWithSingleColumn(new IntegerType(), false); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<int?> _) without schema { var data = new int?[] { 1, 2, null }; StructType schema = SchemaWithSingleColumn(new IntegerType()); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<double> _) without schema { var data = new double[] { 1.2, 2.3 }; StructType schema = SchemaWithSingleColumn(new DoubleType(), false); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<double?> _) without schema { var data = new double?[] { 1.2, 2.3, null }; StructType schema = SchemaWithSingleColumn(new DoubleType()); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<bool> _) without schema { var data = new bool[] { true, false }; StructType schema = SchemaWithSingleColumn(new BooleanType(), false); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<bool?> _) without schema { var data = new bool?[] { true, false, null }; StructType schema = SchemaWithSingleColumn(new BooleanType()); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } // Calling CreateDataFrame(IEnumerable<Date> _) without schema { var data = new Date[] { new Date(2020, 1, 1), new Date(2020, 1, 2), null }; StructType schema = SchemaWithSingleColumn(new DateType()); DataFrame df = _spark.CreateDataFrame(data); ValidateDataFrame(df, data.Select(a => new object[] { a }), schema); } }
public UstaPayload(TaxCase taxCase, DataSupplier dataSupplier, Date creationDate) { this.TaxCase = taxCase ?? throw new ArgumentNullException(nameof(taxCase)); this.DataSupplier = dataSupplier ?? throw new ArgumentNullException(nameof(dataSupplier)); this.CreationDate = creationDate ?? throw new ArgumentNullException(nameof(creationDate)); }
private bool Equals(CompositeOne other) => Id1 == other.Id1 && Equals(Id2, other.Id2) && string.Equals(Name, other.Name) && Date.Equals(other.Date);
/// <inheritdoc/> public override async Task SetParametersAsync(ParameterView parameters) { var dateChanged = parameters.TryGetValue <TValue>(nameof(Date), out var paramDate) && !Date.Equals(paramDate); var datesChanged = parameters.TryGetValue(nameof(Dates), out IEnumerable <TValue> paramDates) && !Dates.AreEqual(paramDates); var minChanged = parameters.TryGetValue(nameof(Min), out DateTimeOffset? paramMin) && !Min.IsEqual(paramMin); var maxChanged = parameters.TryGetValue(nameof(Max), out DateTimeOffset? paramMax) && !Max.IsEqual(paramMax); var firstDayOfWeekChanged = parameters.TryGetValue(nameof(FirstDayOfWeek), out DayOfWeek paramFirstDayOfWeek) && !FirstDayOfWeek.IsEqual(paramFirstDayOfWeek); var displayFormatChanged = parameters.TryGetValue(nameof(DisplayFormat), out string paramDisplayFormat) && DisplayFormat != paramDisplayFormat; var timeAs24hrChanged = parameters.TryGetValue(nameof(TimeAs24hr), out bool paramTimeAs24hr) && TimeAs24hr != paramTimeAs24hr; var disabledChanged = parameters.TryGetValue(nameof(Disabled), out bool paramDisabled) && Disabled != paramDisabled; var readOnlyChanged = parameters.TryGetValue(nameof(ReadOnly), out bool paramReadOnly) && ReadOnly != paramReadOnly; var disabledDatesChanged = parameters.TryGetValue(nameof(DisabledDates), out IEnumerable <TValue> paramDisabledDates) && !DisabledDates.AreEqual(paramDisabledDates); var selectionModeChanged = parameters.TryGetValue(nameof(SelectionMode), out DateInputSelectionMode paramSelectionMode) && !SelectionMode.IsEqual(paramSelectionMode); var inlineChanged = parameters.TryGetValue(nameof(Inline), out bool paramInline) && Inline != paramInline; if (dateChanged || datesChanged) { var formatedDateString = SelectionMode != DateInputSelectionMode.Single ? FormatValueAsString(paramDates?.ToArray()) : FormatValueAsString(new TValue[] { paramDate }); await CurrentValueHandler(formatedDateString); if (Rendered) { ExecuteAfterRender(async() => await JSModule.UpdateValue(ElementRef, ElementId, formatedDateString)); } } if (Rendered && (minChanged || maxChanged || firstDayOfWeekChanged || displayFormatChanged || timeAs24hrChanged || disabledChanged || readOnlyChanged || disabledDatesChanged || selectionModeChanged || inlineChanged)) { ExecuteAfterRender(async() => await JSModule.UpdateOptions(ElementRef, ElementId, new { FirstDayOfWeek = new { Changed = firstDayOfWeekChanged, Value = (int)paramFirstDayOfWeek }, DisplayFormat = new { Changed = displayFormatChanged, Value = DateTimeFormatConverter.Convert(paramDisplayFormat) }, TimeAs24hr = new { Changed = timeAs24hrChanged, Value = paramTimeAs24hr }, Min = new { Changed = minChanged, Value = paramMin?.ToString(DateFormat) }, Max = new { Changed = maxChanged, Value = paramMax?.ToString(DateFormat) }, Disabled = new { Changed = disabledChanged, Value = paramDisabled }, ReadOnly = new { Changed = readOnlyChanged, Value = paramReadOnly }, DisabledDates = new { Changed = disabledDatesChanged, Value = paramDisabledDates?.Select(x => FormatValueAsString(new TValue[] { x })) }, SelectionMode = new { Changed = selectionModeChanged, Value = paramSelectionMode }, Inline = new { Changed = inlineChanged, Value = paramInline }, })); } // Let blazor do its thing! await base.SetParametersAsync(parameters); if (ParentValidation != null) { if (parameters.TryGetValue <Expression <Func <TValue> > >(nameof(DateExpression), out var expression)) { await ParentValidation.InitializeInputExpression(expression); } if (parameters.TryGetValue <string>(nameof(Pattern), out var pattern)) { // make sure we get the newest value var value = parameters.TryGetValue <TValue>(nameof(Date), out var inDate) ? new TValue[] { inDate } : InternalValue; await ParentValidation.InitializeInputPattern(pattern, value); } await InitializeValidation(); } }
public void Show() { Console.WriteLine(Date.ToString() + " " + Key + " " + Url + " " + Mail); }
public Engine(Action <Options> options) { _executionContexts = new Stack <ExecutionContext>(); Global = GlobalObject.CreateGlobalObject(this); Object = ObjectConstructor.CreateObjectConstructor(this); Function = FunctionConstructor.CreateFunctionConstructor(this); Array = ArrayConstructor.CreateArrayConstructor(this); String = StringConstructor.CreateStringConstructor(this); RegExp = RegExpConstructor.CreateRegExpConstructor(this); Number = NumberConstructor.CreateNumberConstructor(this); Boolean = BooleanConstructor.CreateBooleanConstructor(this); Date = DateConstructor.CreateDateConstructor(this); Math = MathInstance.CreateMathObject(this); Json = JsonInstance.CreateJsonObject(this); Error = ErrorConstructor.CreateErrorConstructor(this, "Error"); EvalError = ErrorConstructor.CreateErrorConstructor(this, "EvalError"); RangeError = ErrorConstructor.CreateErrorConstructor(this, "RangeError"); ReferenceError = ErrorConstructor.CreateErrorConstructor(this, "ReferenceError"); SyntaxError = ErrorConstructor.CreateErrorConstructor(this, "SyntaxError"); TypeError = ErrorConstructor.CreateErrorConstructor(this, "TypeError"); UriError = ErrorConstructor.CreateErrorConstructor(this, "URIError"); // Because the properties might need some of the built-in object // their configuration is delayed to a later step Global.Configure(); Object.Configure(); Object.PrototypeObject.Configure(); Function.Configure(); Function.PrototypeObject.Configure(); Array.Configure(); Array.PrototypeObject.Configure(); String.Configure(); String.PrototypeObject.Configure(); RegExp.Configure(); RegExp.PrototypeObject.Configure(); Number.Configure(); Number.PrototypeObject.Configure(); Boolean.Configure(); Boolean.PrototypeObject.Configure(); Date.Configure(); Date.PrototypeObject.Configure(); Math.Configure(); Json.Configure(); Error.Configure(); Error.PrototypeObject.Configure(); // create the global environment http://www.ecma-international.org/ecma-262/5.1/#sec-10.2.3 GlobalEnvironment = LexicalEnvironment.NewObjectEnvironment(this, Global, null, false); // create the global execution context http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.1.1 EnterExecutionContext(GlobalEnvironment, GlobalEnvironment, Global); Options = new Options(); if (options != null) { options(Options); } Eval = new EvalFunctionInstance(this, new string[0], LexicalEnvironment.NewDeclarativeEnvironment(this, ExecutionContext.LexicalEnvironment), StrictModeScope.IsStrictModeCode); Global.FastAddProperty("eval", Eval, true, false, true); _statements = new StatementInterpreter(this); _expressions = new ExpressionInterpreter(this); if (Options._IsClrAllowed) { Global.FastAddProperty("System", new NamespaceReference(this, "System"), false, false, false); Global.FastAddProperty("importNamespace", new ClrFunctionInstance(this, (thisObj, arguments) => { return(new NamespaceReference(this, TypeConverter.ToString(arguments.At(0)))); }), false, false, false); } ClrTypeConverter = new DefaultTypeConverter(this); BreakPoints = new List <BreakPoint>(); DebugHandler = new DebugHandler(this); }
static void Main(string[] args) { DateTime startTime = DateTime.Now; Option.Type optionType = Option.Type.Put; double underlyingPrice = 36; double strikePrice = 40; double dividendYield = 0.0; double riskFreeRate = 0.06; double volatility = 0.2; Date todaysDate = new Date(15, Month.May, 1998); Settings.instance().setEvaluationDate(todaysDate); Date settlementDate = new Date(17, Month.May, 1998); Date maturityDate = new Date(17, Month.May, 1999); Calendar calendar = new TARGET(); DateVector exerciseDates = new DateVector(4); for (int i = 1; i <= 4; i++) { Period forwardPeriod = new Period(3 * i, TimeUnit.Months); Date forwardDate = settlementDate.Add(forwardPeriod); exerciseDates.Add(forwardDate); } EuropeanExercise europeanExercise = new EuropeanExercise(maturityDate); BermudanExercise bermudanExercise = new BermudanExercise(exerciseDates); AmericanExercise americanExercise = new AmericanExercise(settlementDate, maturityDate); // bootstrap the yield/dividend/vol curves and create a // BlackScholesMerton stochastic process DayCounter dayCounter = new Actual365Fixed(); YieldTermStructureHandle flatRateTSH = new YieldTermStructureHandle( new FlatForward(settlementDate, riskFreeRate, dayCounter)); YieldTermStructureHandle flatDividendTSH = new YieldTermStructureHandle( new FlatForward(settlementDate, dividendYield, dayCounter)); BlackVolTermStructureHandle flatVolTSH = new BlackVolTermStructureHandle( new BlackConstantVol(settlementDate, calendar, volatility, dayCounter)); QuoteHandle underlyingQuoteH = new QuoteHandle(new SimpleQuote(underlyingPrice)); BlackScholesMertonProcess stochasticProcess = new BlackScholesMertonProcess(underlyingQuoteH, flatDividendTSH, flatRateTSH, flatVolTSH); PlainVanillaPayoff payoff = new PlainVanillaPayoff(optionType, strikePrice); // options VanillaOption europeanOption = new VanillaOption(payoff, europeanExercise); VanillaOption bermudanOption = new VanillaOption(payoff, bermudanExercise); VanillaOption americanOption = new VanillaOption(payoff, americanExercise); // report the parameters we are using ReportParameters(optionType, underlyingPrice, strikePrice, dividendYield, riskFreeRate, volatility, maturityDate); // write out the column headings ReportHeadings(); #region Analytic Formulas // Black-Scholes for European try { europeanOption.setPricingEngine( new AnalyticEuropeanEngine(stochasticProcess)); ReportResults("Black-Scholes", europeanOption.NPV(), null, null); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Barone-Adesi and Whaley approximation for American try { americanOption.setPricingEngine( new BaroneAdesiWhaleyEngine(stochasticProcess)); ReportResults("Barone-Adesi/Whaley", null, null, americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Bjerksund and Stensland approximation for American try { americanOption.setPricingEngine( new BjerksundStenslandEngine(stochasticProcess)); ReportResults("Bjerksund/Stensland", null, null, americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Integral try { europeanOption.setPricingEngine( new IntegralEngine(stochasticProcess)); ReportResults("Integral", europeanOption.NPV(), null, null); } catch (Exception e) { Console.WriteLine(e.ToString()); } uint timeSteps = 801; // Finite differences try { europeanOption.setPricingEngine( new FdBlackScholesVanillaEngine(stochasticProcess, timeSteps, timeSteps - 1)); bermudanOption.setPricingEngine( new FdBlackScholesVanillaEngine(stochasticProcess, timeSteps, timeSteps - 1)); americanOption.setPricingEngine( new FdBlackScholesVanillaEngine(stochasticProcess, timeSteps, timeSteps - 1)); ReportResults("Finite differences", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } //Variance Gamma try { VarianceGammaProcess vgProcess = new VarianceGammaProcess(underlyingQuoteH, flatDividendTSH, flatRateTSH, volatility, 0.01, 0.0 ); europeanOption.setPricingEngine( new VarianceGammaEngine(vgProcess)); ReportResults("Variance-Gamma", europeanOption.NPV(), null, null); } catch (Exception e) { Console.WriteLine(e.ToString()); } #endregion Analytic Formulas #region Binomial Methods // Binomial Jarrow-Rudd try { europeanOption.setPricingEngine( new BinomialJRVanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialJRVanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialJRVanillaEngine(stochasticProcess, timeSteps)); ReportResults("Binomial Jarrow-Rudd", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Binomial Cox-Ross-Rubinstein try { europeanOption.setPricingEngine( new BinomialCRRVanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialCRRVanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialCRRVanillaEngine(stochasticProcess, timeSteps)); ReportResults("Binomial Cox-Ross-Rubinstein", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Additive Equiprobabilities try { europeanOption.setPricingEngine( new BinomialEQPVanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialEQPVanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialEQPVanillaEngine(stochasticProcess, timeSteps)); ReportResults("Additive Equiprobabilities", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Binomial Trigeorgis try { europeanOption.setPricingEngine( new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialTrigeorgisVanillaEngine(stochasticProcess, timeSteps)); ReportResults("Binomial Trigeorgis", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Binomial Tian try { europeanOption.setPricingEngine( new BinomialTianVanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialTianVanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialTianVanillaEngine(stochasticProcess, timeSteps)); ReportResults("Binomial Tian", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Binomial Leisen-Reimer try { europeanOption.setPricingEngine( new BinomialLRVanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialLRVanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialLRVanillaEngine(stochasticProcess, timeSteps)); ReportResults("Binomial Leisen-Reimer", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } // Binomial Joshi try { europeanOption.setPricingEngine( new BinomialJ4VanillaEngine(stochasticProcess, timeSteps)); bermudanOption.setPricingEngine( new BinomialJ4VanillaEngine(stochasticProcess, timeSteps)); americanOption.setPricingEngine( new BinomialJ4VanillaEngine(stochasticProcess, timeSteps)); ReportResults("Binomial Joshi", europeanOption.NPV(), bermudanOption.NPV(), americanOption.NPV()); } catch (Exception e) { Console.WriteLine(e.ToString()); } #endregion Binomial Methods #region Monte Carlo Methods // quantlib appears to use max numeric (int and real) values to test for 'null' (or rather 'default') values // MC (crude) try { int mcTimeSteps = 1; int timeStepsPerYear = int.MaxValue; bool brownianBridge = false; bool antitheticVariate = false; int requiredSamples = int.MaxValue; double requiredTolerance = 0.02; int maxSamples = int.MaxValue; int seed = 42; europeanOption.setPricingEngine( new MCPREuropeanEngine(stochasticProcess, mcTimeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, requiredSamples, requiredTolerance, maxSamples, seed)); ReportResults("MC (crude)", europeanOption.NPV(), null, null); } catch (Exception e) { Console.WriteLine(e.ToString()); } // MC (Sobol) try { int mcTimeSteps = 1; int timeStepsPerYear = int.MaxValue; bool brownianBridge = false; bool antitheticVariate = false; int requiredSamples = 32768; // 2^15 double requiredTolerance = double.MaxValue; int maxSamples = int.MaxValue; int seed = 0; europeanOption.setPricingEngine( new MCLDEuropeanEngine(stochasticProcess, mcTimeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, requiredSamples, requiredTolerance, maxSamples, seed)); ReportResults("MC (Sobol)", europeanOption.NPV(), null, null); } catch (Exception e) { Console.WriteLine(e.ToString()); } #endregion Monte Carlo Methods DateTime endTime = DateTime.Now; TimeSpan delta = endTime - startTime; Console.WriteLine(); Console.WriteLine("Run completed in {0} s", delta.TotalSeconds); Console.WriteLine(); }
public Mappings() { Func <string, bool> isGuid = s => Guid.TryParse(s, out var _); CreateMap <EvacuationFile, era_evacuationfile>(MemberList.None) .ForMember(d => d.era_name, opts => opts.MapFrom(s => s.Id)) .ForMember(d => d.era_paperbasedessfile, opts => opts.Ignore()) .ForMember(d => d.era_essfilestatus, opts => opts.Ignore()) .ForMember(d => d.era_evacuationfiledate, opts => opts.MapFrom(s => s.EvacuationDate)) .ForMember(d => d.era_securityphrase, opts => opts.Ignore()) .ForMember(d => d.era_needsassessment_EvacuationFile, opts => opts.MapFrom(s => s.NeedsAssessments)) .ForMember(d => d.era_addressline1, opts => opts.MapFrom(s => s.EvacuatedFromAddress.AddressLine1)) .ForMember(d => d.era_addressline2, opts => opts.MapFrom(s => s.EvacuatedFromAddress.AddressLine2)) .ForMember(d => d.era_postalcode, opts => opts.MapFrom(s => s.EvacuatedFromAddress.PostalCode)) .ForMember(d => d.era_city, opts => opts.MapFrom(s => isGuid(s.EvacuatedFromAddress.CommunityCode) ? null : s.EvacuatedFromAddress.CommunityCode)) .ForMember(d => d.era_country, opts => opts.MapFrom(s => s.EvacuatedFromAddress.CountryCode)) .ForMember(d => d.era_province, opts => opts.MapFrom(s => s.EvacuatedFromAddress.StateProvinceCode)) .ForMember(d => d.era_registrationlocation, opts => opts.MapFrom(s => s.RegistrationLocation)) ; CreateMap <era_evacuationfile, EvacuationFile>() .ForMember(d => d.Id, opts => opts.MapFrom(s => s.era_name)) .ForMember(d => d.TaskId, opts => opts.MapFrom(s => s.era_TaskId == null ? null : s.era_TaskId.era_taskdetails)) .ForMember(d => d.CreatedOn, opts => opts.MapFrom(s => s.createdon.Value.DateTime)) .ForMember(d => d.LastModified, opts => opts.MapFrom(s => s.modifiedon.Value.DateTime)) .ForMember(d => d.PrimaryRegistrantId, opts => opts.MapFrom(s => s.era_Registrant.contactid.ToString())) .ForMember(d => d.SecurityPhrase, opts => opts.ConvertUsing <SecurityPhraseConverter, string>(s => s.era_securityphrase)) .ForMember(d => d.SecurityPhraseChanged, opts => opts.MapFrom(s => false)) .ForMember(d => d.EvacuationDate, opts => opts.MapFrom(s => s.era_evacuationfiledate.Value.UtcDateTime)) .ForMember(d => d.NeedsAssessments, opts => opts.MapFrom(s => s.era_needsassessment_EvacuationFile)) .ForMember(d => d.Status, opts => opts.MapFrom(s => s.era_essfilestatus)) .ForMember(d => d.EvacuatedFromAddress, opts => opts.MapFrom(s => s)) .ForMember(d => d.IsSecretPhraseMasked, opts => opts.MapFrom((s, d, _, ctx) => SecurityPhraseConverter.ShouldMaskSecretPhrase(ctx))) .ForMember(d => d.RestrictedAccess, opts => opts.Ignore()) .ForMember(d => d.RegistrationLocation, opts => opts.MapFrom(s => s.era_registrationlocation)) ; CreateMap <era_evacuationfile, EvacuationAddress>(MemberList.None) .ForMember(d => d.AddressLine1, opts => opts.MapFrom(s => s.era_addressline1)) .ForMember(d => d.AddressLine2, opts => opts.MapFrom(s => s.era_addressline2)) .ForMember(d => d.PostalCode, opts => opts.MapFrom(s => s.era_postalcode)) .ForMember(d => d.CommunityCode, opts => opts.MapFrom(s => s.era_Jurisdiction.era_jurisdictionid)) .ForMember(d => d.StateProvinceCode, opts => opts.MapFrom(s => s.era_Jurisdiction.era_RelatedProvinceState.era_code)) .ForMember(d => d.CountryCode, opts => opts.MapFrom(s => s.era_Jurisdiction.era_RelatedProvinceState.era_RelatedCountry.era_countrycode)) ; CreateMap <NeedsAssessment, era_needassessment>(MemberList.None) .ForMember(d => d.era_needassessmentid, opts => opts.MapFrom(s => s.Id)) .ForMember(d => d.era_needsassessmenttype, opts => opts.MapFrom(s => (int?)Enum.Parse <NeedsAssessmentTypeOptionSet>(s.Type.ToString()))) .ForMember(d => d.era_canevacueeprovidefood, opts => opts.MapFrom(s => Lookup(s.CanEvacueeProvideFood))) .ForMember(d => d.era_canevacueeprovideclothing, opts => opts.MapFrom(s => Lookup(s.CanEvacueeProvideClothing))) .ForMember(d => d.era_canevacueeprovideincidentals, opts => opts.MapFrom(s => Lookup(s.CanEvacueeProvideIncidentals))) .ForMember(d => d.era_canevacueeprovidelodging, opts => opts.MapFrom(s => Lookup(s.CanEvacueeProvideLodging))) .ForMember(d => d.era_canevacueeprovidetransportation, opts => opts.MapFrom(s => Lookup(s.CanEvacueeProvideTransportation))) .ForMember(d => d.era_dietaryrequirement, opts => opts.MapFrom(s => s.HaveSpecialDiet)) .ForMember(d => d.era_dietaryrequirementdetails, opts => opts.MapFrom(s => s.SpecialDietDetails)) .ForMember(d => d.era_medicationrequirement, opts => opts.MapFrom(s => s.HaveMedication)) .ForMember(d => d.era_insurancecoverage, opts => opts.MapFrom(s => (int?)Enum.Parse <InsuranceOptionOptionSet>(s.Insurance.ToString()))) .ForMember(d => d.era_haspetfood, opts => opts.MapFrom(s => Lookup(s.HasPetsFood))) .ForMember(d => d.era_householdrecoveryplan, opts => opts.MapFrom(s => s.Notes.Where(n => n.Type == NoteType.RecoveryPlan).FirstOrDefault().Content)) .ForMember(d => d.era_evacuationimpacttohousehold, opts => opts.MapFrom(s => s.Notes.Where(n => n.Type == NoteType.EvacuationImpact).FirstOrDefault().Content)) .ForMember(d => d.era_externalreferralsdetails, opts => opts.MapFrom(s => s.Notes.Where(n => n.Type == NoteType.ExternalReferralServices).FirstOrDefault().Content)) .ForMember(d => d.era_petcareplans, opts => opts.MapFrom(s => s.Notes.Where(n => n.Type == NoteType.PetCarePlans).FirstOrDefault().Content)) .ForMember(d => d.era_haschildcarereferral, opts => opts.MapFrom(s => s.RecommendedReferralServices.Contains(ReferralServices.ChildCare))) .ForMember(d => d.era_hasfirstaidreferral, opts => opts.MapFrom(s => s.RecommendedReferralServices.Contains(ReferralServices.FirstAid))) .ForMember(d => d.era_hasinquiryreferral, opts => opts.MapFrom(s => s.RecommendedReferralServices.Contains(ReferralServices.Inquiry))) .ForMember(d => d.era_haspersonalservicesreferral, opts => opts.MapFrom(s => s.RecommendedReferralServices.Contains(ReferralServices.Personal))) .ForMember(d => d.era_haspetcarereferral, opts => opts.MapFrom(s => s.RecommendedReferralServices.Contains(ReferralServices.PetCare))) .ForMember(d => d.era_hashealthservicesreferral, opts => opts.MapFrom(s => s.RecommendedReferralServices.Contains(ReferralServices.Health))) ; CreateMap <era_needassessment, NeedsAssessment>() .ForMember(d => d.Id, opts => opts.MapFrom(s => s.era_needassessmentid)) .ForMember(d => d.CreatedOn, opts => opts.MapFrom(s => s.createdon.Value.DateTime)) .ForMember(d => d.LastModified, opts => opts.MapFrom(s => s.modifiedon.Value.DateTime)) .ForMember(d => d.Type, opts => opts.MapFrom(s => (int?)Enum.Parse <NeedsAssessmentType>(((NeedsAssessmentTypeOptionSet)s.era_needsassessmenttype).ToString()))) .ForMember(d => d.CanEvacueeProvideClothing, opts => opts.MapFrom(s => Lookup(s.era_canevacueeprovideclothing))) .ForMember(d => d.CanEvacueeProvideFood, opts => opts.MapFrom(s => Lookup(s.era_canevacueeprovidefood))) .ForMember(d => d.CanEvacueeProvideIncidentals, opts => opts.MapFrom(s => Lookup(s.era_canevacueeprovideincidentals))) .ForMember(d => d.CanEvacueeProvideLodging, opts => opts.MapFrom(s => Lookup(s.era_canevacueeprovidelodging))) .ForMember(d => d.CanEvacueeProvideTransportation, opts => opts.MapFrom(s => Lookup(s.era_canevacueeprovidetransportation))) .ForMember(d => d.HaveMedication, opts => opts.MapFrom(s => s.era_medicationrequirement)) .ForMember(d => d.Insurance, opts => opts.MapFrom(s => Enum.Parse <InsuranceOption>(((InsuranceOptionOptionSet)s.era_insurancecoverage).ToString()))) .ForMember(d => d.HaveSpecialDiet, opts => opts.MapFrom(s => s.era_dietaryrequirement)) .ForMember(d => d.SpecialDietDetails, opts => opts.MapFrom(s => s.era_dietaryrequirementdetails)) .ForMember(d => d.HasPetsFood, opts => opts.MapFrom(s => Lookup(s.era_haspetfood))) .ForMember(d => d.HouseholdMembers, opts => opts.MapFrom(s => Array.Empty <HouseholdMember>())) .ForMember(d => d.Pets, opts => opts.MapFrom(s => Array.Empty <Pet>())) .ForMember(d => d.Notes, opts => opts.MapFrom(s => new[] { string.IsNullOrEmpty(s.era_householdrecoveryplan) ? null : new Note { Type = NoteType.RecoveryPlan, Content = s.era_householdrecoveryplan }, string.IsNullOrEmpty(s.era_evacuationimpacttohousehold) ? null : new Note { Type = NoteType.EvacuationImpact, Content = s.era_evacuationimpacttohousehold }, string.IsNullOrEmpty(s.era_externalreferralsdetails) ? null : new Note { Type = NoteType.ExternalReferralServices, Content = s.era_externalreferralsdetails }, string.IsNullOrEmpty(s.era_petcareplans) ? null : new Note { Type = NoteType.PetCarePlans, Content = s.era_petcareplans }, }.Where(n => n != null).ToArray())) .ForMember(s => s.RecommendedReferralServices, opts => opts.MapFrom(s => new[] { s.era_haschildcarereferral.GetValueOrDefault(false) ? ReferralServices.ChildCare : (ReferralServices?)null, s.era_hasfirstaidreferral.GetValueOrDefault(false) ? ReferralServices.FirstAid : (ReferralServices?)null, s.era_hasinquiryreferral.GetValueOrDefault(false) ? ReferralServices.Inquiry : (ReferralServices?)null, s.era_haspersonalservicesreferral.GetValueOrDefault(false) ? ReferralServices.Personal : (ReferralServices?)null, s.era_haspetcarereferral.GetValueOrDefault(false) ? ReferralServices.PetCare : (ReferralServices?)null, s.era_hashealthservicesreferral.GetValueOrDefault(false) ? ReferralServices.Health : (ReferralServices?)null, }.Where(r => r != null).ToArray())) ; CreateMap <era_householdmember, HouseholdMember>() .ForMember(d => d.Id, opts => opts.MapFrom(s => s.era_householdmemberid.ToString())) .ForMember(d => d.LinkedRegistrantId, opts => opts.MapFrom(s => s.era_Registrant.contactid)) .ForMember(d => d.RestrictedAccess, opts => opts.MapFrom(s => s.era_Registrant.era_restriction)) .ForMember(d => d.IsPrimaryRegistrant, opts => opts.MapFrom(s => s.era_isprimaryregistrant)) .ForMember(d => d.IsUnder19, opts => opts.MapFrom(s => s.era_isunder19)) .ForMember(d => d.FirstName, opts => opts.MapFrom(s => s.era_Registrant.firstname.ToString())) .ForMember(d => d.LastName, opts => opts.MapFrom(s => s.era_Registrant.lastname.ToString())) .ForMember(d => d.DateOfBirth, opts => opts.MapFrom(s => !s.era_Registrant.birthdate.HasValue ? null : $"{s.era_Registrant.birthdate.Value.Month:D2}/{s.era_Registrant.birthdate.Value.Day:D2}/{s.era_Registrant.birthdate.Value.Year:D4}")) .ForMember(d => d.Initials, opts => opts.MapFrom(s => s.era_Registrant.era_initial.ToString())) .ForMember(d => d.PreferredName, opts => opts.MapFrom(s => s.era_Registrant.era_preferredname.ToString())) .ForMember(d => d.Gender, opts => opts.ConvertUsing <GenderConverter, int?>(s => s.era_Registrant.gendercode)) ; CreateMap <HouseholdMember, era_householdmember>(MemberList.None) .ForMember(d => d.era_householdmemberid, opts => opts.MapFrom(s => Guid.Parse(s.Id))) .ForMember(d => d.era_isprimaryregistrant, opts => opts.MapFrom(s => s.IsPrimaryRegistrant)) .ForMember(d => d.era_isunder19, opts => opts.MapFrom(s => s.IsUnder19)) .ForMember(d => d.era_Registrant, opts => opts.MapFrom(s => s)) ; CreateMap <HouseholdMember, contact>(MemberList.None) .ForMember(d => d.contactid, opts => opts.MapFrom(s => s.LinkedRegistrantId)) .ForMember(d => d.era_registranttype, opts => opts.MapFrom(s => (int)(s.IsPrimaryRegistrant ? RegistrantType.Primary : RegistrantType.Member))) .ForMember(d => d.firstname, opts => opts.MapFrom(s => s.FirstName)) .ForMember(d => d.lastname, opts => opts.MapFrom(s => s.LastName)) .ForMember(d => d.era_initial, opts => opts.MapFrom(s => s.Initials)) .ForMember(d => d.era_preferredname, opts => opts.MapFrom(s => s.PreferredName)) .ForMember(d => d.gendercode, opts => opts.ConvertUsing <GenderConverter, string>(s => s.Gender)) .ForMember(d => d.birthdate, opts => opts.MapFrom(s => string.IsNullOrEmpty(s.DateOfBirth) ? (Date?)null : Date.Parse(s.DateOfBirth))) .ReverseMap() .ForMember(d => d.Gender, opts => opts.ConvertUsing <GenderConverter, int?>(s => s.gendercode)) .ForMember(d => d.DateOfBirth, opts => opts.MapFrom(s => !s.birthdate.HasValue ? null : $"{s.birthdate.Value.Month:D2}/{s.birthdate.Value.Day:D2}/{s.birthdate.Value.Year:D4}")) .ForMember(d => d.IsUnder19, opts => opts.MapFrom(s => s.birthdate.HasValue ? CheckIfUnder19Years(s.birthdate.Value, Date.Now) : (bool?)null)) .ForMember(d => d.RestrictedAccess, opts => opts.MapFrom(s => s.era_restriction ?? false)) ; CreateMap <era_needsassessmentanimal, Pet>() .ForMember(d => d.Quantity, opts => opts.MapFrom(s => s.era_numberofpets)) .ForMember(d => d.Type, opts => opts.MapFrom(s => s.era_name)) .ReverseMap() .ForMember(d => d.era_numberofpets, opts => opts.MapFrom(s => s.Quantity)) .ForMember(d => d.era_name, opts => opts.MapFrom(s => s.Type)); }
public bool CreateLeaseCanExecute() { return(Date != null && !Date.Equals("")); }
/// <summary> /// Overridden toString method /// </summary> /// <returns></returns> public override string ToString() { return($"{Date.ToShortDateString()},\t{Amount},\t{Category},\t{Description}\t\t{Hash}"); }
protected override void OnBarUpdate() { DateTime dtBegin = DateTime.MaxValue; switch (IntervalType) { case EnumIntervalType.Sec: dtBegin = MinBar.D.Date.AddHours(MinBar.D.Hour).AddMinutes(MinBar.D.Minute).AddSeconds(MinBar.D.Second / Interval * Interval); break; case EnumIntervalType.Min: dtBegin = MinBar.D.Date.AddHours(MinBar.D.Hour).AddMinutes(MinBar.D.Minute / Interval * Interval); break; case EnumIntervalType.Hour: dtBegin = MinBar.D.Date.AddHours(MinBar.D.Hour / Interval * Interval); break; case EnumIntervalType.Day: dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null); break; case EnumIntervalType.Week: dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null); dtBegin = dtBegin.Date.AddDays(1 - (byte)dtBegin.DayOfWeek); break; case EnumIntervalType.Month: dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null); dtBegin = new DateTime(dtBegin.Year, dtBegin.Month, 1); break; case EnumIntervalType.Year: dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null); dtBegin = new DateTime(dtBegin.Year, 1, 1); break; default: throw new Exception("参数错误"); } if (bar == null) //首次调用 { bar = new Bar { D = dtBegin, I = MinBar.I, V = MinBar.V, // kOld.preVol == 0 ? 0 : _tick.Volume - kOld.preVol; }; bar.H = MinBar.H; bar.L = MinBar.L; bar.O = MinBar.O; bar.C = MinBar.C; newbar = true; } else { if (bar.D == dtBegin) //在当前K线范围内 { newbar = false; bar.H = Math.Max(bar.H, MinBar.H); bar.L = Math.Min(bar.L, MinBar.L); bar.C = MinBar.C; bar.V = bar.V + MinBar.V; bar.I = MinBar.I; } else if (dtBegin > bar.D) { newbar = true; bar.D = dtBegin; bar.V = MinBar.V; bar.I = MinBar.I; bar.O = MinBar.O; bar.H = MinBar.H; bar.L = MinBar.L; bar.C = MinBar.C; } } if (newbar) { Date.Add(double.Parse(bar.D.ToString("yyyyMMdd"))); Time.Add(double.Parse(bar.D.ToString("0.HHmmss"))); Open.Add(bar.O); High.Add(bar.H); Low.Add(bar.L); Close.Add(bar.C); Volume.Add(bar.V); OpenInterest.Add(bar.I); } else { High[0] = bar.H; Low[0] = bar.L; Close[0] = bar.C; Volume[0] = bar.V; OpenInterest[0] = bar.I; } }
public override string ToString() => Date.ToString() + "\n" + UserFrom + ": \n" + Text + "\n";
public LinearInterpolatedSmileSection(Date d, DoubleVector strikes, DoubleVector stdDevs, double atmLevel, DayCounter dc, Linear interpolator, Date referenceDate) : this(NQuantLibcPINVOKE.new_LinearInterpolatedSmileSection__SWIG_18(Date.getCPtr(d), DoubleVector.getCPtr(strikes), DoubleVector.getCPtr(stdDevs), atmLevel, DayCounter.getCPtr(dc), Linear.getCPtr(interpolator), Date.getCPtr(referenceDate)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public override string ToString() { return(String.Format("{0}, Open:{1}, High:{2}, Low:{3}, Close:{4}, Vol:{5}", Date.ToShortDateString(), Open, High, Low, Close, Volume)); }
public LinearInterpolatedSmileSection(Date d, DoubleVector strikes, QuoteHandleVector stdDevHandles, QuoteHandle atmLevel, DayCounter dc, Linear interpolator, Date referenceDate, VolatilityType type) : this(NQuantLibcPINVOKE.new_LinearInterpolatedSmileSection__SWIG_11(Date.getCPtr(d), DoubleVector.getCPtr(strikes), QuoteHandleVector.getCPtr(stdDevHandles), QuoteHandle.getCPtr(atmLevel), DayCounter.getCPtr(dc), Linear.getCPtr(interpolator), Date.getCPtr(referenceDate), (int)type), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public LinearInterpolatedSmileSection(Date d, DoubleVector strikes, DoubleVector stdDevs, double atmLevel) : this(NQuantLibcPINVOKE.new_LinearInterpolatedSmileSection__SWIG_21(Date.getCPtr(d), DoubleVector.getCPtr(strikes), DoubleVector.getCPtr(stdDevs), atmLevel), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
private void IncrementDate() { Date = Date.AddDays(1); }
public LinearInterpolatedSmileSection(Date d, DoubleVector strikes, QuoteHandleVector stdDevHandles, QuoteHandle atmLevel, DayCounter dc) : this(NQuantLibcPINVOKE.new_LinearInterpolatedSmileSection__SWIG_14(Date.getCPtr(d), DoubleVector.getCPtr(strikes), QuoteHandleVector.getCPtr(stdDevHandles), QuoteHandle.getCPtr(atmLevel), DayCounter.getCPtr(dc)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
private void a_patient_that_has_a_condition_in_the_revised_term_only() { the_patient = new Patient(Guid.NewGuid(), Vendor.Emis, "ANOTHER-PATIENT-REF", "A0003", Date.Today().PlusYears(-20), Sexes.Both, null, DrugTerminology.Dmd, ClinicalTerminology.SNoMed); the_patient.Has(new ClinicalEntry(the_other_condition.Code, Date.Today())); }
private void DecrementDate() { Date = Date.AddDays(-1); }
public void CanConstructDateFromParts_MaxDay_29() { Date date = new Date(2000, 2, 29); Assert.Equal(730178, date.DayNumber); }
public override string ToString() { return($"Event name: {Name}; Price: {Price}; By: {Artist}; On: {Date.ToShortDateString()}; Description: {Description} "); }
public void CanConstructDateFromParts_MaxDay_31() { Date date = new Date(2000, 1, 31); Assert.Equal(730149, date.DayNumber); }
public void CanConstructDateFromParts_MaxDay_28() { Date date = new Date(2001, 2, 28); Assert.Equal(730543, date.DayNumber); }
public void CanConstructDateFromParts_Max() { Date date = new Date(9999, 12, 31); Assert.Equal(3652058, date.DayNumber); }
public void CanConstructDateFromParts_MaxDay_30() { Date date = new Date(2000, 4, 30); Assert.Equal(730239, date.DayNumber); }