Hi All
Is is possible to create an OIS object OvernightIndexedSwap in python? Creating a curve is possible, but creating a swap and hence finding fairRate() or NPV() is eluding me at the moment. In the code below I have used "OvernightIndexedSwap" but this is undefined in python quantlib. Many thanks from QuantLib import * settlementDate = Date(18,9,2014); maturity = Date(18,9,2016) nominal = 1000000 fixedRate = 0.025 dayCount = Actual365Fixed() spread = 0 discountTermStructure = RelinkableYieldTermStructureHandle() forecastTermStructure = RelinkableYieldTermStructureHandle() MyOisHelper = [OISRateHelper( 0, Period(6,Months),QuoteHandle(SimpleQuote(0.02)), Sonia() ),OISRateHelper( 0, Period(3,Years),QuoteHandle(SimpleQuote(0.03)), Sonia() )] OISSwapCurve = PiecewiseFlatForward(settlementDate, MyOisHelper, dayCount) swapEngine = DiscountingSwapEngine(discountTermStructure) print OISSwapCurve.discount(Date(21,12,2013)) fixedSchedule = Schedule(settlementDate,maturity, Annual, UnitedKingdom(), ModifiedFollowing, ModifiedFollowing, DateGeneration.Forward, False) ois_swap = OvernightIndexedSwap(OvernightIndexedSwap.Payer, nominal, fixedSchedule, fixedRate, dayCount, Sonia(), spread); ois_swap.setPricingEngine(swapEngine) swapEngine = DiscountingSwapEngine(discountTermStructure) discountTermStructure.linkTo(OISSwapCurve) forecastTermStructure.linkTo(OISSwapCurve) print ois_swap.NPV(); print ois_swap.fairRate(); |
Hello,
OvernightIndexedSwap is not exported at this time. If you want to try adding it to the SWIG interfaces, you can look at the way VanillaSwap is exported and replicate it for OvernightIndexedSwap. Post here for help if you get stuck. Luigi On Sat, Sep 27, 2014 at 2:01 AM, KK <[hidden email]> wrote: > Hi All > > Is is possible to create an OIS object OvernightIndexedSwap in python? > Creating a curve is possible, but creating a swap and hence finding > fairRate() or NPV() is eluding me at the moment. > > In the code below I have used "OvernightIndexedSwap" but this is undefined > in python quantlib. > > Many thanks > > from QuantLib import * > > settlementDate = Date(18,9,2014); > maturity = Date(18,9,2016) > nominal = 1000000 > fixedRate = 0.025 > dayCount = Actual365Fixed() > spread = 0 > > discountTermStructure = RelinkableYieldTermStructureHandle() > forecastTermStructure = RelinkableYieldTermStructureHandle() > > MyOisHelper = [OISRateHelper( 0, > Period(6,Months),QuoteHandle(SimpleQuote(0.02)), Sonia() ),OISRateHelper( 0, > Period(3,Years),QuoteHandle(SimpleQuote(0.03)), Sonia() )] > > OISSwapCurve = PiecewiseFlatForward(settlementDate, MyOisHelper, dayCount) > > swapEngine = DiscountingSwapEngine(discountTermStructure) > > print OISSwapCurve.discount(Date(21,12,2013)) > > fixedSchedule = Schedule(settlementDate,maturity, Annual, UnitedKingdom(), > ModifiedFollowing, ModifiedFollowing, DateGeneration.Forward, False) > > ois_swap = *OvernightIndexedSwap(OvernightIndexedSwap.Payer*, nominal, > fixedSchedule, fixedRate, dayCount, Sonia(), spread); > > ois_swap.setPricingEngine(swapEngine) > > swapEngine = DiscountingSwapEngine(discountTermStructure) > > discountTermStructure.linkTo(OISSwapCurve) > forecastTermStructure.linkTo(OISSwapCurve) > > > > print ois_swap.NPV(); > print ois_swap.fairRate(); > > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/OvernightIndexedSwap-in-Python-tp15920.html > Sent from the quantlib-users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > http://pubads.g.doubleclick.net/gampad/clk?id=154622311&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> ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |