Tuesday, April 1, 2014

Role of Derivatives in Global Economy - Study by CME and Milken Group

Derivatives – are good for economy argues Apanard (Penny) Prabha, Keith Savard  and Heather Wickramarachi in a study published by Milken institute.  In this study have analyzed and quantified derivatives impact and concluded,


“KEY FINDINGS

»≫Banks’ use of derivatives, by permitting greater extension of credit to the private sector, increased U.S. quarterly real GDP by about $2.7 billion each quarter from Q1 2003 to Q3 2012.
»≫Derivatives use by non-financial firms increased U.S. quarterly real GDP by about $1 billion during the same period by improving their ability to undertake capital investments.
»≫Combined, derivatives expanded U.S. real GDP by about $3.7 billion each quarter. The total increase in economic activity was 1.1 percent ($149.5 billion) between 2003 and 2012.
»≫By the end of 2012, employment had been boosted by 530,400 (0.6 percent) and industrial production 2.1 percent.”

Derivatives are termed as Financial WMD by famed investor Warren Buffet. In the wake of great financial crisis of 2008 regulators have focused on bringing transparency to Derivatives trading blaming some of these products do not provide any value to the society. This study first of its kind in terms of not only putting together case studies on how Air line carriers hedge their oil cost by using Oil based derivatives, Food processor hedging his production costs by utilizing grain based contracts and most importantly how banks are able to intermediate loans by managing their interest rate risk but also building a quantitative model to back their analysis.

“WHY USE DERIVATIVES?
Investors generally use derivatives for three purposes: risk management, price discovery, and reduction of transaction costs. In a traditional banking model, a maturity mismatch between assets and liabilities subjects banks to interest rate risk. Derivatives mitigate this risk, which often contributes to capital adequacy, profitability, and lowering the probability of bank failure. In addition, banks make markets in derivatives to meet the risk management needs of financial and non-financial firm customers. In the process, they generate fees and other revenue from this trading as well as lower their cost of funding.

Derivatives Help Price discovery

The information that can be extracted from derivatives, such as price discovery, is another important benefit. In “complete” markets (when agents can buy insurance contracts to protect against any future state of the world), trading on derivative exchanges should reveal no new information to market participants. However, the lack of completeness means that informed traders could prefer to own futures or options in lieu of the underlying assets, and this might reveal new information about price. Most studies done on developed nations show that the futures market leads the spot market and therefore serves as the focal point for price discovery.”


I totally agree on all three points that derivatives, are helping in risk management, price discovery and reduction of transaction costs. For instance, when we consider housing market where a typical home buyer goes out to take a 30y fixed rate loan from his bank. Bank hedges this loan on its books with various interest rate derivatives (swaps) to risk manage the interest rate risk. In doing so they transact swaps leading to activity in the swap market and price discovery and leading to better rates to the home buyer.

Authors have chronicled the history of Derivatives in terms of when they started to current day regulatory environment. Growth in the trading volumes of derivative products clearly coincided with increase on global trade and rise in both bond and Equity markets.

“Given the expansion of international trade and financial activities, participants are likely to face increasing risks, and derivatives markets are expected to contribute to economic development by making these risks manageable.”






Interesting fact here to see how big Derivative markets are when compared to global GDP.

After looking at the Trading volumes focus has moved to how this growth has benefited overall economy within the framework of Risk, Price and Cost factors.


Banks use derivatives predominantly to manage the risk arising due to their banking and trading operations. Below chart shows how banks have started increasing using the derivatives on their books. Most of this derivative activity is concentrated in the hands of few large banks. As OCC’s quarterly report confirms, four big banks, JP morgan, Bank of America, Citi bank and Goldman Sachs have had lion’s share of the market.




For nonfinancial Firms Derivative have been serving purely for hedging purposes.
Below chart shows how derivatives have saved some of these firms big money.


