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

SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)

Code Request Page
Requested and Answered by Vanna on 16-Feb-2011 15:17 (19460 reads)
If you are unable to find a piece of code, please enter the details of it in the below edit box.
This page will represent an unsatisfied demand for quantitative finance code, and can be used by anyone planning to volunteer coding for learning and practicing quantitative finance knowledge.


Discuss or give feedback? 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

The comments are owned by the poster. We aren't responsible for their content.

Poster Thread
Anonymous
Posted: 2011/2/16 22:21  Updated: 2011/2/16 22:21
 Code Request Page
I am looking for an implied volatility calculator - saab

Poster Thread
Anonymous
Posted: 2011/2/17 13:54  Updated: 2011/2/17 13:54
 Code Request Page
american option pricer with discrete dividends please..

Poster Thread
Anonymous
Posted: 2011/2/17 21:54  Updated: 2011/2/17 21:54
 Code Request Page
ok, i did it myslef by modifying a file here. uploaded it for the sake of others. cheers.. saab

Poster Thread
Anonymous
Posted: 2011/2/17 21:55  Updated: 2011/2/17 21:55
 Code Request Page
it is in the software section links. enjoy - saab

Poster Thread
Anonymous
Posted: 2011/2/26 9:20  Updated: 2011/2/26 9:20
 Code Request Page
please, I'm looking for codes for pricing ans calculating the delta for european floating strike lookback option. Your help will be greatly appreciated

Poster Thread
Anonymous
Posted: 2011/3/1 11:34  Updated: 2011/3/1 11:34
 Code Request Page
Just want to send props on the great site!


Poster Thread
Anonymous
Posted: 2011/3/6 8:15  Updated: 2011/3/6 8:15
 Code Request Page
Hello Friends,

I have made Garch(1,1) in XLS, but now i would like to do the same process through VBA code, i was able to do all code except
finding MLE by changing three variables (alpha, Beta and Omega). I would be really please if somebody could suggest good optimization code for the same.

Poster Thread
Anonymous
Posted: 2011/3/7 19:30  Updated: 2011/3/7 19:30
 Code Request Page
Stationary wavelet transform in matlab

Poster Thread
Anonymous
Posted: 2011/3/7 19:33  Updated: 2011/3/7 19:33
 Code Request Page
Stationary wavelet transform in matlab, please. Thank you. Les

Poster Thread
Anonymous
Posted: 2011/3/23 8:21  Updated: 2011/3/23 8:21
 Code Request Page
am requesting c# code that optimizes a 7 asset portfolio

Poster Thread
Anonymous
Posted: 2011/3/26 18:34  Updated: 2011/3/26 18:34
 Code Request Page
american call/put option using excel

Poster Thread
Anonymous
Posted: 2011/3/28 3:33  Updated: 2011/3/28 3:33
 Code Request Page
Hi,
I'm looking for a C++ code for CDS pricing.

Poster Thread
Anonymous
Posted: 2011/3/29 17:33  Updated: 2011/3/29 17:33
 Code Request Page
I'm in need of crank nicloson sor european pricing option using c++

Poster Thread
Anonymous
Posted: 2011/4/13 19:36  Updated: 2011/4/13 19:36
 Code Request Page
I was wondering if there is any working code for Malliavin calculus to calculate greeks? I am looking for barriers in particular but any instrument will do

Poster Thread
Anonymous
Posted: 2011/4/25 0:17  Updated: 2011/4/25 0:17
 Code Request Page
C++ algorithmic trading code that checks for updates and then buys or sells depending on the technical indicators.

Poster Thread
Anonymous
Posted: 2011/4/28 18:18  Updated: 2011/4/28 18:18
 Code Request Page
hi guys can am looking for portfolio selection code using the MAD model.will be really great full thanx

Poster Thread
Anonymous
Posted: 2011/5/18 15:15  Updated: 2011/5/18 15:15
 Code Request Page

Poster Thread
Anonymous
Posted: 2011/5/27 5:29  Updated: 2011/5/27 5:29
 Code Request Page
I am looking for a code which does maximum likelihood estimate kalman filter parameters.

Poster Thread
Anonymous
Posted: 2011/6/15 11:43  Updated: 2011/6/15 11:43
 Code Request Page

Poster Thread
Anonymous
Posted: 2011/6/16 22:12  Updated: 2011/6/16 22:12
 Code Request Page
Hi,

I am looking for code for spatial poisson regression. Thanks.

Poster Thread
Anonymous
Posted: 2011/6/24 15:09  Updated: 2011/6/26 13:40
 Code Request Page
Hi, I am looking for a code that calibrates the Garch option pricing model to market prices.

Poster Thread
Anonymous
Posted: 2011/7/1 11:40  Updated: 2011/7/2 12:27
 Code Request Page
