C# wrapper

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

C# wrapper

dwmcqueen
I assume someone successfully has built a C# wrapper for QuantLib
using SWIG.  I tried following a few different directions and none
seemed to work correctly.

Is there a good set of directions somewhere on how to build the
wrapper and the core dll?  In the alternative, is there a binary
posted somewhere that functions as-is?

Thanks,

Duncan McQueen


Reply | Threaded
Open this post in threaded view
|

Problem in FixedCouponBond/FloatingRateBond causing Yield() to fail.

Toyin Akin
Hi,

Basically if one were to construct a bond where the maturity date lands on a
holiday (or weekend), and the date is to be adjusted to a non-holiday
(BusinessDayConvention = Following), then the date passed to the redemption
object will be the unadjusted date (via the Bond constructor).

However the  schedule object will compute the coupons with the last coupon
having an adjusted end date which is different from that of the redemption.

If this happens, it causes the yield() calculation to fail as line #96 of
the Bond.cpp class will try to obtain a discountfactor() with the dates
(lastCouponDate, redemptionDate). However the lastCouponDate is greater than
the redemptionDate.

Also, there is a bug within the mcbarriarengine class (cpp file). I think it
should return the rebate amount instead of 0.0 (lines #140 and #213). (In
fact the rebate amount is set by the constructor, but never used within the
class.)

Toy out.




Reply | Threaded
Open this post in threaded view
|

A question concerning Bond Yield Calculation...

Toyin Akin
Hi,

Maybe my logic is flawed here but I will present what I have and hopefully
somebody can put me right.

Within the Bond Yield solver, you take the clean price add on the accured
and then solve for the yield.

However the accured calculation itself never has use of the yield value.
It's simply

Accruedyearfraction*Coupon*Notional

But by adding the accured value to the Clean price and then solving for the
yield, the accrued part is now sensitive to the yield parameter as the whole
first period (that includes the accured) will be discounted.

Hence the solved Yield will not recover the clean price (nor the dirty price
for that matter as the logic to compute the dirty price within the solver
and the logic used to compute the dirty price within the Bond class is
different...).

Toy out.




Reply | Threaded
Open this post in threaded view
|

RE: A question concerning Bond Yield Calculation...

Toyin Akin
Actually I think my logic on this may be seriously flawed...

Still looking at it...

Toy out.


>From: "Toyin Akin" <[hidden email]>
>To: [hidden email]
>Subject: [Quantlib-users] A question concerning Bond Yield Calculation...
>Date: Mon, 05 Dec 2005 04:02:00 +0000
>
>
>Hi,
>
>Maybe my logic is flawed here but I will present what I have and hopefully
>somebody can put me right.
>
>Within the Bond Yield solver, you take the clean price add on the accured
>and then solve for the yield.
>
>However the accured calculation itself never has use of the yield value.
>It's simply
>
>Accruedyearfraction*Coupon*Notional
>
>But by adding the accured value to the Clean price and then solving for the
>yield, the accrued part is now sensitive to the yield parameter as the
>whole first period (that includes the accured) will be discounted.
>
>Hence the solved Yield will not recover the clean price (nor the dirty
>price for that matter as the logic to compute the dirty price within the
>solver and the logic used to compute the dirty price within the Bond class
>is different...).
>
>Toy out.
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: Splunk Inc. Do you grep through log
>files
>for problems?  Stop!  Download the new AJAX search engine that makes
>searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
>http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>_______________________________________________
>Quantlib-users mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/quantlib-users




Reply | Threaded
Open this post in threaded view
|

RE: A question concerning Bond Yield Calculation...

Toyin Akin
Hi,

Problem sorted... I was using a different DayCounter within the YieldCurve
than that used by the bond. (YieldCurve object is passed to be Bond
constructor)

In this situation, the solved yield may not price your bond correctly as a
different DayCounter is used by the YieldCurve during the NPV bond function.

In fact the Bond's Yield solver calls it's NPV() function which will use the
YieldCurve's DayCount, but then solve for the Yield with the Bond's
dayCounter.

This really shows up when you have accural periods.
Thus make sure that you use the same DayCounter for both the YieldCurve and
the Bond Object.

Toy out.


>From: "Toyin Akin" <[hidden email]>
>To: [hidden email]
>Subject: RE: [Quantlib-users] A question concerning Bond Yield
>Calculation...
>Date: Mon, 05 Dec 2005 05:35:51 +0000
>
>
>Actually I think my logic on this may be seriously flawed...
>
>Still looking at it...
>
>Toy out.
>
>
>>From: "Toyin Akin" <[hidden email]>
>>To: [hidden email]
>>Subject: [Quantlib-users] A question concerning Bond Yield Calculation...
>>Date: Mon, 05 Dec 2005 04:02:00 +0000
>>
>>
>>Hi,
>>
>>Maybe my logic is flawed here but I will present what I have and hopefully
>>somebody can put me right.
>>
>>Within the Bond Yield solver, you take the clean price add on the accured
>>and then solve for the yield.
>>
>>However the accured calculation itself never has use of the yield value.
>>It's simply
>>
>>Accruedyearfraction*Coupon*Notional
>>
>>But by adding the accured value to the Clean price and then solving for
>>the yield, the accrued part is now sensitive to the yield parameter as the
>>whole first period (that includes the accured) will be discounted.
>>
>>Hence the solved Yield will not recover the clean price (nor the dirty
>>price for that matter as the logic to compute the dirty price within the
>>solver and the logic used to compute the dirty price within the Bond class
>>is different...).
>>
>>Toy out.
>>
>>
>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: Splunk Inc. Do you grep through log
>>files
>>for problems?  Stop!  Download the new AJAX search engine that makes
>>searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
>>http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>>_______________________________________________
>>Quantlib-users mailing list
>>[hidden email]
>>https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: Splunk Inc. Do you grep through log
>files
>for problems?  Stop!  Download the new AJAX search engine that makes
>searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
>http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>_______________________________________________
>Quantlib-users mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/quantlib-users




Reply | Threaded
Open this post in threaded view
|

Re: C# wrapper

Luigi Ballabio
In reply to this post by dwmcqueen
On 12/03/2005 05:32:43 AM, Duncan McQueen wrote:
> I assume someone successfully has built a C# wrapper for QuantLib
> using SWIG.  I tried following a few different directions and none
> seemed to work correctly.

I assume you downloaded the 0.3.11 QuantLib-SWIG package. In its CSharp  
subdirectory, there's a QuantLib.sln solution file for VC.NET which  
should just work by choosing "Build solution" from the IDE. What kind  
of errors do you get if you do so? Or maybe you're on a different  
platform?

Later,
        Luigi

----------------------------------------

Vin: It's like this fellow I knew in El Paso. One day, he just took
all his clothes off and jumped in a mess of cactus. I asked him that
same question, "Why?"
Calvera: And?
Vin: He said, "It seemed like a good idea at the time."
-- The Magnificent Seven



Reply | Threaded
Open this post in threaded view
|

Re: Problem in FixedCouponBond/FloatingRateBond causing Yield() to fail.

Luigi Ballabio
In reply to this post by Toyin Akin
On 12/04/2005 05:41:05 PM, Toyin Akin wrote:
> Basically if one were to construct a bond where the maturity date
> lands on a holiday (or weekend), and the date is to be adjusted to a  
> non-holiday (BusinessDayConvention = Following), then the date passed  
> to the redemption object will be the unadjusted date (via the Bond  
> constructor).

Right. I'll fix it shortly.

> Also, there is a bug within the mcbarriarengine class (cpp file). I
> think it should return the rebate amount instead of 0.0 (lines #140  
> and #213). (In fact the rebate amount is set by the constructor, but  
> never used within the class.)

Hmm. I'll have to look into it.

Thanks,
        Luigi

----------------------------------------