This chart provides details of how various users of the Derivative market come together for their needs and consequently affecting the economy. Interestingly, nonfinancial firms are able to increase their firm value by using these products to hedge cash flow volatility.




Banks that use derivatives to manage their operations are able to increase their loans. Below another chart that shows this positive relationship between loan growth and Derivatives usage.







Authors have studied above relationships and confirmed usage of Derivatives is benefiting the Real GDP and increase in employment.



Sunday, March 23, 2014

European style Interest Rate Swaption pricing using - Python-Quantlib


In previous posts, I have described how to construct USD LIBOR Swap Yield curve then we have looked at how to price an interest rate swap. In this note I will discuss what is European Swaption and how to value such a product using Quantlib.

Product Description:

 European Swaptions are instruments that give holder of the option right to Pay or receive fixed rate. This option can be classified into two different types. Payer Swaption in which option buyer gets right to receive fixed rate and pay floating rate at the exercise date if exercised. Receiver Swaption works exactly opposite to the payer swaption where the option holder has the right to receive fixed rate.


Variety of players,including, Hedge funds, banks and pension funds are actively participating in this market to monetize their views on the shapes of yield curve or conduct risk management of their existing portfolios. Consequently it becomes imperative to know if the price they are paying or getting on the swaption is right. To understand this one has to have a tool set to price a swaption.

Pricing and Modeling of the Swaption:

 I have covered some details with regards to how to price a 5y into 5y ATM (at the money) swaption. To be able to value this swaption, I have constructed an yield curve ( with the details of the instruments and curve construction provided below) and then priced a 5y forward 5y swap. Then applying a 15.3% implied volatility I have priced a payer swaption yielding price of 23,162. In general these long dated swaptions are vega sesitive. In other words they appreciate or depreciate when Implied volatility changes significantly. To understand this effect,I have changed the price of the option to 60,000 and implied volatility changed to 40%. Calculations for how to perform these computations are provided step by step using python and Quantlib.
Feel free to use these in your calculation or learning process. Also available other articles on this blog that discuss nuances of swaption market, pricing model and risk management.

# Copyright (C) 2014, Khandrika Capital Markets

# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the license for more details.

from QuantLib import *
import datetime
import numpy as np
import matplotlib.pyplot as plt


# global data
# Here enter the Yield Curve reference Data
calendar = TARGET()
todaysDate = Date(28,February,2014);
Settings.instance().evaluationDate = todaysDate
settlementDate = Date(4,March,2014);

# market quotes
# Update deposit Rates ( usual source will be LIBOR Fixings on the Curve Date
deposits = { (1,Weeks): 0.0023,
             (1,Months): 0.0023,
             (3,Months): 0.0023,
             (6,Months): 0.0023}
# Obtain Futures prices from CME traded Euro Dollar Futures
futures = { Date(19,3,2014): 99.765,
            Date(18,6,2014): 99.75,
            Date(17,9,2014): 99.73,
            Date(17,12,2014): 99.69,
            Date(18,3,2015): 99.605,
            Date(17,6,2015): 99.47,
            Date(16,9,2015): 99.3,
            Date(16,12,2015): 99.085 }
# Obtain Swap rates from Traded Swaps on the Curve data
swaps = { (3,Years): 0.0079,
          (4,Years): 0.012,
          (5,Years): 0.0157,
          (6,Years): 0.01865,
          (7,Years): 0.0216,
          (8,Years): 0.0235,
          (9,Years): 0.0254,
          (10,Years): 0.0273,
          (15,Years): 0.0297,
          (20,Years): 0.0316,
          (25,Years): 0.0335,
          (30,Years): 0.0354}

# convert them to Quote objects
for n,unit in deposits.keys():
    deposits[(n,unit)] = SimpleQuote(deposits[(n,unit)])
for d in futures.keys():
    futures[d] = SimpleQuote(futures[d])
for n,unit in swaps.keys():
    swaps[(n,unit)] = SimpleQuote(swaps[(n,unit)])

# build rate helpers

dayCounter = Actual360()
settlementDays = 2
depositHelpers = [ DepositRateHelper(QuoteHandle(deposits[(n,unit)]),
                                     Period(n,unit), settlementDays,
                                     calendar, ModifiedFollowing,
                                     False, dayCounter)
                   for n, unit in [(1,Weeks),(1,Months),(3,Months),
                                   (6,Months)] ]

dayCounter = Actual360()
months = 3
futuresHelpers = [ FuturesRateHelper(QuoteHandle(futures[d]),
                                     d, months,
                                     calendar, ModifiedFollowing,
                                     True, dayCounter,
                                     QuoteHandle(SimpleQuote(0.0)))
                   for d in futures.keys() ]

settlementDays = 2
fixedLegFrequency = Semiannual
fixedLegTenor = Period(6,Months)
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
floatingLegFrequency = Quarterly
floatingLegTenor = Period(3,Months)
floatingLegAdjustment = ModifiedFollowing
swapHelpers = [ SwapRateHelper(QuoteHandle(swaps[(n,unit)]),
                               Period(n,unit), calendar,
                               fixedLegFrequency, fixedLegAdjustment,
                               fixedLegDayCounter, Euribor3M())
                for n, unit in swaps.keys() ]

# term structure handles

discountTermStructure = RelinkableYieldTermStructureHandle()
forecastTermStructure = RelinkableYieldTermStructureHandle()

# term-structure construction

helpers = depositHelpers[:2] + futuresHelpers + swapHelpers[1:]
depoFuturesSwapCurve = PiecewiseFlatForward(settlementDate, helpers,
                                            Actual360())
print depoFuturesSwapCurve.dates()
df=[]
dates1=[]
for c in depoFuturesSwapCurve.dates():
    df.append(depoFuturesSwapCurve.discount(c))
    dates1.append(c)
    print depoFuturesSwapCurve.discount(c)

termStructure = YieldTermStructureHandle(depoFuturesSwapCurve)

    

#End of Yield Curve Construction

#Begin building forward Curve

# Forward swap underlying the Swaption to be priced
# In this case I am pricing a 5y into 5Y swap
swapEngine = DiscountingSwapEngine(discountTermStructure)

nominal = 1000000
length = 5
maturity = calendar.advance(settlementDate,length,Years)
payFixed = True

fixedLegFrequency = Semiannual
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()

floatingLegFrequency = Quarterly
spread = 0.0
fixingDays = 2
index = Euribor3M(forecastTermStructure)
floatingLegAdjustment = ModifiedFollowing
floatingLegDayCounter = index.dayCounter()

#ATM forward Rate
fixedRate = 0.040852

forwardStart = calendar.advance(settlementDate,5,Years)
forwardEnd = calendar.advance(forwardStart,length,Years)
fixedSchedule = Schedule(forwardStart, forwardEnd,
                         fixedLegTenor, calendar,
                         fixedLegAdjustment, fixedLegAdjustment,
                         DateGeneration.Forward, False)
floatingSchedule = Schedule(forwardStart, forwardEnd,
                            floatingLegTenor, calendar,
                            floatingLegAdjustment, floatingLegAdjustment,
                            DateGeneration.Forward, False)

forward = VanillaSwap(VanillaSwap.Payer, nominal,
                      fixedSchedule, fixedRate, fixedLegDayCounter,
                      floatingSchedule, index, spread,
                      floatingLegDayCounter)
forward.setPricingEngine(swapEngine)




def formatPrice(p,digits=2):
    format = '%%.%df' % digits
    return format % p

def formatRate(r,digits=2):
    format = '%%.%df %%%%' % digits
    return format % (r*100)

headers = ("term structure", "net present value",
           "fair spread", "fair fixed rate" )
separator = " | "

format = ''
width = 0
for h in headers[:-1]:
    format += '%%%ds' % len(h)
    format += separator
    width += len(h) + len(separator)
format += '%%%ds' % len(headers[-1])
width += len(headers[-1])

rule = "-" * width
dblrule = "=" * width
tab = " " * 8

def report(swap, name):
    print format % (name, formatPrice(swap.NPV(),2),
                    formatRate(swap.fairSpread(),4),
                    formatRate(swap.fairRate(),4))

print dblrule
print "5-year market Spot swap-rate = %s" % formatRate(swaps[(5,Years)].value())
print dblrule

discountTermStructure.linkTo(depoFuturesSwapCurve)
forecastTermStructure.linkTo(depoFuturesSwapCurve)
report(forward,'depo-fut-swap')


##############################################
# Bulding the European Swaption pricer part

exercise = maturity
exercised = EuropeanExercise(exercise)
settlementtype="physical"
atmswaption = Swaption(forward,exercised)
#Applying a 15.3% implied volatility to 5y into 5y ATM swaption
vol1  = QuoteHandle(SimpleQuote(0.1533))
atmswaption.setPricingEngine(BlackSwaptionEngine(termStructure,vol1))
print atmswaption.NPV()

#*****************************
#Now given Market Premium implying the underlying volatility

index = Euribor3M(termStructure)
#Place holder for the iterator to hold the implied volatility in the
#swaption Helper
swaptionVols = [ # maturity,          length,             volatility
                 (Period(5, Years), Period(5, Years), 0.1533)]

helpers = [ SwaptionHelper(maturity, length,
                           QuoteHandle(SimpleQuote(vol)),
                           index, index.tenor(), index.dayCounter(),
                           index.dayCounter(), termStructure)
                    for maturity, length, vol in swaptionVols ]

for swaption, helper in zip(swaptionVols, helpers):
        maturity, length, vol = swaption
        print swaption
        helper.setPricingEngine(BlackSwaptionEngine(termStructure,vol1))
        NPV = helper.modelValue()
        print NPV
        NPV=0.06   # here we are adding a premium of 60,000 per 1 MM Notional
        implied = helper.impliedVolatility(NPV, 1.0e-4, 1000, 0.05, 0.50)
        print implied

Friday, March 21, 2014

Interest Rate Swap - Pricing - Python +Quanlib


In previous note we have understood basic building blocks of an Yield Curve. Now using that Yield Curve we will look into modeling an Interest Rate Swap. Here I am considering a Plain Vanilla style USD 5y interest rate swap with 1,000,000 Notional. This Note pays Fixed rate of 1.57% per annum coupon semi annually and receives 3M Libor quarterly.
Below is the Code used to price up this swap. This code needs to be executed along with the code that has been implemented in the Yield curve note.
swapEngine = DiscountingSwapEngine(discountTermStructure)

nominal = 1000000
length = 5
maturity = calendar.advance(settlementDate,length,Years)
payFixed = True

fixedLegFrequency = Semiannual
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
fixedRate = 0.0157

floatingLegFrequency = Quarterly
spread = 0.0
fixingDays = 2
index = Euribor6M(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)


def formatPrice(p,digits=2):
    format = '%%.%df' % digits
    return format % p

def formatRate(r,digits=2):
    format = '%%.%df %%%%' % digits
    return format % (r*100)

headers = ("term structure", "net present value",
           "fair spread", "fair fixed rate" )
separator = " | "

format = ''
width = 0
for h in headers[:-1]:
    format += '%%%ds' % len(h)
    format += separator
    width += len(h) + len(separator)
format += '%%%ds' % len(headers[-1])
width += len(headers[-1])

rule = "-" * width
dblrule = "=" * width
tab = " " * 8

def report(swap, name):
    print format % (name, formatPrice(swap.NPV(),2),
                    formatRate(swap.fairSpread(),4),
                    formatRate(swap.fairRate(),4))

print dblrule
print "5-year market swap-rate = %s" % formatRate(swaps[(5,Years)].value())
print dblrule
print "Term Structure\t" + "Swap Value\t" + "Swap Spread\t" + "Swap Rate\t"

discountTermStructure.linkTo(depoFuturesSwapCurve)
forecastTermStructure.linkTo(depoFuturesSwapCurve)
report(spot,'depo-fut-swap')

Thursday, March 20, 2014

Effective and Better SDR (Swap Data Repository) reporting for CFTC Regulator

·         6351-01-P
COMMODITY FUTURES TRADING COMMISSION
17 CFR Chapter I
RIN 3038-AE12
Request for Comment on Part 45 and Related Provisions of the Commission’s Swap Data Reporting Rules
AGENCY: Commodity Futures Trading Commission.
ACTION: Request for comment.
SUMMARY: On January 21, 2014, the Commodity Futures Trading Commission (“Commission” or “CFTC”) announced the formation of an interdivisional staff working group (“Working Group”)1 to review its swap data reporting rules and related provisions set forth in part 45 of the Commission’s regulations.2 Among other objectives, the Working Group was asked to identify and make recommendations to resolve reporting challenges, and to consider data field standardization and consistency in reporting by market participants. Consistent with those efforts, and informed by the Working Group’s analysis to date, the Commission today requests comment on specific swap data reporting and recordkeeping rules to help determine how such rules are being applied and to determine whether or what clarifications, enhancements or guidance may be appropriate. This request for comment is limited to part 45 and related provisions.

Summary: CFTC and other regulators are interested to understand the risk in the financial system to consider the oversight functions performed by the Commission, including, but not limited to, financial surveillance; market surveillance; risk monitoring; and trade practice surveillance.  To be able to do this job, regulators need accurate underlying Trade data and process work flow to measure and monitor the risk. Currently CFTC is relying on the OTC Derivative trade information provided by GTR (Global Trade Repository) at DTCC to perform this function. In a world where transactions happen in variety of asset classes, with variety of payoffs and disparate ways to identify trade parties it is a formidable task to aggregate all aspect of the transactions.  So far global investment banks themselves are having tough time to represent this trade information in their internal systems are doing this in a piece meal approach. In that case can this problem of collecting trade information in a way that can lend to our better understanding be solved? The answer is yes. We need to focus on replicating a typical trade booking system approach in place in most banks. Of course, this is not panache for all our problems but it will capture 90% of trade information effectively that is contributing to the global financial risk in the system.
My Recommendations would be as follows
  1.  Divide Transactions into various product types (Swaps, Vanilla options, Exotic options etc) 
  2. Aggregate Notional values, Mark to market values and Counterparty types to estimate exposures for each asset class or Trading entity
  3. Trades should reflect the lifecycle of the transaction otherwise our estimate of risk will be inaccurate
  4. Trade work flow (Trade amendments, Novations, Compressions) should be reflected on the transactions
  5.  Price forming data should be disseminated for market participants to understand the state of market

One can understand what a trade is telling looking at
  •  Price of execution to read where the market is trading ( Price Continuation Data)
  • Nature of transaction to see what risks it is creating (Product type and PET)
  • counterparty details to figure the probable purpose of transaction (Counterparty info, Clearing)
  • Underlying legal and collateral information to understand how to value the trade at fair value.( collateralized, independent amount, thresholds etc)

 I guess if we can replicate this model from one trade to thousands of trades effectively we are in good sh


     Confirmation Data (§ 45.3): What terms of a confirmation of a swap transaction should be reported to an SDR as “confirmation data”?
1. What information should be reported to an SDR as confirmation data? Please include specific data elements and any necessary definitions of such elements.