Hello, I'am also looking for a code that calibrates the Garch option pricing model to market prices, but I haven't found, I'am trying to do it by myself, if you want us to collaborate : manitou85@hotmail.com

Poster Thread
Anonymous
Posted: 2011/7/6 18:41  Updated: 2011/7/7 15:08
 Code Request Page
Hello, I am looking for Gaussian Copula example for empirical data in Excel.

Poster Thread
ROADRUNNER
Posted: 2011/7/12 6:24  Updated: 2011/7/14 10:48
Just popping in
Joined: 2011/7/12
From:
Posts: 3
 Interest rate simulation
Hi

I am looking for Java code to simulate interest rates using Vasicek model.

Poster Thread
Anonymous
Posted: 2011/12/11 18:10  Updated: 2012/1/28 18:39
 Code Request Page
Excel VBA code to calculate Delta of an American style stock option using the Bjerksund-Stensland option pricing model.

Poster Thread
Anonymous
Posted: 2011/12/14 2:47  Updated: 2012/1/28 18:40
 Code Request Page
I am looking for matlab codes to fit spot rates in term structure.
I have written part of it but it gives me error.plz help
n=5;
k=3;
m=33;
ti= [-5 -3 -1 0 15 24 28 32];
for p=1:n+k
for m=1:h
sum=0;
for i=p:p+k+1
prod=1;
if t(m)<=ti(i)
sum=sum;
else
for j=p:p+k+1
if j~=i
prod=(1/(ti(j)-ti(i)))*prod;
end
end
sum=sum+(prod*(t(m)-ti(i))^k);
end
end
B(p,m)=sum;
end
end

%to calculate D3
for m=1:h
for p=1:n+k
D3(m,p)=(-t(m))*B(p,m);
end
end
%to estimate lambda3
lambda3=D3\log(inv(C)*Q)

Poster Thread
Anonymous
Posted: 2012/1/9 9:52  Updated: 2012/1/28 18:40
 Code Request Page
Looking for the best model to price very short term (30 to 1 minute, expiring) American options.

Poster Thread
Anonymous
Posted: 2012/1/19 21:25  Updated: 2012/1/28 18:40
 Code Request Page
i am looking for code to run augmented dickey fuller test in microsoft access. thanks for your help in advance.

Poster Thread
Anonymous
Posted: 2012/3/17 2:36  Updated: 2012/3/18 11:03
 Code Request Page
hi
i am looking for code of credit risk estimation by KMV models
thanks

Poster Thread
Anonymous
Posted: 2012/4/23 9:48  Updated: 2012/5/6 19:17
 Code Request Page
program an coding of Minimize PAPR(peak to average ratio) using parametric minimum cross entropy method

Poster Thread
Anonymous
Posted: 2012/4/23 9:51  Updated: 2012/5/6 19:16
 Code Request Page
program with matlab codes for Minimize peak to average ratio using parametric minimum cross entropy methods

Poster Thread
Anonymous
Posted: 2012/5/3 13:30  Updated: 2012/5/6 19:14
 Code Request Page

Poster Thread
Anonymous
Posted: 2012/5/12 6:22  Updated: 2012/5/12 16:22
 Code Request Page
Hello,

I am trying to implement a Kalman Filter- MLE approach in Matlab. I have written a code, but it gives a lot of errors:
function[L] = kalmanFilter1(params)
global Z;
k=6;
T = size(Z,2);
n = size(Z,1);
F=zeros(k,k);
delta=ones(k,1);
S=diag(delta);
V=zeros( k, k, T);
%Vm=zeros(k,k,T);
xhat=zeros( k, T);
%xhatm=zeros(k,T);
%params A matrix
beta1=params(1);
beta2=params(2);
beta3=params(3);
beta4=params(4);
beta5=params(5);
gamma1=params(6);
gamma2=params(7);
gamma3=params(8);
gamma4=params(9);
gamma5=params(10);
A=[beta1, gamma1, 0, 0, 0, 0;...
beta1, gamma1, 0, 0, 0, 0;...
beta2, 0, gamma2, 0, 0, 0;...
beta2, 0, gamma2, 0, 0, 0;...
beta2, 0, gamma2, 0, 0, 0;...
beta3, 0, 0, gamma3, 0, 0;...
beta3, 0, 0, gamma3, 0, 0;...
beta3, 0, 0, gamma3, 0, 0;...
beta4, 0, 0, 0, gamma4, 0;...
beta4, 0, 0, 0, gamma4, 0;...
beta4, 0, 0, 0, gamma4, 0;...
beta5, 0, 0, 0, 0, gamma5;...
beta5, 0, 0, 0, 0, gamma5;...
beta5, 0, 0, 0, 0, gamma5;...
beta5, 0, 0, 0, 0, gamma5];

