|
From: Luigi B. <lui...@gm...> - 2023-10-20 13:34:59
|
Hi Brian,
may you post an example we can run? Lots of undefined variables in the
code you posted (Calendar, DayCounter, SettlementDate...)
Anyway, what I would do is look at the types of the parameters you're
passing (as in, calling type(...) on them) and check if they match the
prototypes that the wrappers are showing in the error message.
Luigi
On Fri, Oct 20, 2023 at 3:10 PM Brian Smith <bri...@gm...>
wrote:
> Hi Trent,
>
> While it will be definitely interesting to try with MakeSwap, but it
> would be insightful to understand why my earlier implementation with
> VanillaSwap is failing. Any help to resolve error with VanillaSwap is
> very appreciated.
>
> Thanks and regards,
>
> On Thu, 19 Oct 2023 at 22:31, Trent Maetzold <tr...@ma...> wrote:
> >
> > Sorry, on mobile. There’s a function MakeSwap that makes it easier to
> construct a swap. You don’t need to worry about as many params and there’s
> better type hinting available. Can you try that instead of using the class
> directly?
> >
> > Sent from Proton Mail for iOS
> >
> >
> > On Thu, Oct 19, 2023 at 11:57, Brian Smith <bri...@gm...>
> wrote:
> >
> > I used
> >
> > ql.VanillaSwap(
> > ql.Swap.Payer,
> > 1000000.0,
> > ql.Schedule(
> > SettlementDate,
> > SettlementDate + ql.Period(5, ql.Years),
> > ql.Period(ql.Annual),
> > Calendar,
> > ql.Unadjusted,
> > ql.Unadjusted,
> > ql.DateGeneration.Forward,
> > False
> > ),
> > 0.007,
> > ql.Thirty360(ql.Thirty360.European),
> > ql.Schedule(
> > SettlementDate,
> > SettlementDate + ql.Period(5, ql.Years),
> > ql.Period(ql.Semiannual),
> > Calendar,
> > ql.ModifiedFollowing,
> > ql.ModifiedFollowing,
> > ql.DateGeneration.Forward,
> > False
> > ),
> > ForecastingTermStructure,
> > 0.0,
> > ql.Actual360()
> > )
> >
> > But still getting error which reads as
> >
> > Traceback (most recent call last):
> >
> > File "<stdin>", line 1, in <module>
> >
> > File "/usr/local/lib/python3.11/site-packages/QuantLib/QuantLib.py",
> > line 21252, in __init__
> >
> > _QuantLib.VanillaSwap_swiginit(self, _QuantLib.new_VanillaSwap(*args))
> >
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > TypeError: Wrong number or type of arguments for overloaded function
> > 'new_VanillaSwap'.
> >
> > Possible C/C++ prototypes are:
> >
> > VanillaSwap::VanillaSwap(Swap::Type,Real,Schedule const
> > &,Rate,DayCounter const &,Schedule const &,ext::shared_ptr< IborIndex
> > > const &,Spread,DayCounter const &,ext::optional< bool >)
> >
> > VanillaSwap::VanillaSwap(Swap::Type,Real,Schedule const
> > &,Rate,DayCounter const &,Schedule const &,ext::shared_ptr< IborIndex
> > > const &,Spread,DayCounter const &)
> >
> > On Thu, 19 Oct 2023 at 22:18, David Duarte <nh...@gm...> wrote:
> > >
> > > It seems you are providing a YieldTermStructureHandle to a
> YieldTermStructureHandle here:
> ql.YieldTermStructureHandle(ForecastingTermStructure),
> > >
> > > In your swap constructor, you can use ForecastingTermStructure
> directly because it's already a YieldTermStructureHandle.
> > >
> > >
> > >
> > > On Thu, 19 Oct 2023 at 16:04, Brian Smith <bri...@gm...>
> wrote:
> > >>
> > >> Hi,
> > >>
> > >> I tried to create Swap contract unsuccessfully as below
> > >>
> > >> import QuantLib as ql
> > >>
> > >> Euribor6MInstruments = [
> > >> ql.DepositRateHelper(
> > >> ql.QuoteHandle(ql.SimpleQuote(0.00312)),
> > >> ql.Period(6, ql.Months),
> > >> 3,
> > >> Calendar,
> > >> ql.Following,
> > >> False,
> > >> DepositDayCounter
> > >> )
> > >> ]
> > >> Euribor6MTermStructure = ql.PiecewiseLogCubicDiscount(SettlementDate,
> > >> Euribor6MInstruments, TermStructureDayCounter)
> > >> ForecastingTermStructure = ql.RelinkableYieldTermStructureHandle()
> > >> ForecastingTermStructure.linkTo(Euribor6MTermStructure)
> > >>
> > >> ql.VanillaSwap(
> > >> ql.Swap.Payer,
> > >> 1000000.0,
> > >> ql.Schedule(
> > >> SettlementDate,
> > >> SettlementDate + ql.Period(5, ql.Years),
> > >> ql.Period(ql.Annual),
> > >> Calendar,
> > >> ql.Unadjusted,
> > >> ql.Unadjusted,
> > >> ql.DateGeneration.Forward,
> > >> False
> > >> ),
> > >> 0.007,
> > >> ql.Thirty360(ql.Thirty360.European),
> > >> ql.Schedule(
> > >> SettlementDate,
> > >> SettlementDate + ql.Period(5, ql.Years),
> > >> ql.Period(ql.Semiannual),
> > >> Calendar,
> > >> ql.ModifiedFollowing,
> > >> ql.ModifiedFollowing,
> > >> ql.DateGeneration.Forward,
> > >> False
> > >> ),
> > >> ql.YieldTermStructureHandle(ForecastingTermStructure),
> > >> 0.0,
> > >> ql.Actual360()
> > >> )
> > >>
> > >> With above I got below error
> > >>
> > >> Traceback (most recent call last):
> > >>
> > >> File "<stdin>", line 26, in <module>
> > >>
> > >> File "/usr/local/lib/python3.11/site-packages/QuantLib/QuantLib.py",
> > >> line 8609, in __init__
> > >>
> > >> _QuantLib.YieldTermStructureHandle_swiginit(self,
> > >> _QuantLib.new_YieldTermStructureHandle(*args))
> > >>
> > >>
> > >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >>
> > >> TypeError: Wrong number or type of arguments for overloaded function
> > >> 'new_YieldTermStructureHandle'.
> > >>
> > >> Possible C/C++ prototypes are:
> > >>
> > >> Handle< YieldTermStructure >::Handle(ext::shared_ptr<
> > >> YieldTermStructure > const &)
> > >>
> > >> Handle< YieldTermStructure >::Handle()
> > >>
> > >> Any help on how to resolve above error is very appreciated.
> > >>
> > >>
> > >> _______________________________________________
> > >> QuantLib-users mailing list
> > >> Qua...@li...
> > >> https://lists.sourceforge.net/lists/listinfo/quantlib-users
> >
> >
> > _______________________________________________
> > QuantLib-users mailing list
> > Qua...@li...
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|