For every transactions, PET (primary economic terms) are the basis and needs to be disclosed if one needs to understand the transactions. These terms vary for each product type hence individual elements will be different.
For instance to measure risk of the trades below we need all the PET terms that vary by product.
·         IR swap, we need to know who is paying fixed and what floating rate etc.
·         Equity Variance swap, we need to know the Vega notional, Variance strike rate
·         Cliquet, we need to know details like Global cap,  Global floor etc
                So the list of terms is exhaustive but very long.

2. Should the confirmation data reported to an SDR regarding cleared swaps be different from the confirmation data reported to an SDR regarding uncleared swaps? If so, how?

Cleared swaps are cash collateralized compared to un cleared where collateral requirements are counterparty information are needed to understand further on the risk and value of the trade.
Therefore, information pertaining who is counterparty and Collateral related info should be reported to SDR.
4. More generally, please describe any operational, technological, or other challenges faced in reporting confirmation data to an SDR.
Collateral posting requirements and margin call process details information needs to be provided by the Trading party and reporting this information for all existing portfolio of trades is a cumbersome job. As banks are working towards optimizing the use of collateral this process will get matured and process will get simpler.



Tuesday, March 18, 2014

USD Yield Curve building using Python and Quantlib

Yield Curve is fundamental building block in the pricing of Interest rate Derivative products.An Yield Curve constructed using US government issued Treasury securities is termed as Treasury Yield curve, if it is constructed using corporate bonds then it is called Corporate Bond Curve and so on. Here I will describe building LIBOR Yield Curve that is bedrock for Pricing an Interest Rate Derivative product like IR swaps. Yield curve construction starts with identifying instruments needed to build and then applying appropriate bootstrapping technique.

 LIBOR Yield curve is in general constructed blending Cash deposit products, Future contracts and Swap rates based on their liquidity in the market. This is because, each of these products are liquid at particular time to maturity in the market

Cash Deposit products: LIBOR cash deposit markets is very active in overnight, 1week, 1M, 3m and 6M maturities. These deposits are quoted in the market as cash rate earned for a particular maturity. In general LIBOR Rates are now fixed by Intercontinental Exchange after the infamous LIBOR Fixing scandal.These rates are quoted with ACT/360 basis convention. Futures products: Euro Dollar Futures are most liquid traded instruments on CME exchange. These futures imply LIBOR interest rate for that period. Typically they are traded on the market with March, June, September and December expiration dates along with serial months on the front end. These contracts are being traded as far as 10 years from now. A typical contract for instance, Jun 14 ( symbol: EDM4) will imply a 3m rate starting on June as of today. These contracts are very useful in risk management of trading book with interest rate swaps. Future contracts are traded on the exchange and are subject to initial and variation margin. Due to this when comparing futures rates with Over the counter traded markets, players incorporate Convexity adjustment (Here we will not cover that)
In our yield curve construction, we are going to use 8 future contracts for a period of 2 years. Different Banks have different requirements and hence this will vary from 8 to 16 future contracts.
Now let is move on to
Interest rate swaps Dollar Interest rate swaps are traded with in over the counter market. Recent Dodd Frank regulation has enjoined moving these products onto exchanges. Consequently, you are seeing movement of these products onto Swap Execution Facilities run by variety of players. Even to mitigate counterparty risk, these swaps are now moving on Clearing houses where they will become more like futures.
We will use these quoted swap rates from 3y onwards to 30y in our yield curve construction.
We utilize liquid, Deposits till 6M maturity, from there 8 future contracts and then from 3y onward till 30y swap rates are considered and blended together to construct discount curve and then Forward curve.
We will also use Piece wise flat curve interpolation methodology implemented by Quantlib in building our discount factors.Essentially this will serve the purpose of generating a smooth discount curve that can imply a smooth forward curve which is very important in pricing any kind of exotic derivatives.
# Copyright (C) 2014, Khandrika Capital Markets

# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the license for more details.

from QuantLib import *
import datetime
import numpy as np
import matplotlib.pyplot as plt


