Login  Register

Re: Cash flow schedule from Vanilla Swap

Posted by Luigi Ballabio on Sep 19, 2014; 3:17pm
URL: http://quantlib.414.s1.nabble.com/Cash-flow-schedule-from-Vanilla-Swap-tp8425p15882.html

As I said, nominals and rates must be two Python lists.

Luigi

On Fri, Sep 19, 2014 at 5:05 PM, KK <[hidden email]> wrote:

> Hi Luigi
>
> Thanks for the quick reply. I still get an error:
>
>     nominal = 1000000
>
>     maturity = Date(swap_date.day,swap_date.month,swap_date.year)
>     payFixed = True
>
>
>
>
>     fixedRate = 0.04
>
>     floatingLegFrequency = Semiannual
>     spread = 0.0
>     fixingDays = 0
>     index = GBPLibor(floatingLegTenor,forecastTermStructure)
>     floatingLegAdjustment = ModifiedFollowing
>     floatingLegDayCounter = index.dayCounter()
>
>     fixedSchedule = Schedule(settlementDate, maturity,
>                              fixedLegTenor, calendar,
>                              fixedLegAdjustment, fixedLegAdjustment,
>                              DateGeneration.Forward, False)
>     floatingSchedule = Schedule(settlementDate, maturity,
>                                 floatingLegTenor, calendar,
>                                 floatingLegAdjustment,
> floatingLegAdjustment,
>                                 DateGeneration.Forward, False)
>
>
>     spot = VanillaSwap(VanillaSwap.Payer, nominal,
>                        fixedSchedule, fixedRate, fixedLegDayCounter,
>                        floatingSchedule, index, spread,
>                        floatingLegDayCounter)
>     spot.setPricingEngine(swapEngine)
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominal, fixedRate)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominal, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominal, fixedRate)
> TypeError: in method 'FixedRateLeg', argument 3 of type 'std::vector<
> Real,std::allocator< Real > > const &'
>
> I assume that the last argument i pass is incorrect. Any idea what it should
> be?
>
> Thanks
>
>
>
> On Fri, Sep 19, 2014 at 10:56 AM, Luigi Ballabio [via QuantLib] <[hidden
> email]> wrote:
>>
>> That code is just building a schedule (i.e., a sequence of dates), not
>> a sequence of cash flows. You're not passing any rates or day-count
>> convention, for example.
>>
>> >From Python, you can use the FixedRateLeg function to create the
>> cashflows. Given the schedule you've created, you can call it as
>>
>> cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>>
>> for c in cfs:
>>     print c.date(), c.amount()
>>
>> where nominals and rates are two Python lists.
>>
>> Luigi
>>
>>
>>
>> On Thu, Sep 18, 2014 at 4:20 AM, KK <[hidden email]> wrote:
>>
>> >
>> > Is there a way to get this vector of cashflows in Python QL?
>> >
>> > fixedSchedule = Schedule(settlementDate, maturity,
>> >                              fixedLegTenor, calendar,
>> >                              fixedLegAdjustment, fixedLegAdjustment,
>> >                              DateGeneration.Forward, False)
>> >
>> > print [x for x in fixedSchedule]
>> >
>> > will return the dates, but without the cashflows.
>> >
>> > Thanks
>> >
>> > KK
>> > Luigi Ballabio wrote
>> >> On Wed, 2010-09-29 at 18:55 +0200,
>> >
>> >> tarpanelli@
>> >
>> >>  wrote:
>> >>> Hello,
>> >>> I have created a Vanilla Swap [...]as follow
>> >>>
>> >>> boost::shared_ptr
>> >> <VanillaSwap>
>> >>  swap_ptr(new VanillaSwap(swap_type,principal,
>> >>> swaption_FixedSch,strike,swap_FixedLegDc,swaption_FloatingSch,
>> >>> swaption_FloatingLegIndex,0.0,swaption_FloatLegDc));
>> >>>
>> >>> How can I show the cash flows for each one of the leg?
>> >>
>> >> swap_ptr->fixedLeg() and swap_ptr->floatingLeg() will give you two
>> >> vectors of CashFlow instances.
>> >>
>> >> Luigi
>> >>
>> >>
>> >> --
>> >>
>> >> The First Rule of Optimization: Don't do it.
>> >> The Second Rule of Optimization (For experts only): Don't do it yet.
>> >> -- Michael Jackson
>> >>
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> Virtualization is moving to the mainstream and overtaking
>> >> non-virtualized
>> >> environment for deploying applications. Does it make network security
>> >> easier or more difficult to achieve? Read this whitepaper to separate
>> >> the
>> >> two and get a better understanding.
>> >> http://p.sf.net/sfu/hp-phase2-d2d
>> >> _______________________________________________
>> >> QuantLib-users mailing list
>> >
>> >> QuantLib-users@.sourceforge
>> >
>> >> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>> >
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> > http://quantlib.10058.n7.nabble.com/Cash-flow-schedule-from-Vanilla-Swap-tp8425p15873.html
>> > Sent from the quantlib-users mailing list archive at Nabble.com.
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Want excitement?
>> > Manually upgrade your production database.
>> > When you want reliability, choose Perforce
>> > Perforce version control. Predictably reliable.
>> >
>> > http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
>> > _______________________________________________
>> > QuantLib-users mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>>
>>
>> ------------------------------------------------------------------------------
>> Slashdot TV.  Video for Nerds.  Stuff that Matters.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://quantlib.10058.n7.nabble.com/Cash-flow-schedule-from-Vanilla-Swap-tp8425p15879.html
>> To unsubscribe from Cash flow schedule from Vanilla Swap, click here.
>> NAML
>
>
>
> ________________________________
> View this message in context: Re: Cash flow schedule from Vanilla Swap
>
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Slashdot TV.  Video for Nerds.  Stuff that Matters.
> http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Slashdot TV.  Video for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users