%params a
a1=params(11);
a2=params(12);
a3=params(13);
a4=params(14);
a5=params(15);
a6=params(16);
a7=params(17);
a8=params(18);
a9=params(19);
a10=params(20);
a11=params(21);
a12=params(22);
a13=params(23);
a14=params(24);
a15=params(25);
for i=1:T
a(1,i)=a1;
a(2,i)=a2;
a(3,i)=a3;
a(4,i)=a4;
a(5,i)=a5;
a(6,i)=a6;
a(7,i)=a7;
a(8,i)=a8;
a(9,i)=a9;
a(10,i)=a10;
a(11,i)=a11;
a(12,i)=a12;
a(13,i)=a13;
a(14,i)=a14;
a(15,i)=a15;
%params rho
rho1=params(26);
rho2=params(27);
rho3=params(28);
rho4=params(29);
rho5=params(30);
rho=[rho1, rho1, rho2, rho2, rho2, rho3, rho3, rho3, rho4, rho4, rho4, rho5, rho5, rho5, rho5];
W=diag(rho);

if n~=size(A,1)
error('Dimension error - A & Z must agree.');
end

if (n~=size(W,1) || n~=size(W,2))
error('Dimension error - W is not valid covariance matrix.');
end

if (k~=size(F,2))
error('Dimension error - F not square.');
end

if (k~=size(A,2))
error('Dimension error - F & A do not agree.');
end

if (k~=size(S,1) || k~=size(S,2))
error('Dimension error - S is not valid.');
end


% Initialize log-likelihood
L = 0;


for i = 1:T
% Time update
if i==1
xhatm = F*x0 ;
Vm= F*V0*F' + S;
else
xhatm = F*xhat ;
Vm = F*V*F' + S;
end

% Correction
H = A*Vm*A' + W;
K = Vm* A'*inv(H);
xhat= xhatm+ K*(Z(:,i)- A*xhatm-a);
V= (eye(k) - K*A)*Vm';

%xfilt(:,i) = xhat(:,i);
%Vfilt = V;
%Vmfilt = Vm;

% Update log likelihood
L = L -(n/2)*log(2*pi) - .5 * log( abs(det(H)) ) -.5*(( Z(:,i) - a - A*xhatm )'*inv(H)*( Z(:,i) - a - A*xhatm ));
end
L=L*(-1);
end

Then I try to minimize the negative log likelihood function by:
load DAT2.dat;
Z=DAT2;
T = size(Z,2);
n = size(Z,1);
k = 6;
xo=ones(k,T);
V0=zeros(k,k);
F=zeros(k,k);

delta=ones(k,1);
S=diag(delta);
%params
params=[0.0548, 0.0760, 0.0564, 0.0694, 0.0839, 0.0214, 0.0001, 0.0305, 0.0001, 0.0476, 0.0113, 0.0070, 0.0059, 0.0063, 0.0099, 0.0019, 0.0152, 0.0092, 0.0091, 0.0039, 0.0073, 0.0034, 0.0139, 0.0065, 0.0128, 0.0671, 0.0716, 0.0623, 0.0728, 0.1069];

x0=params;
L=0

%optimize
options=optimset('MaxIter',10000,'MaxFunEvals',10000);
[A, a, rho]=fminsearch('kalmanFilter1',x0,options);

The following errors were generated:
Error in ==> kalmanFilter1 at 2
global Z;

??? Output argument "L" (and maybe others) not assigned during call to "C:\Documents and Settings\Izabela\My Documents\MATLAB\kalmanFilter1.m
(kalmanFilter1)".

Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});


Can you please help? This is really urgent,any suggestion or ideas will be greatly appreciated.

Poster Thread
Anonymous
Posted: 2012/10/29 17:41  Updated: 2012/11/18 13:35
 Code Request Page
"incremental risk charge"

Poster Thread
Anonymous
Posted: 2012/11/15 19:16  Updated: 2012/11/18 13:35
 Code Request Page
bayesian beta

Poster Thread
Anonymous
Posted: 2012/11/20 4:29  Updated: 2012/12/14 22:24
 Code Request Page
Hi, I would like to model the implied volatility distribution of Dupires (local volatility model) versus Black Scholes (implied volatility). How can I do that with the intention of comparison? mzhkust@gmail.com

Poster Thread
Anonymous
Posted: 2013/1/24 9:31  Updated: 2013/2/10 12:53
 Code Request Page
Hi, I am looking for matlab code of how to calculate the price of a capital protected structured note with a call option. email: mzhkust@gmail.com

Poster Thread
Anonymous
Posted: 2013/5/22 18:16  Updated: 2013/6/2 21:19
 Code Request Page
pricing of vanilla call options granted by average payoff at maturity

Discuss or give feedback? 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
Similar Links:
Copyright 2011 QuantCode Inc. All rights reserved.