Hi,
I am trying to understand how to price Asian arithmetic average strike options. There is an example in the testsuite, but the fact that the payoff is a PlainVanillaPayoff, which requires a strike price as its second argument, irritates me. After all, in an average strike option I don't know the strike a priori. Anyone who can shed some light on this? Paul ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Thu, May 17, 2012 at 11:21 PM, Paul Carter <[hidden email]> wrote:
> I am trying to understand how to price Asian arithmetic average strike > options. There is an example in the testsuite, but the fact that the payoff > is a PlainVanillaPayoff, which requires a strike price as its second > argument, irritates me. After all, in an average strike option I don't know > the strike a priori. Anyone who can shed some light on this? Hi Paul, the passed strike is ignored. The PlainVanillaPayoff is a square peg that was made to fit in a round hole. If that's any consolation, it irritates me, too. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
Thanks for the quick and helpful reply. In a next step, I would actually like to feed a time dependent (deterministic) volatility into the MC engine. However, I am not quite sure where to start looking... There doesn't seem to be much documentation around this. At the moment I'm doing this: Handle<BlackVolTermStructure> flatVolTermStructure( boost::shared_ptr<BlackVolTermStructure>( new BlackConstantVol( evalDate, calendar, volatility, dayCounter ))); So basically I'm looking to replace BlackConstantVol by something where volatility isn't a simple double as above, but a function pointer (well, I presume the actual implementation in QuantLib is more clever than this). Another thing I was wondering about are the greeks. Currently, these aren't implemented for the MC Asian engines, but I would have thought that somewhere relatively far up the instrument class hierarchy, there should be a method that allows one to numerically approximate the greeks but simply bumping the relevant arguments (e.g. price of underlying for delta, volatility for vega, etc) and calculating the resulting slope of the change in value of the instrument. Any thoughts on this? Regards, Paul On Fri, May 18, 2012 at 10:53 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi,
Any idea what's
wrong, "empty Handle cannot be dereferenced"?
I googled and this
is quite a common error message in QuantLib
Billy
Ng
Exception in
thread "main" java.lang.RuntimeException: empty Handle cannot be
dereferenced
at org.quantlib.QuantLibJNI.Instrument_NPV(Native Method) at org.quantlib.Instrument.NPV(Instrument.java:56) at examples.CPIBonds.main(CPIBonds.java:297) ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Paul Carter-5
On Fri, May 18, 2012 at 11:41 PM, Paul Carter <[hidden email]> wrote:
> Thanks for the quick and helpful reply. In a next step, I would actually > like to feed a time dependent (deterministic) volatility into the MC engine. > However, I am not quite sure where to start looking... There doesn't seem to > be much documentation around this. At the moment I'm doing this: > > Handle<BlackVolTermStructure> flatVolTermStructure( > boost::shared_ptr<BlackVolTermStructure>( new BlackConstantVol( evalDate, > calendar, volatility, dayCounter ))); > > So basically I'm looking to replace BlackConstantVol by something where > volatility isn't a simple double as above, but a function pointer (well, I > presume the actual implementation in QuantLib is more clever than this). You can try using BlackVarianceCurve instead of BlackConstantVol. It allows you to interpolate a number of at-the-money volatilities for different maturities. > Another thing I was wondering about are the greeks. Currently, these aren't > implemented for the MC Asian engines, but I would have thought that > somewhere relatively far up the instrument class hierarchy, there should be > a method that allows one to numerically approximate the greeks but simply > bumping the relevant arguments (e.g. price of underlying for delta, > volatility for vega, etc) and calculating the resulting slope of the change > in value of the instrument. Any thoughts on this? You can bump the quotes you used to build the instrument and the curves, and the price of the instrument will vary accordingly. You can look at test-suite/asianoptions.cpp and see how it's done in the test*Greeks() test cases (it's the part that calculates the expected numerical Greeks and stores them into the "expected" map). It will work for MC engines, too. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Billy Ng-5
On Sun, May 20, 2012 at 2:01 AM, Billy Ng <[hidden email]> wrote:
> Any idea what's wrong, "empty Handle cannot be dereferenced"? > I googled and this is quite a common error message in QuantLib You passed a Handle to an instrument (possibly a Handle to a curve, or to a quote) and tried to calculate the NPV before linking the handle to an actual curve/quote. Can you send the code that causes the error? Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Attached is the Java code.
Another question in Debugging SWIG-Java under JNI I build both the Release and Debug QuantLib.lib QuantLibJNI.lib and dll for the Java JNI, then run the code in debug mode under Eclipse It seems like the Debug Build make not much help in debugging. Is there any setup issue/Plugin to debug even under the Native Mode under Eclipse? Billy Ng -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Monday, May 21, 2012 5:41 PM To: Billy Ng Cc: [hidden email] Subject: Re: [Quantlib-users] Asian arithmetic average strike option On Sun, May 20, 2012 at 2:01 AM, Billy Ng <[hidden email]> wrote: > Any idea what's wrong, "empty Handle cannot be dereferenced"? > I googled and this is quite a common error message in QuantLib You passed a Handle to an instrument (possibly a Handle to a curve, or to a quote) and tried to calculate the NPV before linking the handle to an actual curve/quote. Can you send the code that causes the error? Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users CPIBonds.java (13K) Download Attachment |
On Mon, May 21, 2012 at 12:43 PM, Billy Ng <[hidden email]> wrote:
> Attached is the Java code. I can't run it since I don't have your Java wrappers, but it seems to me that you never link a curve to the hcpi handle. > Another question in Debugging SWIG-Java under JNI > I build both the Release and Debug QuantLib.lib QuantLibJNI.lib and dll for the Java JNI, then run the code in debug mode under Eclipse > It seems like the Debug Build make not much help in debugging. > Is there any setup issue/Plugin to debug even under the Native Mode under Eclipse? No idea about this, sorry. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
The C++ Code runs though. But I think it uses TermStructure.recalculate() to trigger the boostrapping? Billy Ng -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Monday, May 21, 2012 6:53 PM To: Billy Ng Cc: [hidden email] Subject: Re: ERROR: empty Handle cannot be dereferenced On Mon, May 21, 2012 at 12:43 PM, Billy Ng <[hidden email]> wrote: > Attached is the Java code. I can't run it since I don't have your Java wrappers, but it seems to me that you never link a curve to the hcpi handle. > Another question in Debugging SWIG-Java under JNI > I build both the Release and Debug QuantLib.lib QuantLibJNI.lib and dll for the Java JNI, then run the code in debug mode under Eclipse > It seems like the Debug Build make not much help in debugging. > Is there any setup issue/Plugin to debug even under the Native Mode under Eclipse? No idea about this, sorry. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
The C++ Code runs though. But I think it uses TermStructure.recalculate() to trigger the boostrapping? Billy Ng -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Monday, May 21, 2012 6:53 PM To: Billy Ng Cc: [hidden email] Subject: Re: ERROR: empty Handle cannot be dereferenced On Mon, May 21, 2012 at 12:43 PM, Billy Ng <[hidden email]> wrote: > Attached is the Java code. I can't run it since I don't have your Java wrappers, but it seems to me that you never link a curve to the hcpi handle. > Another question in Debugging SWIG-Java under JNI > I build both the Release and Debug QuantLib.lib QuantLibJNI.lib and dll for the Java JNI, then run the code in debug mode under Eclipse > It seems like the Debug Build make not much help in debugging. > Is there any setup issue/Plugin to debug even under the Native Mode under Eclipse? No idea about this, sorry. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Billy Ng-6
On Mon, May 21, 2012 at 12:58 PM, Billy Ng <[hidden email]> wrote:
> > The C++ Code runs though. There might be some difference you overlooked. You pass hcpi to ii, and later assign ii to fixedIndex and pass it to the instrument. Does the C++ do the same? ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
You are correct. I overlooked.
Now it works for NPV calculation, but not yield, dirtyPrice and cleanPrice? Billy Ng -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Monday, May 21, 2012 7:07 PM To: Billy Ng Cc: [hidden email] Subject: Re: [Quantlib-users] ERROR: empty Handle cannot be dereferenced On Mon, May 21, 2012 at 12:58 PM, Billy Ng <[hidden email]> wrote: > > The C++ Code runs though. There might be some difference you overlooked. You pass hcpi to ii, and later assign ii to fixedIndex and pass it to the instrument. Does the C++ do the same? ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, May 21, 2012 at 1:22 PM, Billy Ng <[hidden email]> wrote:
> You are correct. I overlooked. > > Now it works for NPV calculation, but not yield, dirtyPrice and cleanPrice? They don't work on 1.2 (see <http://old.nabble.com/Re%3A-CPIbond-to33636345.html>). The code is fixed in Subversion in the "R01020x-branch" branch. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
You have a good memory. I tried to fix that bug weeks ago and that is why my C++ version works fine. Many Thanks Billy Ng -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Monday, May 21, 2012 10:23 PM To: Billy Ng Cc: Billy Ng; [hidden email] Subject: Re: [Quantlib-users] ERROR: empty Handle cannot be dereferenced On Mon, May 21, 2012 at 1:22 PM, Billy Ng <[hidden email]> wrote: > You are correct. I overlooked. > > Now it works for NPV calculation, but not yield, dirtyPrice and cleanPrice? They don't work on 1.2 (see <http://old.nabble.com/Re%3A-CPIbond-to33636345.html>). The code is fixed in Subversion in the "R01020x-branch" branch. Luigi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Luigi Ballabio
On Mon, May 21, 2012 at 11:38 AM, Luigi Ballabio <[hidden email]> wrote:
Great, that worked fine. However, as BlackScholesMertonProcess (and indeed any other Black-Scholes type process defined by QuantLib) picks up the volatility in its drift term, I am now trying to cancel out the volatility as I would like to have no drift at all. This requires me to define a yield term structure, which seems rather less straightforward. Do you maybe know of a good, hands-on example showing how I can define myself a suitable (dividend) yield term structure (eg some code in the testsuite)?
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
It might be done, but it's not easy. How about inheriting from
BlackScholesProcess instead and overriding the drift() method so that it doesn't take volatility into account? That would be easy enough to implement. Luigi On Sun, Jun 3, 2012 at 10:40 PM, Paul Carter <[hidden email]> wrote: > However, as BlackScholesMertonProcess (and indeed any other Black-Scholes > type process defined by QuantLib) picks up the volatility in its drift term, > I am now trying to cancel out the volatility as I would like to have no > drift at all. This requires me to define a yield term structure, which seems > rather less straightforward. Do you maybe know of a good, hands-on example > showing how I can define myself a suitable (dividend) yield term structure > (eg some code in the testsuite)? ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |