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

Main : C++ : 



Sort by:  Title () Date () Rating () Popularity ()
Files currently sorted by: Date (New Files Listed First)


Category: C++ View Full Details
Download Now!Integral of a function in C
Submitter: vanna Date: 2009/1/27
Description:
This function GetIntegrationResult returns result of inegral of a function.

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 506 times  506  File Size 0 bytes  Supported Platforms C, C++, Visual C++ 2005 express  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: C++ View Full Details
Download Now!Demo for minimizing function with Adaptive Simulated Annealing (ASA)
Submitter: vanna Date: 2009/1/23
Description:
Adaptive simulation annealing is an algorithm developed by Lester Ingber to find global minimization of a function. For more detailed information about the algorithm and it's usage, please refer to the author's Author's website

The attached script here is a demo for minimizing this simple function with 3 parameters:
f(x)=(x1+1)^2 + (x2-2)^2 + (x3+3)^ + 552
Using ASA code to do this is like killing a fly with a shotgun, but nevertheless the purpose here is to make user familiar with usage of the function.

Following are steps to do minimize the function:

1.Create a project to use ASA as mentioned in How do I get started with Adaptive Simulated annealing (ASA)?
2.Download file asa_usr_cst.c from the above link and replace the file in current project. This file has implementation of the new function.
3.Modify file asa_opt in current project.
Change this portion of code:
number_parameters=*parameter_dimension			4

Param#:Minimum:Maximum:InitialValue:Integer[1or2]orReal[-1or-2]
0	-10000	10000	999.0			-1
1	-10000	10000	-1007.0			-1
2	-10000	10000	1001.0			-1
3	-10000	10000	-903.0			-1


Replace it with this code:
number_parameters=*parameter_dimension			3

Param#:Minimum:Maximum:InitialValue:Integer[1or2]orReal[-1or-2]
0	-10000	10000	999.0			-1
1	-10000	10000	-1007.0			-1
2	-10000	10000	1001.0			-1


4.Run the program.
5.Read output result in asa_usr_out file
exit code = 1
final cost value =          552
parameter	value
0		  -0.9998934
1		    1.999928
2		   -3.000056


As can be seen, result is close correct values of (-1,2,-3)

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 525 times  525  File Size 0 bytes  Supported Platforms Visual C++ 2005 express  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: C++ View Full Details
Download Now!Asian option price using Alternating Direction Implicit (ADI)
Submitter: vanna Date: 2008/8/11
Description:
This file demonstrates applciation of Alternating direction Implicit finite difference method to solve call option price of an arithmetic average fixed strike asian option. It also demonstartes superior stability in comparing to implicit or explicit methods

For the spatial grid assume the following 2 axes:
S=stock price
A=Arithmetic average of stock price


Notes:
1. Upwind scheme is used to discretize the asian option PDE as mentioned in eqns 12-15 of paper Efficient Pricing of an Asian Put Option Using Stiff ODE Methods
2. First half timestep implements S explcit and A implicit. While next half timestep has S implicit and A explicit.
3. A simple Gauss siedel mehtod is used to do Finite difference for each set of equations.
4. Environment is based on using GSL library on Visual Studio 2005 C++ express. To setup GSL and VS 2005 pl. refer How do I use GSL on Visual C++ 2005 express?
5. The result is tested by comparing data from Asian Option price using Monte carlo simulation
following are some test results:
double S0=100; //Spot price (S0)
double K=100; // option strike
double sigma=0.15; //volatility
double r=0.05; //Risk free rate [r]
double T=1; //Maturity of Option in years (T)

MC option price=4.7315
FD option price=4.77736


double S0=100; 
double K=100; 
double sigma=0.2; 
double r=0.1; 
double T=1; 

MC option price=7.1027
FD option price=7.1315



6.ADI method has superior convergence as compared to pure implicit method. For example, the pure 2D implicit method implementation Asian Option Price using 2D Finite Difference Method
works for sigma=0.15 and sigma=0.25 but blows up for sigma=0.5. While ADI method seems to be close enough.

double S0=100; 
double K=100; 
double sigma=0.5; 
double r=0.1; 
double T=1; 

MC option price=13.2946
FD option price=13.3061


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 953 times  953  File Size 0 bytes  Supported Platforms C++ GSL Visual Studio 2005  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (17)

Category: C++ View Full Details
Download Now!American option price using Andersen's method
Submitter: vanna Date: 2008/8/9
Description:
Calculates option price using Andersen's method in the GSL C++ framework.

Reuslts can be compared by setting same parameters to CRR Tree or LSM Method

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 1135 times  1135  File Size 0 bytes  Supported Platforms   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: C++ View Full Details
Download Now!Asian Option Price using 2D Finite Difference Method
Submitter: vanna Date: 2008/8/8
Description:
This file demonstrates using a 2D finite difference method to solve call option price of an arithmetic average fixed strike asian option.

Notes:
1. Upwind scheme is used to discretize the asian option PDE as mentioned in eqns 12-15 of paper Efficient Pricing of an Asian Put Option Using Stiff ODE Methods
2. Implicit scheme is used for time stepping.
3. A simple Gauss siedel mehtod is used to do Finite difference.
4. Environment is based on using GSL library on Visual Studio 2005 C++ express. To setup GSL and VS 2005 pl. refer How do I use GSL on Visual C++ 2005 express?
5. The result is tested by comparing data from Asian Option price using Monte carlo simulation
following are some test results:
double S0=100; //Spot price (S0)
double K=100; // option strike
double sigma=0.15; //volatility
double r=0.05; //Risk free rate [r]
double T=1; //Maturity of Option in years (T)

MC option price=4.7315
FD option price=4.77732


double S0=100; 
double K=100; 
double sigma=0.2; 
double r=0.1; 
double T=1; 

MC option price=7.1027
FD option price=7.12212


6.This technique is not stable for all parameter constellations and requires satisfaction of Peclet condition. eg., results become unrelaible around or after volatility=0.5. (Van leer's flux limiter finite volume method is supposedly more accurate)

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 1648 times  1648  File Size 0 bytes  Supported Platforms C++ GSL Visual Studio 2005  Home Page http://www.quantcode.com/
Rating: 0.00 (0 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (3)
« 1 2 3 (4) 5 6 7 8 9 10 11 »
Similar Links:

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