Cash flow schedule from Vanilla Swap

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

Cash flow schedule from Vanilla Swap

tarpanelli@libero.it
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?

Thanks in advance,
P

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

QLXL-Some of the functions of the samples return an error. Why?

Theologis Chapsalis-2
  Dear QL-community

I am using QLXL-0.9.7 and in many occasions, it works perfectly fine.
However, some functions do not run in the samples that were installed
together with the xll.

Here is such an example: In columns 6,7,9,11 (Sheet("Cubic")), I can
only see the typical Excel error msg (#VALUE!)...
Does anyone get a result?

Thank you very much for your time and effort
Theo

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

Interpolation.xls (121K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: QLXL-Some of the functions of the samples return an error. Why?

Bojan Nikolic

I think this example is stale. If you take the values to be interpolated
and transfer them to a range of cells (i.e., C5 to a range like B27:31
and C6 to C27:31) and then supply these ranges to the
qlCubinInterpolation function then everything should work fine.

I believe this change is necessary because as of March 2009 the Y array
can now be an array of Quote's but the automatic conversion from comma
delimited array does not work for this type.

Best,
Bojan

--
Bojan Nikolic          ||          http://www.bnikolic.co.uk/ql

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

Luigi Ballabio
In reply to this post by tarpanelli@libero.it
On Wed, 2010-09-29 at 18:55 +0200, [hidden email] 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QLXL-Some of the functions of the samples return an error. Why?

Eric Ehlers-2
In reply to this post by Theologis Chapsalis-2
Hi Theo,

> I am using QLXL-0.9.7 and in many occasions, it works perfectly fine.
> However, some functions do not run in the samples that were installed
> together with the xll.

The best example workbooks are YieldTermStructures.xls and  
InterestRateDerivatives.xls.  The others are less well maintained.
>
> Here is such an example: In columns 6,7,9,11 (Sheet("Cubic")), I can
> only see the typical Excel error msg (#VALUE!)...
> Does anyone get a result?

I just tried that workbook and it works fine for me.  Here are the  
steps I followed:

1) Install QuantLibXL 0.9.7 (binary release)
2) Start Excel
3) Open C:\Program Files\QuantLibXL-0.9.7\xll\QuantLibXL-vc80-mt-s-0_9_7.xll
4) Open C:\Program Files\QuantLibXL-0.9.7\Workbooks\Math\Interpolation.xls
5) Hit Ctrl-Alt-F9

At that point in sheet Cubic all of the formulas return values, no errors.

[With one exception, in range =[Interpolation.xls]Cubic!$C$4, the  
formula should be ohRangeRetrieveError() not ohRetrieveError()]

Can you repeat the steps above?  At what point do your results differ  
from mine?

I tried the same test for QuantLibXL version 1.0.1 and I get #VALUE  
but the workaround mentioned separately by Bojan fixes the problem.  
The comma delimited list of inputs is broken and a fix for this is on  
my to do list.

Thanks,
Eric


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QLXL-Some of the functions of the samples return an error. Why?

Theologis Chapsalis-2
  Hi Eric

Thank you very much for your message. Indeed it helps and now I can run
the spreadsheet "InterestRatederivatives.xls" without any problem.
However I cannot find the spreadsheet "YieldTermStructures.xls". Do you
mean "YieldCurveBottstrapping.xls"?

Also, it's great that you are strongly contributing to the updates of
QLXL ( I saw that the version 1.0.1 has been released). Congratulations!

Theo



On 06/10/2010 14:38, Eric Ehlers wrote:

> Hi Theo,
>
>> I am using QLXL-0.9.7 and in many occasions, it works perfectly fine.
>> However, some functions do not run in the samples that were installed
>> together with the xll.
>
> The best example workbooks are YieldTermStructures.xls and
> InterestRateDerivatives.xls.  The others are less well maintained.
>>
>> Here is such an example: In columns 6,7,9,11 (Sheet("Cubic")), I can
>> only see the typical Excel error msg (#VALUE!)...
>> Does anyone get a result?
>
> I just tried that workbook and it works fine for me.  Here are the
> steps I followed:
>
> 1) Install QuantLibXL 0.9.7 (binary release)
> 2) Start Excel
> 3) Open C:\Program
> Files\QuantLibXL-0.9.7\xll\QuantLibXL-vc80-mt-s-0_9_7.xll
> 4) Open C:\Program
> Files\QuantLibXL-0.9.7\Workbooks\Math\Interpolation.xls
> 5) Hit Ctrl-Alt-F9
>
> At that point in sheet Cubic all of the formulas return values, no
> errors.
>
> [With one exception, in range =[Interpolation.xls]Cubic!$C$4, the
> formula should be ohRangeRetrieveError() not ohRetrieveError()]
>
> Can you repeat the steps above?  At what point do your results differ
> from mine?
>
> I tried the same test for QuantLibXL version 1.0.1 and I get #VALUE
> but the workaround mentioned separately by Bojan fixes the problem.  
> The comma delimited list of inputs is broken and a fix for this is on
> my to do list.
>
> Thanks,
> Eric
>


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QLXL-Some of the functions of the samples return an error. Why?

Eric Ehlers-2
Hi Theo,

Quoting Theologis Chapsalis <[hidden email]>:

> Thank you very much for your message. Indeed it helps and now I can run
> the spreadsheet "InterestRatederivatives.xls" without any problem.
> However I cannot find the spreadsheet "YieldTermStructures.xls". Do you
> mean "YieldCurveBottstrapping.xls"?

I didn't write those workbooks but it seems that for 0.9.7 it's  
InterestRateDerivatives.xls and YieldCurveBootstrapping.xls, for 1.0.1  
it's those two again plus YieldTermStructures.xls.

> Also, it's great that you are strongly contributing to the updates of
> QLXL ( I saw that the version 1.0.1 has been released). Congratulations!

Thanks!

Regards,
Eric


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
KK
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

KK
In reply to this post by Luigi Ballabio

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, [hidden email] 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

Luigi Ballabio
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
KK
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

KK
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

Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

Luigi Ballabio
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
KK
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

KK
Hi Luigi

So for the fixed leg, this works!
    nominal = 1000000
    fixedRate = 0.04

    nominals =[nominal for x in fixedSchedule]
    rates =[fixedRate for x in fixedSchedule]
    
    cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates) 

    for c in cfs: 
        print c.date(), c.amount() 



Is there a way of passing the floating leg schedule of rates?         
        
    cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index) 

    for c in cfls: 
        print c.date(), c.amount() 

Thanks again!

On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
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



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-tp8425p15882.html
To unsubscribe from Cash flow schedule from Vanilla Swap, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

Luigi Ballabio
Use IborLeg to build the other leg. You can check its interface in
<QuantLib-SWIG/SWIG/cashflows.i>.

Luigi

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

> Hi Luigi
>
> So for the fixed leg, this works!
>     nominal = 1000000
>     fixedRate = 0.04
>
>     nominals =[nominal for x in fixedSchedule]
>     rates =[fixedRate for x in fixedSchedule]
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>
>
> Is there a way of passing the floating leg schedule of rates?
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
> Thanks again!
>
> On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden
> email]> wrote:
>>
>> 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
>>
>>
>> ________________________________
>> 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-tp8425p15882.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
KK
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

KK
Hi Luigi

Many thanks for helping with this:

I tried
index = GBPLibor(floatingLegTenor,forecastTermStructure)
floatingSchedule = Schedule(settlementDate, maturity,
                                floatingLegTenor, calendar,
                                floatingLegAdjustment, floatingLegAdjustment,
                                DateGeneration.Forward, False)

 fnominals =[nominal for x in floatingSchedule]   
 floatingrates = IborLeg(fnominals[:-1],floatingSchedule,index,dayCounter) 
 for c in floatingrates: 
        print c.date(),c.amount()

