本文整理了Java中com.opengamma.strata.basics.date.AdjustableDate.of()
方法的一些代码示例,展示了AdjustableDate.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AdjustableDate.of()
方法的具体详情如下:
包路径:com.opengamma.strata.basics.date.AdjustableDate
类名称:AdjustableDate
方法名:of
[英]Obtains an instance with no business day adjustment.
This creates an adjustable date from the specified date. No business day adjustment applies, thus the result of #adjusted(ReferenceData)is the specified date.
[中]获取没有工作日调整的实例。
这将从指定日期创建一个可调整的日期。不适用营业日调整,因此#调整(参考数据)的结果为指定日期。
代码示例来源:origin: OpenGamma/Strata
/**
* Obtains an instance representing an amount where the date is fixed.
*
* Whether the payment is pay or receive is determined by the sign of the specified amount.
*
* @param value the amount of the payment
* @param date the date that the payment is made
* @return the adjustable payment instance
*/
public static AdjustablePayment of(CurrencyAmount value, LocalDate date) {
return new AdjustablePayment(value, AdjustableDate.of(date));
}
代码示例来源:origin: OpenGamma/Strata
/**
* Calculates the applicable end date.
*
* The result combines the end date and the appropriate business day adjustment.
*
* @return the calculated end date
*/
public AdjustableDate calculatedEndDate() {
return AdjustableDate.of(endDate, calculatedEndDateBusinessDayAdjustment());
}
代码示例来源:origin: OpenGamma/Strata
@Override
public AdjustableDate getStartDate() {
return AdjustableDate.of(paymentPeriods.get(0).getStartDate());
}
代码示例来源:origin: OpenGamma/Strata
@Override
public AdjustableDate getEndDate() {
return AdjustableDate.of(paymentPeriods.get(paymentPeriods.size() - 1).getEndDate());
}
代码示例来源:origin: OpenGamma/Strata
public static MockSwapLeg of(
SwapLegType type,
PayReceive payReceive,
LocalDate startDate,
LocalDate endDate,
Currency currency) {
return new MockSwapLeg(type, payReceive, AdjustableDate.of(startDate), AdjustableDate.of(endDate), currency);
}
代码示例来源:origin: OpenGamma/Strata
/**
* Obtains an instance representing an amount to be paid where the date is fixed.
*
* The sign of the amount will be normalized to be negative, indicating a payment.
*
* @param value the amount of the payment
* @param date the date that the payment is made
* @return the adjustable payment instance
*/
public static AdjustablePayment ofPay(CurrencyAmount value, LocalDate date) {
return new AdjustablePayment(value.negative(), AdjustableDate.of(date));
}
代码示例来源:origin: OpenGamma/Strata
public void test_of_null() {
assertThrowsIllegalArg(() -> AdjustableDate.of(null));
assertThrowsIllegalArg(() -> AdjustableDate.of(null, BDA_FOLLOW_SAT_SUN));
assertThrowsIllegalArg(() -> AdjustableDate.of(FRI_2014_07_11, null));
assertThrowsIllegalArg(() -> AdjustableDate.of(null, null));
}
代码示例来源:origin: OpenGamma/Strata
@Test(dataProvider = "adjusted")
public void test_adjusted(LocalDate date, LocalDate expected) {
AdjustableDate test = AdjustableDate.of(date, BDA_FOLLOW_SAT_SUN);
assertEquals(test.adjusted(REF_DATA), expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_of_2args_withNoAdjustment() {
AdjustableDate test = AdjustableDate.of(FRI_2014_07_11, BDA_NONE);
assertEquals(test.getUnadjusted(), FRI_2014_07_11);
assertEquals(test.getAdjustment(), BDA_NONE);
assertEquals(test.toString(), "2014-07-11");
assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11);
}
代码示例来源:origin: OpenGamma/Strata
public void formatForCsv() {
AdjustableDate date = AdjustableDate.of(date(2016, 6, 30), BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN));
assertThat(AdjustableDateValueFormatter.INSTANCE.formatForCsv(date)).isEqualTo("2016-06-30");
}
}
代码示例来源:origin: OpenGamma/Strata
public void test_of_1arg() {
AdjustableDate test = AdjustableDate.of(FRI_2014_07_11);
assertEquals(test.getUnadjusted(), FRI_2014_07_11);
assertEquals(test.getAdjustment(), BDA_NONE);
assertEquals(test.toString(), "2014-07-11");
assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11);
}
代码示例来源:origin: OpenGamma/Strata
public void test_of_2args_withAdjustment() {
AdjustableDate test = AdjustableDate.of(FRI_2014_07_11, BDA_FOLLOW_SAT_SUN);
assertEquals(test.getUnadjusted(), FRI_2014_07_11);
assertEquals(test.getAdjustment(), BDA_FOLLOW_SAT_SUN);
assertEquals(test.toString(), "2014-07-11 adjusted by Following using calendar Sat/Sun");
assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11);
}
代码示例来源:origin: OpenGamma/Strata
public void test_getEndDate() {
SwapLeg leg1 = MockSwapLeg.of(FIXED, PAY, date(2015, 6, 29), date(2017, 6, 30), Currency.USD);
SwapLeg leg2 = MockSwapLeg.of(FIXED, RECEIVE, date(2015, 6, 30), date(2017, 6, 29), Currency.USD);
assertEquals(Swap.of(leg1).getEndDate(), AdjustableDate.of(date(2017, 6, 30)));
assertEquals(Swap.of(leg2).getEndDate(), AdjustableDate.of(date(2017, 6, 29)));
assertEquals(Swap.of(leg1, leg2).getEndDate(), AdjustableDate.of(date(2017, 6, 30)));
assertEquals(Swap.of(leg2, leg1).getEndDate(), AdjustableDate.of(date(2017, 6, 30)));
}
代码示例来源:origin: OpenGamma/Strata
static Swaption sut2() {
return Swaption.builder()
.expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 10), ADJUSTMENT))
.expiryTime(LocalTime.of(14, 0))
.expiryZone(ZoneId.of("GMT"))
.longShort(SHORT)
.swaptionSettlement(CASH_SETTLE)
.underlying(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M
.createTrade(LocalDate.of(2014, 6, 10), Tenor.TENOR_10Y, BuySell.BUY, 1d, FIXED_RATE, REF_DATA).getProduct())
.build();
}
代码示例来源:origin: OpenGamma/Strata
public void test_resolve_pay() {
BulletPayment test = BulletPayment.builder()
.payReceive(PayReceive.PAY)
.value(GBP_P1000)
.date(AdjustableDate.of(DATE_2015_06_30))
.build();
ResolvedBulletPayment expected = ResolvedBulletPayment.of(Payment.of(GBP_M1000, DATE_2015_06_30));
assertEquals(test.resolve(REF_DATA), expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_resolve_receive() {
BulletPayment test = BulletPayment.builder()
.payReceive(PayReceive.RECEIVE)
.value(GBP_P1000)
.date(AdjustableDate.of(DATE_2015_06_30))
.build();
ResolvedBulletPayment expected = ResolvedBulletPayment.of(Payment.of(GBP_P1000, DATE_2015_06_30));
assertEquals(test.resolve(REF_DATA), expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_serialization() {
BulletPayment test = BulletPayment.builder()
.payReceive(PayReceive.PAY)
.value(GBP_P1000)
.date(AdjustableDate.of(DATE_2015_06_30))
.build();
assertSerialization(test);
}
代码示例来源:origin: OpenGamma/Strata
public void test_builder_expiryAfterStart() {
assertThrowsIllegalArg(() -> Swaption.builder()
.expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 17), ADJUSTMENT))
.expiryTime(EXPIRY_TIME)
.expiryZone(ZONE)
.longShort(LONG)
.swaptionSettlement(PHYSICAL_SETTLE)
.underlying(SWAP)
.build());
}
代码示例来源:origin: OpenGamma/Strata
public void test_physicalSettlement() {
Swaption swaption = Swaption
.builder()
.expiryDate(AdjustableDate.of(MATURITY, BDA_MF))
.expiryTime(LocalTime.NOON)
.expiryZone(ZoneOffset.UTC)
.swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT)
.longShort(LONG)
.underlying(SWAP_PAY)
.build();
assertThrowsIllegalArg(() -> PRICER.impliedVolatility(swaption.resolve(REF_DATA), RATE_PROVIDER, VOLS));
}
代码示例来源:origin: OpenGamma/Strata
public void test_physicalSettlement() {
Swaption swaption = Swaption.builder()
.swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT)
.expiryDate(AdjustableDate.of(SWAPTION_EXERCISE_DATE))
.expiryTime(SWAPTION_EXPIRY_TIME)
.expiryZone(SWAPTION_EXPIRY_ZONE)
.longShort(LongShort.LONG)
.underlying(SWAP_REC)
.build();
assertThrowsIllegalArg(() -> PRICER_SWAPTION.presentValue(swaption.resolve(REF_DATA), RATE_PROVIDER, VOLS));
}