# global data
# Here enter the Yield Curve reference Data
calendar = TARGET()
todaysDate = Date(28,February,2014);
Settings.instance().evaluationDate = todaysDate
settlementDate = Date(4,March,2014);

# market quotes
# Update deposit Rates ( usual source will be LIBOR Fixings on the Curve Date
deposits = { (1,Weeks): 0.0023,
             (1,Months): 0.0023,
             (3,Months): 0.0023,
             (6,Months): 0.0023}
# Obtain Futures prices from CME traded Euro Dollar Futures
futures = { Date(19,3,2014): 99.765,
            Date(18,6,2014): 99.75,
            Date(17,9,2014): 99.73,
            Date(17,12,2014): 99.69,
            Date(18,3,2015): 99.605,
            Date(17,6,2015): 99.47,
            Date(16,9,2015): 99.3,
            Date(16,12,2015): 99.085 }
# Obtain Swap rates from Traded Swaps on the Curve data
swaps = { (3,Years): 0.0079,
          (4,Years): 0.012,
          (5,Years): 0.0157,
          (6,Years): 0.01865,
          (7,Years): 0.0216,
          (8,Years): 0.0235,
          (9,Years): 0.0254,
          (10,Years): 0.0273,
          (15,Years): 0.0297,
          (20,Years): 0.0316,
          (25,Years): 0.0335,
          (30,Years): 0.0354}

# convert them to Quote objects
for n,unit in deposits.keys():
    deposits[(n,unit)] = SimpleQuote(deposits[(n,unit)])
for d in futures.keys():
    futures[d] = SimpleQuote(futures[d])
for n,unit in swaps.keys():
    swaps[(n,unit)] = SimpleQuote(swaps[(n,unit)])

# build rate helpers

dayCounter = Actual360()
settlementDays = 2
depositHelpers = [ DepositRateHelper(QuoteHandle(deposits[(n,unit)]),
                                     Period(n,unit), settlementDays,
                                     calendar, ModifiedFollowing,
                                     False, dayCounter)
                   for n, unit in [(1,Weeks),(1,Months),(3,Months),
                                   (6,Months)] ]

dayCounter = Actual360()
months = 3
futuresHelpers = [ FuturesRateHelper(QuoteHandle(futures[d]),
                                     d, months,
                                     calendar, ModifiedFollowing,
                                     True, dayCounter,
                                     QuoteHandle(SimpleQuote(0.0)))
                   for d in futures.keys() ]

settlementDays = 2
fixedLegFrequency = Semiannual
fixedLegTenor = Period(6,Months)
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
floatingLegFrequency = Quarterly
floatingLegTenor = Period(3,Months)
floatingLegAdjustment = ModifiedFollowing
swapHelpers = [ SwapRateHelper(QuoteHandle(swaps[(n,unit)]),
                               Period(n,unit), calendar,
                               fixedLegFrequency, fixedLegAdjustment,
                               fixedLegDayCounter, Euribor3M())
                for n, unit in swaps.keys() ]

# term structure handles

discountTermStructure = RelinkableYieldTermStructureHandle()
forecastTermStructure = RelinkableYieldTermStructureHandle()

# term-structure construction

helpers = depositHelpers[:2] + futuresHelpers + swapHelpers[1:]
depoFuturesSwapCurve = PiecewiseFlatForward(settlementDate, helpers,
                                            Actual360())
print depoFuturesSwapCurve.dates()
for c in depoFuturesSwapCurve.dates():
    print depoFuturesSwapCurve.discount(c)
#output

1.0
0.999955279778
0.999801983663
0.999304040868
0.99867255034
0.997998353751
0.997225503985
0.996208950194
0.994872376004
0.993129765936
0.990838040119
0.976526437683
0.95283925956
0.923683284288
0.892554279843
0.824681470718
0.790220477256
0.753705873129
0.63046764213
0.517332972767
0.411723283158
0.315258111833

    


So far we have constructed the discount factors using Quantlib and Python. Have a great evening