feature, n:
        A surprising property of a program.  Occasionally documented.
        To call a property a feature sometimes means the author did not
        consider that case, and the program makes an unexpected, though
        not necessarily wrong response.  See BUG.  "That's not a bug,
        it's a feature!"  A bug can be changed to a feature by
        documenting it.



Reply | Threaded
Open this post in threaded view
|

Re: C# wrapper

dwmcqueen
In reply to this post by Luigi Ballabio
I was using Visual C++ .Net Express Edition to try and compile it and
did get errors - I will post those soon.

However, is there a way to compile it using SWIG on Windows using Mingw?

On 12/6/05, Luigi Ballabio <[hidden email]> wrote:

>
> On 12/03/2005 05:32:43 AM, Duncan McQueen wrote:
> > I assume someone successfully has built a C# wrapper for QuantLib
> > using SWIG.  I tried following a few different directions and none
> > seemed to work correctly.
>
> I assume you downloaded the 0.3.11 QuantLib-SWIG package. In its CSharp
> subdirectory, there's a QuantLib.sln solution file for VC.NET which
> should just work by choosing "Build solution" from the IDE. What kind
> of errors do you get if you do so? Or maybe you're on a different
> platform?
>
> Later,
>         Luigi
>
> ----------------------------------------
>
> Vin: It's like this fellow I knew in El Paso. One day, he just took
> all his clothes off and jumped in a mess of cactus. I asked him that
> same question, "Why?"
> Calvera: And?
> Vin: He said, "It seemed like a good idea at the time."
> -- The Magnificent Seven
>
>


Reply | Threaded
Open this post in threaded view
|

Re: C# wrapper

dwmcqueen
The error was related to finding the mt-sgd lib from QuantLib.  I
think the newer Visual C++ gave me this warning when migrating the
project:

The single-threaded run-time library switches (/MLd, /ML) have been
removed from the C++ compiler. The project has been automatically
converted to use the corresponding multi-threaded run-time library
switches (/MTd, /MT).

Not sure if this is realted, but I renamed the library created (I
selected the SingleThreaded setting for the compile) to what the
wrapper was looking for, and everything compiled fine.  I ran the test
and everything seemed to work.

On 12/6/05, Duncan McQueen <[hidden email]> wrote:

> I was using Visual C++ .Net Express Edition to try and compile it and
> did get errors - I will post those soon.
>
> However, is there a way to compile it using SWIG on Windows using Mingw?
>
> On 12/6/05, Luigi Ballabio <[hidden email]> wrote:
> >
> > On 12/03/2005 05:32:43 AM, Duncan McQueen wrote:
> > > I assume someone successfully has built a C# wrapper for QuantLib
> > > using SWIG.  I tried following a few different directions and none
> > > seemed to work correctly.
> >
> > I assume you downloaded the 0.3.11 QuantLib-SWIG package. In its CSharp
> > subdirectory, there's a QuantLib.sln solution file for VC.NET which
> > should just work by choosing "Build solution" from the IDE. What kind
> > of errors do you get if you do so? Or maybe you're on a different
> > platform?
> >
> > Later,
> >         Luigi
> >
> > ----------------------------------------
> >
> > Vin: It's like this fellow I knew in El Paso. One day, he just took
> > all his clothes off and jumped in a mess of cactus. I asked him that
> > same question, "Why?"
> > Calvera: And?
> > Vin: He said, "It seemed like a good idea at the time."
> > -- The Magnificent Seven
> >
> >
>


Reply | Threaded
Open this post in threaded view
|

Re: Problem in FixedCouponBond/FloatingRateBond causing Yield() to fail.

Luigi Ballabio
In reply to this post by Toyin Akin
On 12/04/2005 05:41:05 PM, Toyin Akin wrote:

> Also, there is a bug within the mcbarriarengine class (cpp file). I
> think it should return the rebate amount instead of 0.0

Right. It is fixed now.

Thanks,
        Luigi


----------------------------------------

Everything can be filed under "miscellaneous".
-- unknown