Showing posts with label quantitative finance. Show all posts
Showing posts with label quantitative finance. Show all posts

Saturday, November 15, 2014

Instructor Based Introductory Course To R - R for finance/ Analytics Online Course & Projects at qcfinance.in


COURSE LINK - Introduction to R

Course Highlights:
  1. No pre-knowledge of R required.
  2. Get started with Programming in R.
  3. Get Practical examples to understand better.
  4. Gives an Idea of it’s financial applications as well.
  5. Highly flexible and tailored according to individual needs.
  6. Contains perfect blend of theory and practice
  7. Gain confidence with R.
  8. 4 interactive classes with experienced teacher.
  9. Personalized approach.
  10. Flexible timings.


Now ask for as low as just one customized  session (1 hour) from qcfinance.in at $20.


Course Description:
One on One course Introductory course for R. 4 hours of basics of R to get you started in R. Flexible timings with personalized approach by Experienced Faculty. Online tests to prepare yourself better. This course will help you in:
  • Add to the profile by learning R.
  • Provides a base for learning advanced R.
  • Gives you a perfect platform for launching a career in R.
  • Gain the knowledge of  integration with excel  .

We use 2 pluggins -
1. XLconnect
2. Rexcel to connect excel & R
+we  also  give consultancy

Course Structure:
Class No.
Topics for CFA L1
Class duration
1
Installing R, Intro to R packages, R as calculator
1 hour
2
Matrix in R, Indexing in R, Intro to ARIMA, Regression in R
1 hour
3
Connecting R with Excel, Importing CSV, Input methods, connecting R with external sources feeds like QuantDL
1 hour
4
Revision/Doubt Clearing
1 hour



About the Author:

Shivgan Joshi
Indore, India
Shivgan Joshi holds a B.E. from Shri Vaishnav Institute of Technology, Indore & PGDF (Post Grad Diploma in Finance) from Business India Institute of Finance, New Delhi. Have worked extensively on VBA, MATLAB, R & others. He has cleared CFA Level 1 and FRM L1 and has scored 70% in BAT (in top 10 percentile globally approximately). He has taken more than 500 classes on GRE & GMAT preparations in last 1 year. He has published research papers in top journals like IEEE, LNCS Springer and more. He writes a popular blog: Stock Credit Finance CFA on Blogspot.com.

Guest Faculty: Nehal Jain
Nehal holds a B.E. degree in Electronics and Communication from IIST-II, Indore. Her key skills include R, MATLAB ,C , C++, Core Java and Advance Java.
Note: If you miss a scheduled one on one class, then don't worry, you can reschedule it at your convenient time & the missed class won't be counted. You may defer a class any number of time. Also, you get life time access to materials which gets constantly updated.

Contact Us: info@qcfinance.in
Skype Id: qcfinancein

Wednesday, August 22, 2012

R for Financial Engineering Course on Applying R in Quantitative Finance/ Analytics & Projects at qcfinance.in

R for Financial Engineering / Quantitative Finance


R is mix of MATLAB and SAS, if I relate to the other 2 tools used in Finance.
R is having mix of maths and data handling powers of SAS and given that it is open source and the best choice for research.

R is MATLAB when it comes to syntax.
When it comes to data handling it uses RMySQL in the very same way as SAS does.
Hence, it does things that SAS+MATLAB do for free.
SQL has inherent limitations of doing quant computations, and MATLAB is heave and requires too much resources. MATLAB is not very good to deal with SQL at system level.

But to start with, one also needs to know VBA for entry level and for easy task, VBA is preferred.


Divisions:
  1. 10 hours on handling data, functions, indexing, structures, data linkages, importing, SQL, etc
  2. 10 hours on Financial Commands, tools, pre-built libraries.


I will discuss in detail about R and its application in this post.

Keep checking it for updates.


Ref: R in a Nutshell

For getting some info you can join my MATLAB Course at:
http://stockcreditfinancecfa.blogspot.com/2012/07/50-hours-course-in-matlab-for-finance.html

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


Course based on:

http://www.unicom.co.uk/quant-finance/R-for-Finance.php

http://www.optirisk-systems.com/papers/FinancewithR.pdf

http://www.optirisk-systems.com/events/finance-with-r.asp

https://www.rmetrics.org/ebooks-basicr

