|
From: Brian S. <bri...@gm...> - 2023-10-19 16:57:32
|
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
|