Directory of Open Source for Quantitative Finance and Trading
Username: Password: Not registered?
 
Quick Search:    (AJAX based: No need to press button)

Main : Matlab : 



Sort by:  Title () Date () Rating () Popularity ()
Files currently sorted by: Rating (Lowest Score to Highest Score)


Category: Matlab View Full Details
Download Now!Tutorial on dynamics of constant maturity swap rate
Submitter: vanna Date: 2008/3/17
Description:
This script demonstrates the effect of yield curve movements on net receipts for a constant maturity swap payment, using the example data as mentioned in paperAn Examination of the Convexity Adjustment Technique in the Pricing of Constant Maturity Swaps

Results are matched to the table as mentioned in page 6 of the paper.
Following is output of this program:
Initial yield curve
SwapRate = 0.064820
Libor3Month = 0.063518
NetReceipt = 0.0013021
***********
Parallel shift (up)
SwapRate = 0.065819
Libor3Month = 0.064518
NetReceipt = 0.0013013
***********
Parallel shift (down)
SwapRate = 0.063821
Libor3Month = 0.062518
NetReceipt = 0.0013029
***********
Steepening
SwapRate = 0.070542
Libor3Month = 0.064518
NetReceipt = 0.0060241
***********
Humped yield curve
SwapRate = 0.064861
Libor3Month = 0.063518
NetReceipt = 0.0013433
***********
Inverted yield curve
SwapRate = 0.061059
Libor3Month = 0.063518
NetReceipt = -0.0024587
***********


As can be seen from the above results, the net receipts is not much effected by absolute changes in yield curve , but it is sensistive to the shape and slope of the movements. If the investor believes that the yield curve will steepen he will want to receive the swap rate. If the investor believes that the yield curve will flatten or invert he/she will want to pay the swap rate.


Got a question or problem with this link? Just enter your message and click on submit. No registration is required.

Note: A copy of this message will also be emailed to the submitter of this link
Downloaded 777 times  777  File Size 0 bytes  Supported Platforms Octave Matlab  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (10)

Category: Matlab View Full Details
Download Now!Tutorial and code for Constrained function minimization
Submitter: vanna Date: 2008/3/6
Description:
This file demonstrates a simple transformation one can use to solve a constarined fucntion mimization problem using an existing solver for unconstrained fucntion minimzation.
For example, Octave does not have the constrained version fmincon function while it does have fmins which does not implement any constraints.

Now consider this function to solve for the minima:



Local minima for this function is obtained by transforming the function input parameter to
x=a+(b-a)/(1+exp(-t))


where
t is the function input parameter
a=lower range of constraint
b=upper range of constraint
x=the function variable

Output of running this program:
octave-3.0.0.exe:1> consdemo
**** using unconstrained minimization ****
xmin = -3.9062e-004

**** using constrained minimization ****
a =  0.12000
b =  0.52000
xmin =  0.29690

a =  0.56000
b =  1.1500
xmin =  0.98869

a =  1.4000
b =  1.8000
xmin =  1.6599

Got a question or problem with this link? Just enter your message and click on submit. No registration is required.

Note: A copy of this message will also be emailed to the submitter of this link
Downloaded 765 times  765  File Size 0 bytes  Supported Platforms Octave Matlab  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (8)

Category: Matlab View Full Details
Download Now!Beta process estimation for GM vs DJI index using Kalman Filter
Submitter: vanna Date: 2008/2/25
Description:
This code uses Kalman filtering technique to find stock beta process
It takes as input 2 files:
1.stock prices for GM
2.prices of DJI index

I have used adj. close prices downloaded from Yahoo finance.

The model assumed is described in equation 15 of paper Estimating Value at Risk with the Kalman Filter

Using arbitrary initial values the parameters are computed using maximum likelihood estimation.
In the below figure,
1st graph indicates monthly returns of GM prices
2nd graph shows monthly returns of DJI prices
3rd graph shows time varying beta


Got a question or problem with this link? Just enter your message and click on submit. No registration is required.

Note: A copy of this message will also be emailed to the submitter of this link
Downloaded 1014 times  1014  File Size 0 bytes  Supported Platforms Octave Matlab  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (9)

Category: Matlab View Full Details
Download Now!Maximum Likelihood estimation with Kalman Filter
Submitter: vanna Date: 2008/2/24
Description:
Stock beta is an important parameter used in Financial modelling of time series or Value at Risk estimation.
Here we simulate 3 stochastic processes :
1. market index returns - this becomes an input parameter of observation equation
2. stock returns - this becomes the output of observation equation
3. beta parameter - this is the transition equation

After simulating the processes, we start with some arbitrary initial values and use the equations for Kalman filter maximum likelihood estimation to find out the unknown parameters. The optimizer is used to solve the function minima which gives the estimated parameters. Finally the actual beta process is compared with the beta process estimated though the predictor corrector loop of Kalman filter equations.

In the below figure, red line indicates the beta process that was actually generated from simulation. Green line is the beta process using estimated parameters.

Got a question or problem with this link? Just enter your message and click on submit. No registration is required.

Note: A copy of this message will also be emailed to the submitter of this link
Downloaded 1927 times  1927  File Size 0 bytes  Supported Platforms Octave Matlab  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (11)

Category: Matlab View Full Details
Download Now!Demo for forecasting by Kalman filter
Submitter: vanna Date: 2008/2/22
Description:
This code demonstrates an application of kalman filter for getting the unobservable process.

Intially, series of values are geneated for the 2 processes (observable and unobservable) using the state space equations:

%  State space reprsentation to be forcasted by kalman filter
%   zhi(t+1) = F*zhi(t) + v(t+1)   --> unbobserved varaibles
%   v~N(0,Q)
%   y(t) = A'*x(t) + H'*zhi(t) + w(t)
%   w~N(0,R)



Next, the unobservable process is set aside and rest of all the remaining parameters are fed as input to the kalman filter predictor-corretor algorithm.
At each iteration, the unobserbale process predicted by the filter is noted.
Finally, the graph compares the processes:
Red curve- Original unobesrable process that was used for simulation
Green curve - unobervable process predicted using Kalman filter
Blue curve - observable process

As can be seen, the pupose of Kalman filter in this exercise was to predict the unoservable process green curve and it pretty much moves along with the red curve. Hence Kalman filter is doing a good job in fiding underlying process that was used to generate our observable process.

Got a question or problem with this link? Just enter your message and click on submit. No registration is required.

Note: A copy of this message will also be emailed to the submitter of this link
Downloaded 1799 times  1799  File Size 0 bytes  Supported Platforms Octave Matlab  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (8)
« 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (17) 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 »
Similar Links:

Subscribe to RSS or daily email updates of latest quantitative finance code listings
Email address :
Copyright © 2011 QuantCode Inc. All rights reserved.