http://www.r-bloggers.com/search/finance

http://www.rinfinance.com/RinFinance2009/presentations/ChicagoWuertz.pdf

http://blog.revolutionanalytics.com/2011/11/course-financial-data-modeling-and-analysis-in-r.html

http://braverock.com/brian/R/PerformanceAnalytics/html/PerformanceAnalytics-package.html

http://www.quantmod.com/documentation/00Index.html

http://tradeblotter.files.wordpress.com/2012/06/uw_r_seminar_may_2012.pdf


Introduction to R
  • Some background on R, how to obtain and how to install it.
  • R documentation and help and web resources available.
  • R Console and R GUI.
  • Data import, data types and variables.
  • Elementary import functions.
  • Data types.
  • Variable generation, inspection and modification.
  • Graphics in R.
  • Command "plot" and where to plot.
  • Setting the par.
  • High-level and low-level plotting functions legends.
  • Math in plots.  
  • Hands-on Session—data handling & graphics.
  • Simulations in R.
  • Simulating from given distributions.
  • Risk management basics.
  • Data Structures in R.
  • Review of types of objects.    
  • Additional object types.
  • Basics of the R Language. 
  • Conditionals & Loops. 
  • Writing R Functions: Basic functions.
  • Object-orientation.
  • Debugging.
  • Application in Finance.
  • Calculating Value at Risk.
  • Packages for Portfolio Optimization. 


Functions of R/R Commands to be covered in the course:
Caution: Always save workspace.
Use “c” when you want to use it a signal in black scholes formula.

read.table function will be used to get the data into R (/\ used opposite
than the one used in windows)
http://www.ats.ucla.edu/stat/r/faq/inputdata_R.htm.

