I recently caught a podcast via Chat with Traders that included one among several episodes related to quantitative finance and this one emphasized some basics of machine learning. Very good discussion of some fundamental concepts in machine learning regardless of your interest in finance or algorithmic trading.
You can find this episode via iTunes. But here is a link with some summary information.
Q5: Good (and Not So Good) Uses of Machine Learning in Finance w/ Max Margenot & Delaney Mackenzie
https://chatwithtraders.com/quantopian-podcast-episode-5-max-margenot/
Some of the topics covered include (swiping from the link above):
What is machine learning and how is it used in everyday life?
Supervised vs unsupervised machine learning, and when to use each class.
Does machine learning offer anything more than traditional statistics methods.
Good (and not so good) uses of machine learning in trading and finance.
The balance between simplicity and complexity.
I believe the guests on the show were quantopian data scientists, and quantopian is a platform for algorithmic trading and machine learning applied to finance. They do this stuff for real.
There was also some discussion of python. Following up with that there was a tweet from @chatwithtraders linking to a nice blog, python for finance that covers some applications using python. Very good stuff all around. I wish I still taught financial data modeling!
See also: Modeling Dependence with Copulas and Quantmod in R
An attempt to make sense of econometrics, biostatistics, machine learning, experimental design, bioinformatics, ....
Showing posts with label quantitative finance. Show all posts
Showing posts with label quantitative finance. Show all posts
Thursday, February 16, 2017
Sunday, October 30, 2016
Modeling Dependence with Copulas and Quantmod in R
A while back I produced a few posts related to copulas. In A Basic Intro to Copulas I played around with some examples using SAS. This gave me some idea about how you could fit copulas based on parameters estimated from real data. And then I did some exploratory work using the copula package in R. In Copulas Functions, R and the Financial Crisis I mentioned some properties of copulas and how they were used in some of the risk modeling related to mortgage backed securities that went bad during the financial crisis. I used R to make some copula based plots....but it just did not click with me how I could use the copula functions in R to do anything concrete.
However, recently I ran across a post Modelling Dependence with Copulas in R, in which the author walks through a number of motivating examples giving some really powerful intuition about how copulas work, as well as a concrete application using stock data.
In this post (or really just the R code below) I modified the code somewhat to pull the data from yahoo finance using the quantmod package in R. Then I just pulled out the key segments of code that estimated the copulas, and concretely used parameters derived from the actual stock data to simulate returns for two stocks, Yahoo and Cree, Inc. Except I used Monsanto and ADM.
One thing discussed in the post that I found very interesting was related to the VineCopula application. This was used to help decide which copula specification might make the most sense for a given data structure.
"In the first example above I chose a normal copula model without much thinking, however, when applying these models to real data one should carefully think at what could suit the data better. For instance, many copulas are better suited for modelling asymetrical correlation other emphasize tail correlation a lot, and so on. My guess for stock returns is that a t-copula should be fine, however a guess is certainly not enough. Fortunately, the VineCopula package offers a great function which tells us what copula we should use. Essentially the VineCopula library allows us to perform copula selection using BIC and AIC through the function BiCopSelect()"
Below is the last plot from my code, of simulated returns vs actual daily returns for Monsanto and ADM for the last 3 years. I'll have to echo the above, I didn't use the VineCopula package to select a copula, but my intent here was just to look at some example code and a practical application of copulas using R with real data.
I won't share the previous plots etc. but refer you to the original post where they walk through the code almost line by line and demonstrate really well how this works. My code is below, but they have their entire program for their orignal post at github.

R Code:
However, recently I ran across a post Modelling Dependence with Copulas in R, in which the author walks through a number of motivating examples giving some really powerful intuition about how copulas work, as well as a concrete application using stock data.
In this post (or really just the R code below) I modified the code somewhat to pull the data from yahoo finance using the quantmod package in R. Then I just pulled out the key segments of code that estimated the copulas, and concretely used parameters derived from the actual stock data to simulate returns for two stocks, Yahoo and Cree, Inc. Except I used Monsanto and ADM.
One thing discussed in the post that I found very interesting was related to the VineCopula application. This was used to help decide which copula specification might make the most sense for a given data structure.
"In the first example above I chose a normal copula model without much thinking, however, when applying these models to real data one should carefully think at what could suit the data better. For instance, many copulas are better suited for modelling asymetrical correlation other emphasize tail correlation a lot, and so on. My guess for stock returns is that a t-copula should be fine, however a guess is certainly not enough. Fortunately, the VineCopula package offers a great function which tells us what copula we should use. Essentially the VineCopula library allows us to perform copula selection using BIC and AIC through the function BiCopSelect()"
Below is the last plot from my code, of simulated returns vs actual daily returns for Monsanto and ADM for the last 3 years. I'll have to echo the above, I didn't use the VineCopula package to select a copula, but my intent here was just to look at some example code and a practical application of copulas using R with real data.
I won't share the previous plots etc. but refer you to the original post where they walk through the code almost line by line and demonstrate really well how this works. My code is below, but they have their entire program for their orignal post at github.
R Code:
Subscribe to:
Posts (Atom)