I am using the FloatingRateBond
class to create a floating rate bond object, which I have already priced correctly. However, now I need to retrieve the cashflows and the dirty price to decompose the yield. I have been trying the following without any success:
Leg cf=floatingRateBond.cashflows();
Leg::iterator it;
for(it=cf.begin();it!=cf.end();++it)
cout<<"Type: "<<typeid(*it).name()<< " value:" << *it<<endl;
Output:
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14362a50
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14362c40
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14362e70
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x143630a0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x143632d0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14363500
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14363730
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14363960
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14363b90
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14363dc0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14363ff0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14364220
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14364450
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14364680
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x143648b0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14364ae0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14364d10
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14364f40
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14365170
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x143653a0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE value:0x14362660
thanks
I have. however I get the same thing. My collegue solved it by not using an iterator but just a simple for loop and then pointing to the ->amount()
I don't understand however how is this different given that quantlib is built upon STL and boost.
like so:
If it did (*it)->amount(); it would yield an error.