Example 1
> test.txt <- read.table ("C:/Documents and Settings/shivbhakta.joshi/My
Documents/test.txt", header=T)
> print(test.txt)
> column <- test.txt[,c('make','price')].

Example 2
grb <- read.table ("C:/Documents and Settings/shivbhakta.joshi/My
Documents/GRB_afterglow.dat", header=T, skip=1)
x <- (grb[,1]).

Grabbing data from tables into a single dimensional array
x <- (grb[,1])
y <- log(grb[,1]).

Another way to create returns for stock daily return is
f=dft$age/dft$price (using dollar sign extraction)
Deleting column http://www.sr.bham.ac.uk/~ajrs/R/r-manipulate_data.html
> add <- add[-2] to delete the element 2nd
Adding data to array busing column command
> add <- c(1,d).


Using Data frames
Data.frame is used to combine the arrays back into table format
people = data.frame (x,y)
Write.CSV command executed
write.csv(people,"filename.csv")

grb <- read.table ("C:/Documents and Settings/satyadhar.joshi/My
Documents/GRB_afterglow.dat", header=T, skip=1)
x <- (grb[,1])
y <- log(grb[,1])
people = data.frame (x,y)
write.csv(people,"filename.csv")

These methods can be used to compute beta from columns of a csv file.


Working formula of Black Scholes
BS <-
function(S, K, T, r, sig, type="C"){
d1 <- (log(S/K) + (r + sig^2/2)*T) / (sig*sqrt(T))
d2 <- d1 - sig*sqrt(T)
if(type=="C"){
value <- S*pnorm(d1) - K*exp(-r*T)*pnorm(d2)
}
if(type=="P"){
value <- K*exp(-r*T)*pnorm(-d2) - S*pnorm(-d1)
}
return(value)
}

Black Scholes <- function(s, k, r=.1, t=5, sigma=.9,call=TRUE) {
#calculate call/put option
d1 <- (log(s/k)+(r+sigma^2/2)*t)/(sigma*sqrt(t))
d2 <- d1 - sigma * sqrt(t)
ifelse(call==TRUE,s*pnorm(d1) - k*exp(-r*t)*pnorm(d2),k*exp(-r*t)
* pnorm(-d2) - s*pnorm(-d1))
}


Predefined Black schools model:
http://shafik.net/~shafik/FinancialEngineering/Code/
black_scholes ("c",5600,5600,.1,.08,.22 )
this depicts use of functions in R.


Merton Distance to Default (different as per needs)
(modified from Black Scholes formula, still
unsure about pnorm() function)
d1 <- (log(s/k)+(sigma^2/2))/(sigma)
pnorm(d1)

3 files are needed to run the demos which are available on internet by various authors:
  1. black_scholes.R
  2. GRB_afterglow.dat
  3. test.txt.

ARIMA and Forecasting Using R

Commands:

library(Quandl)
> Quandl.auth("1LkmpypqJskJzKcpd2TV")

>stockData=Quandl("YAHOO/INDEX_GSPC", start_date="2004-01-01", end_date="2014-04-17")

stockData[,7]

// ran Arima here:
results2=arima(stockData[,7], order = c(3,0,0))

fit <- arima(myts, order=c(p, d, q)

fit <- arima(stockData[,7],order = c(3,0,0))

results=arima(stockData[,7])

fit <- arima(stockData[,7],order = c(3,0,0))

predict(arima(stockData[,7], order = c(3,0,0))

results=arima(stockData[,7])

x2=(forecast(fit, 100))

plot(x2).


Excel and R:
http://rcom.univie.ac.at/download.html#statconnDCOM
http://www.r-bloggers.com/a-million-ways-to-connect-r-and-excel/
http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf
http://cran.r-project.org/web/packages/XLConnect/XLConnect.pdf
https://stat.ethz.ch/R-manual/R-patched/library/base/html/getwd.html


Playing with arrays and matrix
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f
https://stat.ethz.ch/pipermail/r-help/2008-February/154088.html
http://stat.ethz.ch/R-manual/R-devel/library/base/html/rev.html.

ARIMA and Predict statement
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/predict.arima.html
http://people.duke.edu/~rnau/411arim.htm
http://www.statmethods.net/advstats/timeseries.html
http://stackoverflow.com/questions/14272937/time-series-prediction-using-r
http://www.inside-r.org/packages/cran/forecast/docs/forecast.Arima.

Market check
http://www.bloomberg.com/quote/SPX:IND/chart.

Other good References
http://heather.cs.ucdavis.edu/~matloff/132/NSPpart.pdf.


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 Trainings are provided on request 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.

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


Website- http://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-defined 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

Friday, November 11, 2011

Research areas in Financial Engineering and Trends

Introduction: This blog is aimed to deliver you the latest research and innovation in financial and risk engineering. I will be posting topics related to Energy risk, financial game theory, financial war simulations, modeling developments on derivatives, and other areas of finance. Also I will try to link these areas to the studies for CFA/FRM and other courses.

Game theory is to predict how a game would look like and what can be the moves. It identifies the game into a type link the probabilities and then find the best path to move so that ultimately the result is the best.

Portfolio is defined by the modern portfolio theory also covered in the exams, but in real we need to adjust various parameters. For example in real the risk may not be just SD, distributions needs to tweaked, time lines needs to adjusted and selection of right tiem interval, etc. There are also various software available for the same and there are lots of complexities which needs to be modeled.

Option pricing is another very very quant based areas which use physics from quantum mechanics. All those who like physics will like this area of derivative pricing.

Energy risk with focus on  Investment banking for alternative energy sources like solar, wind and fuel cell is any area that will play a very important role. The current energy companies needs to make a very right strategy so that they can create wealth.

Financial Engineering includes Java/C++ modeling and advanced Engineering maths which has calculus, vector, advanced probability which is one step up from the the CFA prep. With CFA and FRM in your resume you must look into this area, as in real life these kinds of models are seen.

Some of the Journals that I am referring are:
Review of Quantitative Finance and Accounting @ Springer

Mathematical Finance @ Wiley
Quantitative Finance @ Taylor & Francis
Applied Mathematical Finance  @ Taylor & Francis
Journal of Empirical Finance  @ ScienceDirect

I will post some of the review about the recent developments in Quantitative Finance in the Blog in the coming days.

Application of what we have in CFA1/2 FRM 1/2 SAS/Matlab can be seen very clearly in international business and green energy business models. Economics of CFA L2 is quite interesting and talks about important international economics. Whereas international strategy for international business is very much dependent of aspects of foreign exchange, and investment accounting taxing etc.

I will be looking for how game theory can be imbibed in the financial studies I am doing especially when it comes to areas like Nanotechnology. This becomes even more important when you are aware of all areas of CFA and FRM and then move to research and I can see that benefit.