It is important for choosing method for the time propogating.
1. Explicit schemes are easily to implement, do not suffer from oscillation problems but are only conditionally stable.
2. Implicit schemes are also oscillation-free, unconditionally stable but only first-order accurate.
3. The Crank–Nicolson scheme is (theoretically) second-order accurate but it is well known that it produce spurious oscillations and spikes near the strike price, barriers and monitoring points.
4. Hybrid method. Such as in Rannacher (1984) it uses fully implicit
Euler for the first few time steps and Crank–Nicolson after that. The scheme is stable, firstorder accurate and is oscillation-free. And use Richardson extrapolation in combination with implicit Euler (Gourlay, 1980). The resulting
scheme is stable, second-order accurate and again oscillation free.
5. Function smooth.1) Projecting the initial condition onto a set of basis functions
6. One can combine smoothing and the Rannacher method to get a stable, second-order accurate and oscillation-free finite difference scheme
Saturday, October 13, 2007
Friday, October 12, 2007
Note 12: Finite difference approach to solve Heston model(1)
1) By Ito formula, it is easy to write down the PDE for
Heston model
2) The inmportant thing is the boundary condition
s->0 s-> infinity, u->0 u-> infinity
a) For European call option
we have s->0 U=0 u-> infinity U=S
u=0, we solve the PDE separatly which can be regarded a boundary
s-> infinite , Let us use U'=1(linear boundary condition)
b)For European call option
we have s->0 U=K u-> infinity U=0
u=0, max(K-S,0)
s-> infinite , Let us use U'=0(linear boundary condition)
c) we can have some other conditions
3) Numerical method for Heston model
Let us give basic introduction to the numerical procedure
1) Create Mesh
2) Define initial condition
3) update the boundary conditions for time level n+1 first at time level n
4) Propogate the state at time level n to time level n+1
5) Iterative Until the time is ended.
Heston model
2) The inmportant thing is the boundary condition
s->0 s-> infinity, u->0 u-> infinity
a) For European call option
we have s->0 U=0 u-> infinity U=S
u=0, we solve the PDE separatly which can be regarded a boundary
s-> infinite , Let us use U'=1(linear boundary condition)
b)For European call option
we have s->0 U=K u-> infinity U=0
u=0, max(K-S,0)
s-> infinite , Let us use U'=0(linear boundary condition)
c) we can have some other conditions
3) Numerical method for Heston model
Let us give basic introduction to the numerical procedure
1) Create Mesh
2) Define initial condition
3) update the boundary conditions for time level n+1 first at time level n
4) Propogate the state at time level n to time level n+1
5) Iterative Until the time is ended.
Thursday, October 11, 2007
Note 11: How to solve parital integro differential equation(PIDE)
In BS formalism, we know V_t=LV which is a partial differential equation. However, if we included jump
as Merton model, our equation changes to V_t=LV+I(V),
I(V) means an integration term. So now it is PIDE.
1) How to deal with the integration term
* FFT evaluation
* a) Interpolate the discrete values to equal space (Or using unequal space FFT evaluation, it is costly) b) after the result, interpolate back...
The reason is that we usually use unequally spaced gird in S coordinates as near the strikes and barriers we use small mesh.
* For avoid “wrap around pollution”, use linear extrapolation to extend the Smax, Smin.
2) For each step, after getting the value of integration, we can boost the calculation using Fix point interation et al. to use the PDE in this step.
as Merton model, our equation changes to V_t=LV+I(V),
I(V) means an integration term. So now it is PIDE.
1) How to deal with the integration term
* FFT evaluation
* a) Interpolate the discrete values to equal space (Or using unequal space FFT evaluation, it is costly) b) after the result, interpolate back...
The reason is that we usually use unequally spaced gird in S coordinates as near the strikes and barriers we use small mesh.
* For avoid “wrap around pollution”, use linear extrapolation to extend the Smax, Smin.
2) For each step, after getting the value of integration, we can boost the calculation using Fix point interation et al. to use the PDE in this step.
Sunday, October 7, 2007
Use SAS to fit the ARIMA model with the Box-Jenkins methodology
proc arima data=test;
by id
identify var=trend scan;
run;
estimate p=2 q=1 ;
run;
forecast
lead=10 out=predicttrend printall;
run;
quit;
by id
identify var=trend scan;
run;
estimate p=2 q=1 ;
run;
forecast
lead=10 out=predicttrend printall;
run;
quit;
Note 10: Detailes for the usage of QuantLib Calendar Class
When we deal with real business time, it is no more simple time interval calculation between two different time. And one need to use the business day calculation. In principle, it is extremely simple and just needs basic level of programming. However, it is tedious for a quant working in this convention. So Let us borrow others.
Date todayDate(15, May, 1998);
Date settlementDate(17, May, 1998);
Date startDate(18,May,1998);
Date maturity(17, May, 1999);
// We use the Holidays setting for the stock exchange in NYSE
// Market { Settlement, NYSE, GovernmentBond, NERC }@USA
Calendar calendar = UnitedStates();
// Calculate the business day between
int btimeinterval=calendar.businessDaysBetween(startDate,maturity);
// Calculate the day between
DayCounter daycount = Actual365Fixed();
int timeinterval=daycount.dayCount(startDate,maturity);
std::cout << "SettlementDate = " << settlementDate << std::endl;
std::cout << "StartDate = " << startDate << std::endl;
std::cout << "Maturity = " << maturity << std::endl;
std::cout << "Total business days= "<< btimeinterval << std::endl;
std::cout << "Totaldays= "<< timeinterval << std::endl;
Date startDate01 = calendar.advance(settlementDate,Period(1,Days));
Date maturity01 = calendar.advance(settlementDate,Period(1,Years));
std::cout << "SettlementDate = " << settlementDate << std::endl;
std::cout << "StartDate = " << startDate01 << std::endl;
std::cout << "Maturity = " << maturity01 << std::endl;
Date todayDate(15, May, 1998);
Date settlementDate(17, May, 1998);
Date startDate(18,May,1998);
Date maturity(17, May, 1999);
// We use the Holidays setting for the stock exchange in NYSE
// Market { Settlement, NYSE, GovernmentBond, NERC }@USA
Calendar calendar = UnitedStates();
// Calculate the business day between
int btimeinterval=calendar.businessDaysBetween(startDate,maturity);
// Calculate the day between
DayCounter daycount = Actual365Fixed();
int timeinterval=daycount.dayCount(startDate,maturity);
std::cout << "SettlementDate = " << settlementDate << std::endl;
std::cout << "StartDate = " << startDate << std::endl;
std::cout << "Maturity = " << maturity << std::endl;
std::cout << "Total business days= "<< btimeinterval << std::endl;
std::cout << "Totaldays= "<< timeinterval << std::endl;
Date startDate01 = calendar.advance(settlementDate,Period(1,Days));
Date maturity01 = calendar.advance(settlementDate,Period(1,Years));
std::cout << "SettlementDate = " << settlementDate << std::endl;
std::cout << "StartDate = " << startDate01 << std::endl;
std::cout << "Maturity = " << maturity01 << std::endl;
Subscribe to:
Comments (Atom)