c.date works fine, but for c.amount() an error is returned:

c.amount()
RuntimeError: empty Handle cannot be dereferenced

Am i missing parameters in the IborLeg function?

Thanks


On Fri, Sep 19, 2014 at 11:29 AM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
Use IborLeg to build the other leg. You can check its interface in
<QuantLib-SWIG/SWIG/cashflows.i>.

Luigi

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

> Hi Luigi
>
> So for the fixed leg, this works!

>     nominal = 1000000
>     fixedRate = 0.04
>
>     nominals =[nominal for x in fixedSchedule]
>     rates =[fixedRate for x in fixedSchedule]
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>
>
> Is there a way of passing the floating leg schedule of rates?
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
> Thanks again!
>
> On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden

> email]> wrote:
>>
>> 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
>>
>>
>> ________________________________
>> 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-tp8425p15882.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



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-tp8425p15884.html
To unsubscribe from Cash flow schedule from Vanilla Swap, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

Luigi Ballabio

I'm guessing forecastTermStructure is an empty handle.

Luigi

On Sep 19, 2014 6:09 PM, "KK" <[hidden email]> wrote:
Hi Luigi

Many thanks for helping with this:

I tried
index = GBPLibor(floatingLegTenor,forecastTermStructure)
floatingSchedule = Schedule(settlementDate, maturity,
                                floatingLegTenor, calendar,
                                floatingLegAdjustment, floatingLegAdjustment,
                                DateGeneration.Forward, False)

 fnominals =[nominal for x in floatingSchedule]   
 floatingrates = IborLeg(fnominals[:-1],floatingSchedule,index,dayCounter) 
 for c in floatingrates: 
        print c.date(),c.amount()

c.date works fine, but for c.amount() an error is returned:

c.amount()
RuntimeError: empty Handle cannot be dereferenced

Am i missing parameters in the IborLeg function?

Thanks


On Fri, Sep 19, 2014 at 11:29 AM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
Use IborLeg to build the other leg. You can check its interface in
<QuantLib-SWIG/SWIG/cashflows.i>.

Luigi

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

> Hi Luigi
>
> So for the fixed leg, this works!

>     nominal = 1000000
>     fixedRate = 0.04
>
>     nominals =[nominal for x in fixedSchedule]
>     rates =[fixedRate for x in fixedSchedule]
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>
>
> Is there a way of passing the floating leg schedule of rates?
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
> Thanks again!
>
> On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden

> email]> wrote:
>>
>> 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
>>
>>
>> ________________________________
>> 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-tp8425p15882.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



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-tp8425p15884.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


------------------------------------------------------------------------------
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
KK
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

KK
Thanks again for persisting with me on this Luigi!

My code has

  discountTermStructure = RelinkableYieldTermStructureHandle()
  forecastTermStructure = RelinkableYieldTermStructureHandle()
    
  swapEngine = DiscountingSwapEngine(discountTermStructure)

and i can debug to show:

forecastTermStructure
RelinkableYieldTermStructureHandle: <QuantLib.QuantLib.RelinkableYieldTermStructureHandle; proxy of <Swig Object of type 'RelinkableHandle< YieldTermStructure > *' at 0x09C97AB8> >

I found this snippet, which create IborLegin the same way:

floatingleg=IborLeg(nominals,schedule,index,Actual360())


and doesn't refer to forecastTermStructure again in the code.

Any ideas what the fix might be?

Thanks




On Fri, Sep 19, 2014 at 12:11 PM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:

I'm guessing forecastTermStructure is an empty handle.

Luigi

On Sep 19, 2014 6:09 PM, "KK" <[hidden email]> wrote:
Hi Luigi

Many thanks for helping with this:

