|
From: Banerjee, T. K <tap...@jp...> - 2019-08-20 13:20:28
|
Hello Luigi, experts,
I am trying to use QantlibSWIGJava for Bond valuation.
I wrote a simple program as under. But when I run I am getting below error.
2019-08-19 15:10:14,294 INFO MONETA_PERF:37 [http-nio-8080-exec-1] - EVENT=[WEB] TIME=[2376]
2019-08-19 15:10:14,303 ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]:182 [http-nio-8080-exec-1] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: null pricing engine] with root cause
java.lang.RuntimeException: null pricing engine
at org.quantlib.QuantLibJNI.Bond_cleanPrice__SWIG_0(Native Method)
at org.quantlib.Bond.cleanPrice(Bond.java:131)
Any idea what I am doing wrong.?
Another Q: How do I make same program run both Unix as well as Window env?
Do I load BOTH dll & so file under
System.loadLibrary("QuantLibJNI");
Thanks,
----
Date todaysDate = new org.quantlib.Date(9, Month.August, 2015);
Settings.instance().setEvaluationDate(todaysDate);
org.quantlib.Calendar calendar = new org.quantlib.UnitedStates();
// Bonda parameter
Date issueDate = new Date(2, Month.October, 2014);
int settlementDays = 2;
BusinessDayConvention paymentConvention = BusinessDayConvention.Following;
BusinessDayConvention accrualConvention = BusinessDayConvention.Unadjusted;
double faceAmount = 100;
double redemption = 100;
Date maturityDate = new Date(2, Month.October, 2016);
DayCounter dayCounter = new Actual365Fixed();
Frequency frequency = Frequency.Annual;
double coupon = .05;
//make schedules via constructor
Schedule schedule = new Schedule(issueDate, maturityDate, new Period(1, TimeUnit.Years), calendar, accrualConvention, accrualConvention, DateGeneration.Rule.Backward, false);
DoubleVector coupons = new DoubleVector();
coupons.add(coupon);
FixedRateBond couponBond = new FixedRateBond(settlementDays, faceAmount, schedule, coupons,
dayCounter, paymentConvention, redemption, issueDate, calendar);
double acrInterest = couponBond.accruedAmount();
System.out.println("Acrued Interest: " + acrInterest + ", Clean Price:" + couponBond.cleanPrice());
return acrInterest;
This message is confidential and subject to terms at: https://www.jpmorgan.com/emaildisclaimer including on confidential, privileged or legal entity information, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited.
|