Tuesday, June 12, 2012

MATLAB Finance for Fixed Income / Credit Risk (Analysis and Data Cleaning)/ Passive smart ETF

Financial Applications of MATLAB 



Our course on MATLAB


WizIQ Link

Join our MATLAB for financial engineering course (http://www.wiziq.com/course/7225-matlab-for-financial-engineering) & get 15% discount. Ask for discount code, email - info@qcfinance.in


Websitehttp://qcfinance.in/
YouTube Channel- http://www.youtube.com/user/shivbhaktajoshi


In this post I am going to talk about how to use MATLAB for Financial Risk Management. Also for Fixed Income in general. There is a big file of fixed income of 500 pages which MATLAB has provided.

Areas to look at in Finance to start with are:
  1. For those who have not done Programming before the logical flow like For statement becomes the first Hurdle.
  2. Regression using MATLAB.
  3. Symbolic computations.
  4. Making Chart: Polyval(c,x) to make the long elements that can be then used for making chart.
  5. Different way to make different type of matrix, like equal, incremental etc.
  6. Matrix division vs Element by element division.
Program 1: Consider writing a user-deļ¬ned function that searches a matrix input argument for the element with the largest value and returns the indices of that element.

Book Review: MATLAB Basics and Beyond: This book has lot of graphic and graphics and data type forms the heart of stuff that are done.

Book Review: MATLAB Primer

FRM Level 2 terms in MATLAB Stat toolbox:
  • Copula
  • Modelling Tail Data with the Generalized Pareto Distribution.
  • Modelling Data with the Generalized Extreme Value Distribution.
  • Bayesian Analysis for a Logistic Regression Model.
  • Weibull distribution.

Data Cleaning and management with MATLAB:
  1. Playing with Array & Matrix.
  2. Errors and data cleaning Excel.
  3. Programs you have made on VBA.
  4. Old programs in MATLAB (questions on that).
  5. Movement and arrays of data.
  6. Time series analysis in MATLAB.
  7. Types of array / matrix / data types / vector arrays etc.
  8. Reducing and selecting of Matrix.
  9. Looping for data handing in Excel.
  10. Reading Data from SQL Database and linking the system (advanced and out of scope), MATLAB Database toolbox.
  11. Interpretation and Control.
  12. Trading MATLAB and importance of Visualization.
  13. Commodity trading in MATLAB.
  14. SAS vs MATLAB for Intermediary display.
  15. CDS MATLAB / VAR 99% VAR 1 day, this is interesting probability of default as well, bond valuation in MATLAB using some data.
  16. Loops for Array.
  17. CDS in MATLAB, article of Markit.
  18. Query Builder SQL Array.
  19. Struct http://www.mathworks.in/help/techdoc/ref/struct.html.

There was array handing, and how to manage data for Quant Finance...

Preparing data for final analysis for: Algo trading & VAR computations

Five area of MATLAB you need to master:
  1. StatisticalToolbox
  2. Symbolic computation toolbox
  3. Fixed income
  4. Econometrics (Monte Carlo)
  5. Derivatives
Generic Knowledge about the industry needed:
  • Data -- Inter-phasing -- Output
  • Spreads changing
  • Bank Rating Consumer
  • Shorting CDS
  • Causes and Role of Goldman on Greece Crisis


Interesting areas in MATLAB Finance where I am researching solutions are:
  1. Data management or data cleaning or data optimization skills used in MATLAB.
  2. Loop for data correction like addressing blank or data types management.
  3. Optimizing data for time series.
Three job profiles:
  1. Bond spreads, CDS, fixed income etc (M).
  2. VAR, PoD, bond portfolio, companies bond, trading data and VAR for that, etc (G).
  3. Data cleaning for Time series, other data cleaning and optimizations (E).

References:
http://www.mathworks.in/help/techdoc/ref/struct.html
http://www.mathworks.in/help/techdoc/ref/size.html
http://www.mathworks.in/help/techdoc/ref/f16-42340.html
http://www.mathworks.in/products/matlab/demos.html?file=/products/demos/shipping/matlab/nddemo.html



MATLAB for Finance by qcfinance.in

This article will talk about various applications in MATLAB for finance. We have taken in real time issues in the recent months and discussed how we can simulate some on them on MATLAB.

MATLAB can be learned and used for all of the following purposes:
  1. Old work ppt: Reliability, HPC, simulink etc.
  2. Data cleaning, data modifications, data arrays, struct, rating matrix, selection of elements from rating matrix, banks internal rating and pod computations, post that you made.
  3. Matlab for game theory.
  4. For fixed income Bond pricing, CDS, and other leveraged fixed income tools on MATLAB.
  5. Matlab for distributions and monte carlo.
  6. Data handing from sql and other parameters for MATLAB.
  7. MATLAB HPC toolbox to be used for various other options.
  8. Neural network in Finance.
There were few articles I found on MATLAB Credit Risk and there were many more on their website:
http://www.mathworks.in/products/finance/

Conclusion
  • MATLAB Credit Risk : Credit Risk Modeling Using Excel and VBA is a good book to look out for excel based modeling which then can be taken into MATLAB (link was on the references of the above articles)
  • As far as the comparison goes, R vs MATLAB, MATLAB is much easier and the only reason people do R in west is because R is free and MATLAB is very expensive.
  • As per my knowledge R and SAS are not so much user friendly, although when it comes to hardcore data handling SAS is much much better. MATLAB is good for easier applications.
Quantitative Analysis & Fixed Income Research:
  1. Back-testing of investment strategies.
  2. Credit risk modelling using KMV approach (Merton Model), there is a tool of Moodies, and also work on Municipal bonds (question in interivews).
  3. Monte-Carlo simulation.
  4. Portfolio optimization and asset allocation.
  5. Statistical modelling, variance-covariance modelling, value at risk modelling, regular risk reporting (hot spot reports, concentration reports), risk assessment and style analysis of money managers, term structure modelling, rich cheap analysis.
  6. Mark-to-market of fixed income instruments.
  7. Credit research reports covering liquidity and debt analysis (Equity based).
  8. Yield and CDS spreads.
Thus looking at them can help us understand how MATLAB can help us to work on these specific areas.

Passive Smart ETF

CMO

http://www.mathworks.in/help/fininst/using-collateralized-debt-obligations-cmo-.html

http://www.mathworks.in/help/fininst/cmoschedcf.html
http://www.mathworks.in/help/fininst/mbscfamounts.html
http://www.mathworks.in/help/fininst/cmoseqcf.html
http://www.mathworks.in/help/fininst/example-collateralized-debt-obligations-cmos-.html
http://en.wikipedia.org/wiki/Collateralized_mortgage_obligation

Links to toolbox:
statistical_toolbox.pdf
econometrics_toolbox.pdf
financial_derivatives_toolbox.pdf
financial_time_series_toolbox.pdf
fixed_income_toolbox.pdf
financial_toolbox.pdf

Some Books to refer:
  • Elementary Stochastic Calculus With Finance in View (Advanced Series on Statistical Science & Applied Probability, Vol 6) (Advanced Series on Statistical Science and Applied Probability).
  • Financial Options: From Theory to Practice.
  • Paul Wilmott on Quantitative Finance 3 Volume Set (2nd Edition).
  • Monte Carlo Methodologies and Applications for Pricing and Risk Management. 
  • Stochastic Calculus for Finance I: The Binomial Asset Pricing Model (Springer Finance / Springer Finance Textbooks).
  • Modern Pricing of Interest-Rate Derivatives: The LIBOR Market Model and Beyond.
  • The Analysis of Structured Securities: Precise Risk Measurement and Capital Allocation.
  • Credit Derivatives Pricing Models: Models, Pricing and Implementation (The Wiley Finance Series).






One on One Customized Training:
qcfinance.in believes in personalized touch so that our clients are completely satisfied with our service. In this regard, we offer One on One Customized Training to our clients.
These Training are provided on requests by our clients & are customized according to their individual needs.
The course structure & timings for these training are highly flexible, classes are scheduled as per the convenience of our clients. 

Contact Us for More details: info@qcfinance.in

MATLAB for Finance FRM CFA

Monday, June 11, 2012

Reinsurance Interview Prep Questions


In this post I am going to talk about Reinsurance, like CDS this is another very interesting area.

Important Points:
  1. Two types of Reinsurance: Facultative and Treaty.
  2. Reliability of Big Machines and how they could fail is an engineering area which needs to be put in a Business case for the Facilitative Reinsurance.
  3. A profile of Mechanical Engineering, and Electrical Engineering is useful to capture reliability of these devices and when they could fail causing an event. 
  4. Exotic Insurance like CDS Swap, defaults do they come under reinsurance?
  5. Catastrophe modeling: Various distributions 
  6. Securitization 
  7. Reinsurance Side Car: http://en.wikipedia.org/wiki/Reinsurance_sidecar
  8. Catastrophe Bonds and trends
  9. Poisson Distribution, I think I saw this operation Risk in FRM as well. Levy process, Bayes estimation.
  10. Monte Carlo, Pareto Distribution, Bootstrapping, we often see these terms in Insurance Analytic 
  11. Some Actuarial Exams has this General Insurance paper which your should refer

These are some of the topics that you might find helpful. There are very less jobs in Reinsurance and hence this area is not explored for Job prospectus. Jobs for entry level are with Reinsurance Brokers.

Wednesday, June 6, 2012

Credit Risk Research & Prep guide for FRM Level 2, Credit Risk Interview, CFA L2 Fixed Income

Credit Risk Research & Prep guide for FRM CFA Fixed Income/Job Interviews
By Satyadhar Joshi


Introduction
This thread is about Credit Risk for FRM Level 2, Credit Risk Interview, and other topics of Modeling Credit Risk. One thing that is very important for you to understand is that is that if you read without understanding the matter, you might fail in the interviews which run for over 2 hours, with at least 50 questions for a Credit Risk Job.

To start with, I will assume you are through with FRM and CFA Level 1 or MBA Finance and know all the basics of Finance. Now we will jump into the advanced areas of credit risk.


FRM Level 2
Areas of Credit Risk that are interesting to look into are (also in the form of chapters in readings in FRM Level 2):
  1. MBS: Securitization, Tranching & CMO.
  2. Measuring of Credit Risk & Measuring of default Risk: Requires Probability.
  3. Credit Exposure calculations.
  4. CDS & CDO (Structural Finance), CDO contains all of them and is most complex.
  5. Managing Credit Risk.
Now how these credit risk elements are modeled and simulated is another important aspect.


Quant Finance application in credit research:
  1. Stochastic Calculus & Black Scholes (use to find interest rates of the future)
  2. Monet Carlo (CFA L2 talks about how to use it for Option adjusted Spread)
  3. Neural Networks (used to reverse engineering elements from market, saw some research papers on this area, will try to post the link).

Modeling Aspects in Credit Risk, to be done using SAS or VBA Excel:
  1. Database Management in SAS, Access, Business Objects, Hyperion and Cognos.
  2. Using decision tree or cluster analysis to group together similar operating variables, environment etc.
  3. Using regression based models (Logistic, OLS, Discriminant, etc.) to arrive at EL (Expected loss per Quarter), PD (Probability of Default), LGD (Loss Given Default) and Exposure at Default.
  4. Modeling probability based on logistic regression in SAS.
  5. Sensitivity (Elasticity) analysis, Interest rate/Discount rate to compute NPV of deal.
  6. Sovereign risks to model interest rate.
  7. Basel Credit Risk Modeling (PD, LGD & Stress Testing).
  8. Logistic Regression, Linear Regression, Cluster, CHAID and Time Series Forecasting.
  9. SAS, FICO Model Builder, Knowledge Seeker, MS Office and Minitab.

      CFA helps in Credit Analysis as it has in CFA Level 2:
      1. Valuing media bonds and understanding of accounting for corporate bond valuations.
      2. Understanding how Moody uses the algo for bond rating.
      3. CDS uses bond valuation which is not covered in FRM but in CFA L2 for corporate bonds.

      From FRM Level 1 Monte Carlo & Interest rate dynamics
      1. One Box Ingersoll Ross one factor model for short term interest rates.
      2. Two factor Brennan and Schwerz Model for short term and long term rates.

      Numerical of Credit Risk (CFA Level 2):
      1. Binomial numerical CFA L2.
      2. CPR PSA.
      3. Tranches in CMO.
      4. Valuation last chapter of CFA L2 Fixed Income is interesting.
      5. Monte Carlo Simulation for calculating probability of default and or OAS and CMO.

      Important points that comes out from CFA L2:
      1. CDO is an ABS.
      2. OAS is an interesting thing to read on, and how they are used with Monte carlo simulation.
      3. OAS over valued and under valued.

      Trends in Credit Research

      In all, we have to also understand computation of default frequency and numerical for default frequency and reverse interpretation from Rating agency. Models to calculate default frequency and loss given default and change of yield is an important parameter which is quite hot.

      Tough numerical of FRM Level 2 is interesting, which you learn when you will give the Level 2 exam.


      Linking SAS for credit risk [1]:
      1. Classification trees, neural networks, time-series modeling.
      2. Roll rate models, predict delinquencies and perform vintage curve analysis to generate highly accurate credit loss forecasts (these are interesting research areas that are being researched).
      3. Probability of default, exposure at default, credit migration, regulatory capital, risk weighted assets, credit value at risk (CVaR) and economic capital (areas seen in FRM L2).
      4. Mark-to-market calculations, model risk factors, run Monte Carlo simulations, explore scenarios and build stress tests.

      Things that were interesting but not prepared by me, please learn about them before entering:
      1. Merton Model.
      2. Migration Risk.
      3. Copula and Multivariate Analysis.
      4. Advanced VBA, but there is no international exam on this.
      5. SAS is the most relevant software for Credit Risk, SQL Excel and how to link them in SAS software is another interesting thing.

      3rd Party Resources (Credit to respective authors):

      Quoting Kenny Ming of HK from [2] where he talks about interview questions. And I Quote
      1. Basel II and Implication.
      2. Risk Management in Derivatives Product, Structured Products and Hybrid Products.
      3. Forecasting Time Series by Garch(1.1), Garch(1.1)-t, Garch-M, Nonlinear-Garch, Kurtosis of Garch model, CHARMA, EGarch Model by Maximum Likelihood function . IGarch(1.1) for Risk Metrics
      4. Risk Metrics approach for portfolio risk.
      5. Monte Carlo Simulation for portfolio stocks, structured products such as equity linked products, hybrid products.
      6. Greeks for dynamic hedging by closed form formula for standard European Option and finite difference method for non-linear structured product and exotic option.
      7. Static Hedging of Option by Derman and Peter Carr Approach and Quasi Static Approach for re-hedging structured products.
      8. Value at Risk: Law of Coherent Risk (Axioms and examples)
      9. Extreme Value Theory: Estimation of tail distribution, Dynamic extreme value theory, Multivariate EVT
      10. Statistics and Probability: e.g. skewness, tail effect, distribution, conditional probability, tower law of probability.
      11. Back-testing and Stress-testing principle
      12. Using add-in Excel function and VBA for large scale risk management assessment.
      13. Pricing non-linear option by C++ programming.
      14. Interest rate model, Swaption, fixed income

      GARCH (1.1) model to simulate the volatility due to "leverage" effect?
      How about if there is great jump/drop?
      How about if the volatility forecasting is related to other variable?
      How do you compare with the difference between GARCH and implied volatility?
      "Cholesky Decomposition"


      How to create VAR for:
      1) Private Debt Securities (PDS)
      2) IRS & CCS
      3) Convertible Bonds
      4) American style FX Options
      5) European style interest rate caps & floors
      6) Callable Range Accruals
      7) American style exchange traded Equity Warrants
      8) Multi-asset basket options.

      Mountain Range Options taken from [2].

      Conclusion
      Three sources needs to be seen: CFA FRM and bits of quant finance to understand and work in credit risk area. The area is very deep and you need to read a lot to know more about how things go. The jobs here are very interesting and fascination. If I get time I will develop a video series for this area.


      List of place to read about financial risk [3]:
      1. www.wbstraining.com/php/events/showevent.php?id=117
      2. www.financial-conferences.com
      3. www.incisive-events.com/public/showPage.html?page=im_events_quanteuro2006_prog&tempId=334063
      4. doi:10.1111/j.1467-9965.2006.00281.x.

      My Targets are to model the following in MATLAB [6] for Credit Risk:
      1. Questions of VAR
      2. CDO
      3. CDS
      4. OAS
      5. Monte Carlo Simulation for various applications.
      I will try to put my code here as well so that you can run the program on your system as well.


      References
      [1] http://www.sas.com/industry/financial-services/banking/credit-risk-management/index.html
      [2] http://www.wilmott.com/messageview.cfm?catid=16&threadid=49249
      [3] http://www.wilmott.com/messageview.cfm?catid=11&threadid=43404
      [4] My SAS Post on the same Blog: http://stockcreditfinancecfa.blogspot.in/2011/12/sas-base-certification-study.html
      [5] http://www.sas.com/offices/europe/uk/education/courses/bb3c61.html
      [6] http://www.mathworks.in/computational-finance/.


      Taken from Naukri.com:
      • Familiarity with PD, LGD models with hands on experience in creating these.
      • Knowledge of Basel framework and regulations and experience in creating related models.
      • Running SAS queries to prepare datasets used in analysis and predictive modeling.
      • Ability to use SQL from SAS to extract and aggregate data from larger data sources.
      • Perform ad-hoc analysis/statistical analysis and generate actionable reports.
      • Provide assistance/guidance to other team members in SAS/SPSS/MS Excel/MS Access and VBA etc.
      • Exposure to other analysis tools like SPSS, R, and other is useful.
      • Exposure to IT data management tools and BI platforms is a plus.
      • Generally hedge funds/Asset managers needs to implement market risk solution in the enterprise wide. risk framework. It requires understanding of the details of Market Risk/Credit risk and derivative products from major asset classes (Fixed Income, Equity and derivatives).
      • Working across risk framework ladder which typically covers risk production, pricing and valuation, risk analytics and risk advisory Key Skills.
      • Expertise in Market risk/ Credit risk is required focusing on value at Risk, scenario analysis and stress testing and Portfolio p&l attribution.
      • Knowledge about pricing and modelling of financial products from Fixed Income, Equity and structured products domain.
      • Knowledge of Global markets dynamics including macroeconomics, news analysis and ability to relate financial markets event to trade performance etc.