I tried
index = GBPLibor(floatingLegTenor,forecastTermStructure)
floatingSchedule = Schedule(settlementDate, maturity,
                                floatingLegTenor, calendar,
                                floatingLegAdjustment, floatingLegAdjustment,
                                DateGeneration.Forward, False)

 fnominals =[nominal for x in floatingSchedule]   
 floatingrates = IborLeg(fnominals[:-1],floatingSchedule,index,dayCounter) 
 for c in floatingrates: 
        print c.date(),c.amount()

c.date works fine, but for c.amount() an error is returned:

c.amount()
RuntimeError: empty Handle cannot be dereferenced

Am i missing parameters in the IborLeg function?

Thanks


On Fri, Sep 19, 2014 at 11:29 AM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
Use IborLeg to build the other leg. You can check its interface in
<QuantLib-SWIG/SWIG/cashflows.i>.

Luigi

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

> Hi Luigi
>
> So for the fixed leg, this works!

>     nominal = 1000000
>     fixedRate = 0.04
>
>     nominals =[nominal for x in fixedSchedule]
>     rates =[fixedRate for x in fixedSchedule]
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>
>
> Is there a way of passing the floating leg schedule of rates?
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
> Thanks again!
>
> On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden

> email]> wrote:
>>
>> 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
>>
>>
>> ________________________________
>> 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-tp8425p15882.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



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-tp8425p15884.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


------------------------------------------------------------------------------
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-tp8425p15886.html
To unsubscribe from Cash flow schedule from Vanilla Swap, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

Luigi Ballabio

forecastTermStructure,linkTo(curve)

where curve is whatever term structure you're using to forecast Libor fixings. Look at the swap example.

Luigi

On Sep 19, 2014 6:25 PM, "KK" <[hidden email]> wrote:
Thanks again for persisting with me on this Luigi!

My code has

  discountTermStructure = RelinkableYieldTermStructureHandle()
  forecastTermStructure = RelinkableYieldTermStructureHandle()
    
  swapEngine = DiscountingSwapEngine(discountTermStructure)

and i can debug to show:

forecastTermStructure
RelinkableYieldTermStructureHandle: <QuantLib.QuantLib.RelinkableYieldTermStructureHandle; proxy of <Swig Object of type 'RelinkableHandle< YieldTermStructure > *' at 0x09C97AB8> >

I found this snippet, which create IborLegin the same way:

floatingleg=IborLeg(nominals,schedule,index,Actual360())


and doesn't refer to forecastTermStructure again in the code.

Any ideas what the fix might be?

Thanks




On Fri, Sep 19, 2014 at 12:11 PM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:

I'm guessing forecastTermStructure is an empty handle.

Luigi

On Sep 19, 2014 6:09 PM, "KK" <[hidden email]> wrote:
Hi Luigi

Many thanks for helping with this:

I tried
index = GBPLibor(floatingLegTenor,forecastTermStructure)
floatingSchedule = Schedule(settlementDate, maturity,
                                floatingLegTenor, calendar,
                                floatingLegAdjustment, floatingLegAdjustment,
                                DateGeneration.Forward, False)

 fnominals =[nominal for x in floatingSchedule]   
 floatingrates = IborLeg(fnominals[:-1],floatingSchedule,index,dayCounter) 
 for c in floatingrates: 
        print c.date(),c.amount()

c.date works fine, but for c.amount() an error is returned:

c.amount()
RuntimeError: empty Handle cannot be dereferenced

Am i missing parameters in the IborLeg function?

Thanks


On Fri, Sep 19, 2014 at 11:29 AM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
Use IborLeg to build the other leg. You can check its interface in
<QuantLib-SWIG/SWIG/cashflows.i>.

Luigi

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

> Hi Luigi
>
> So for the fixed leg, this works!

>     nominal = 1000000
>     fixedRate = 0.04
>
>     nominals =[nominal for x in fixedSchedule]
>     rates =[fixedRate for x in fixedSchedule]
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>
>
> Is there a way of passing the floating leg schedule of rates?
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
> Thanks again!
>
> On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden

> email]> wrote:
>>
>> 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
>>
>>
>> ________________________________
>> 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-tp8425p15882.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



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-tp8425p15884.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


------------------------------------------------------------------------------
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-tp8425p15886.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


------------------------------------------------------------------------------
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
KK
Reply | Threaded
Open this post in threaded view
|

Re: Cash flow schedule from Vanilla Swap

KK
Hi Luigi

Many thanks for your help and patience with this - I finally managed to get it work by ensuring I had forecastTermStructure,linkTo(curve) in the right place!

Thanks again!

On Fri, Sep 19, 2014 at 12:47 PM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:

forecastTermStructure,linkTo(curve)

where curve is whatever term structure you're using to forecast Libor fixings. Look at the swap example.

Luigi

On Sep 19, 2014 6:25 PM, "KK" <[hidden email]> wrote:
Thanks again for persisting with me on this Luigi!

My code has

  discountTermStructure = RelinkableYieldTermStructureHandle()
  forecastTermStructure = RelinkableYieldTermStructureHandle()
    
  swapEngine = DiscountingSwapEngine(discountTermStructure)

and i can debug to show:

forecastTermStructure
RelinkableYieldTermStructureHandle: <QuantLib.QuantLib.RelinkableYieldTermStructureHandle; proxy of <Swig Object of type 'RelinkableHandle< YieldTermStructure > *' at 0x09C97AB8> >

I found this snippet, which create IborLegin the same way:

floatingleg=IborLeg(nominals,schedule,index,Actual360())


and doesn't refer to forecastTermStructure again in the code.

Any ideas what the fix might be?

Thanks




On Fri, Sep 19, 2014 at 12:11 PM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:

I'm guessing forecastTermStructure is an empty handle.

Luigi

On Sep 19, 2014 6:09 PM, "KK" <[hidden email]> wrote:
Hi Luigi

Many thanks for helping with this:

I tried
index = GBPLibor(floatingLegTenor,forecastTermStructure)
floatingSchedule = Schedule(settlementDate, maturity,
                                floatingLegTenor, calendar,
                                floatingLegAdjustment, floatingLegAdjustment,
                                DateGeneration.Forward, False)

 fnominals =[nominal for x in floatingSchedule]   
 floatingrates = IborLeg(fnominals[:-1],floatingSchedule,index,dayCounter) 
 for c in floatingrates: 
        print c.date(),c.amount()

c.date works fine, but for c.amount() an error is returned:

c.amount()
RuntimeError: empty Handle cannot be dereferenced

Am i missing parameters in the IborLeg function?

Thanks


On Fri, Sep 19, 2014 at 11:29 AM, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
Use IborLeg to build the other leg. You can check its interface in
<QuantLib-SWIG/SWIG/cashflows.i>.

Luigi

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

> Hi Luigi
>
> So for the fixed leg, this works!

>     nominal = 1000000
>     fixedRate = 0.04
>
>     nominals =[nominal for x in fixedSchedule]
>     rates =[fixedRate for x in fixedSchedule]
>
>     cfs = FixedRateLeg(fixedSchedule, dayCounter, nominals, rates)
>
>     for c in cfs:
>         print c.date(), c.amount()
>
>
>
> Is there a way of passing the floating leg schedule of rates?
>
>     cfls = FixedRateLeg(floatingSchedule, dayCounter, nominals, index)
>
>     for c in cfls:
>         print c.date(), c.amount()
>
> Thanks again!
>
> On Fri, Sep 19, 2014 at 11:17 AM, Luigi Ballabio [via QuantLib] <[hidden

> email]> wrote:
>>
>> 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
>>
>>
>> ________________________________
>> 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-tp8425p15882.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



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-tp8425p15884.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


------------------------------------------------------------------------------
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-tp8425p15886.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


------------------------------------------------------------------------------
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-tp8425p15888.html
To unsubscribe from Cash flow schedule from Vanilla Swap, click here.
NAML