本文整理汇总了C#中Date类的典型用法代码示例。如果您正苦于以下问题:C# Date类的具体用法?C# Date怎么用?C# Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Date类属于命名空间,在下文中一共展示了Date类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FixedRateCoupon
// 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);
}
开发者ID:jrviala,项目名称:qlnet,代码行数:8,代码来源:FixedRateCoupon.cs
示例2: CanAddZeroYears
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);
}
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs
示例3: CanAddPositiveYears_FromLeapDay_ToLeapYear
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);
}
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs
示例4: FixedRateBond
//! 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");
}
开发者ID:akasolace,项目名称:qlnet,代码行数:41,代码来源:Fixedratebond.cs
示例5: CanAddPositiveYears
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);
}
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs
示例6: AmericanExercise
public AmericanExercise(Date latest, bool payoffAtExpiry)
: base(Type.American, payoffAtExpiry)
{
dates_ = new InitializedList<Date>(2);
dates_[0] = Date.minDate();
dates_[1] = latest;
}
开发者ID:ammachado,项目名称:QLNet,代码行数:7,代码来源:Exercise.cs
示例7: SwaptionVolatilityDiscrete
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);
}
开发者ID:akasolace,项目名称:qlnet,代码行数:31,代码来源:swaptionvoldiscrete.cs
示例8: isBusinessDay
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;
}
开发者ID:Yenyenx,项目名称:qlnet,代码行数:32,代码来源:norway.cs
示例9: testAmortizingBond1
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");
}
开发者ID:akasolace,项目名称:qlnet,代码行数:27,代码来源:T_Bonds.cs
示例10: FloatingRateBond
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);
}
开发者ID:akasolace,项目名称:qlnet,代码行数:25,代码来源:FloatingRateBond.cs
示例11: CommonVars
// todo
// cleanup
// SavedSettings backup;
// setup
public CommonVars()
{
calendar = new TARGET();
today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
faceAmount = 1000000.0;
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:12,代码来源:T_Bonds.cs
示例12: dates
//! \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);
}
}
开发者ID:minikie,项目名称:test,代码行数:38,代码来源:CPIVolatilitySurface.cs
示例13: WriteRawValueWritesDate
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");
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:RawValueWriterTests.cs
示例14: CalculateDifference_ShouldNotChangePeriod
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));
}
开发者ID:Marceli,项目名称:Date-Calculator,代码行数:7,代码来源:PeriodTest.cs
示例15: CallableBondConstantVolatility
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);
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:7,代码来源:CallableBondConstantVolatility.cs
示例16: date
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;
}
开发者ID:akasolace,项目名称:qlnet,代码行数:26,代码来源:Imm.cs
示例17: BlackVanillaOptionPricer
public BlackVanillaOptionPricer(double forwardValue, Date expiryDate, Period swapTenor, SwaptionVolatilityStructure volatilityStructure) {
forwardValue_ = forwardValue;
expiryDate_ = expiryDate;
swapTenor_ = swapTenor;
volatilityStructure_ = volatilityStructure;
smile_ = volatilityStructure_.smileSection(expiryDate_, swapTenor_);
}
开发者ID:minikie,项目名称:test,代码行数:7,代码来源:ConundrumPricer.cs
示例18: CreateDate
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");
}
开发者ID:QTruffart,项目名称:OsteoYoga,代码行数:31,代码来源:RendezVousController.cs
示例19: getCPR
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;
}
开发者ID:Yenyenx,项目名称:qlnet,代码行数:7,代码来源:PSACurve.cs
示例20: isBusinessDay
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;
}
开发者ID:tickzoom,项目名称:QLNet,代码行数:31,代码来源:denmark.cs
注:本文中的Date类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论