Apr
3

Another excel / VBA source for volatility calculation, including option based volatility such as implied volatility of Black Scholes model, volatility surface construction, Heston parameters estimation from option prices, etc; and a list of time series volatility calculation, for example, ARCH, ARIMA, EGARCH, EWMA, GARCH, GJR...

One thing you should be aware is some of the files involve a call to NAG library, one of the major benefits of the NAG Library is its inherent flexibility, it can be used by programmers developing in traditional languages, or by users of modern software packages and programming environments, like Microsoft Excel. Both of my former company and my current university have NAG library installed, so download & read more at your choice at http://php.portals.mbs.ac.uk/SerHuangPoon/Teaching/DataandProgrammes/tabid/973/Default.aspx and http://www.nag.co.uk/numeric/nagandexcel.asp

One thing you should be aware is some of the files involve a call to NAG library, one of the major benefits of the NAG Library is its inherent flexibility, it can be used by programmers developing in traditional languages, or by users of modern software packages and programming environments, like Microsoft Excel. Both of my former company and my current university have NAG library installed, so download & read more at your choice at http://php.portals.mbs.ac.uk/SerHuangPoon/Teaching/DataandProgrammes/tabid/973/Default.aspx and http://www.nag.co.uk/numeric/nagandexcel.asp

Mar
31

Visual Basic in finance application has been introduced many times in this blog, one especially useful book was reviewed in an old post Option Pricing Models and Volatility Using Excel-VBA. Here is another

at the moment the number of VBA codes is only a few, some useful files include:

Swaps Tool: Comprehensive tool to manage equity swap resets and set up new deal templates

Dividend Points: Retrieves Index Weights and Dividends Data from Bloomberg and Calculates Index Dividend Points

CA Tool: Dividends and Corporate Actions notification tool

Volatility: Building Volatilty Surface and using the SABR model for calibration

Trading Tool: Simple tool to set buy/sell targets and track prices and dividends

Visit the site if you are looking for

**VBA finance**site perhaps of your interest. As the site describes:The purpose of this site is to provide financial professionals with VBA code snippets and complete projects that can be useful in their work and development.

Our portfolio includes examples of:

* Data Extraction from different sources like Bloomberg and Reuters, internet sites like Yahoo and CBOE and financial systems like Murex

* Incorporating email capabilities with the VBA code which can be very useful when distributing reports on a frequent basis

* User defined functions and general topics like Add-ins, User Forms, utilizing the memory effectively, working with databases, etc ...

* VBA overview, syntax, keywords, classes

* Some useful Windows API functions and how to employ them

* Complete projects utilizing some of the examples above

Our portfolio includes examples of:

* Data Extraction from different sources like Bloomberg and Reuters, internet sites like Yahoo and CBOE and financial systems like Murex

* Incorporating email capabilities with the VBA code which can be very useful when distributing reports on a frequent basis

* User defined functions and general topics like Add-ins, User Forms, utilizing the memory effectively, working with databases, etc ...

* VBA overview, syntax, keywords, classes

* Some useful Windows API functions and how to employ them

* Complete projects utilizing some of the examples above

at the moment the number of VBA codes is only a few, some useful files include:

Swaps Tool: Comprehensive tool to manage equity swap resets and set up new deal templates

Dividend Points: Retrieves Index Weights and Dividends Data from Bloomberg and Calculates Index Dividend Points

CA Tool: Dividends and Corporate Actions notification tool

Volatility: Building Volatilty Surface and using the SABR model for calibration

Trading Tool: Simple tool to set buy/sell targets and track prices and dividends

Visit the site if you are looking for

**VBA finance**codes.
Mar
16

Often we have to face the problem of

M files:

more can be downloaded at here.

**solving a stochastic differential equation**, and even more often there is no analytic solution, in another words,**numerical monte carlo simulation**is applied. I don't need to write much about this topic as here is a fantastic paper on it already: An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations, in which the author builds around 10 MATLAB programs, and the topics covered include stochastic integration, the Euler–Maruyama method, Milstein’s method, strong and weak convergence, linear stability, and the stochastic chain rule.M files:

**Euler–Maruyama method**: http://personal.strath.ac.uk/d.j.higham/em.m**Milstein’s method**: http://personal.strath.ac.uk/d.j.higham/milstrong.mmore can be downloaded at here.

Mar
12

Could any R expert here help me to vectorize my for loop? Thanks in advance for your favor. The reason I am in trouble is the variable inside my "for" function are updated after each loop, which makes me feel difficult to use lapply, sapply or whatever.

Simplifed codes are listed below:

The point is how to vectorize the for loop while allowing AdjS and VarS to be updated. I appreciate your help.

Simplifed codes are listed below:

for (i in 1:N) { #N could be a large number, AdjS and VarS are initially given and updated for each i

PredS <- F %*% AdjS

PredY <- H %*% PredS

PredError <- (Y[i,] - t(PredY))

VarY <- (H %*% VarS) %*% t(H)

InvVarY <- solve(VarY)

KG <- (VarS %*% t(H)) %*% InvVarY

AdjS <- PredS + PredError

VarS <- (diag(3) - KG %*% H) %*% VarS

ll[i] <- PredError %*% InvVarY %*% t(PredError)

}

PredS <- F %*% AdjS

PredY <- H %*% PredS

PredError <- (Y[i,] - t(PredY))

VarY <- (H %*% VarS) %*% t(H)

InvVarY <- solve(VarY)

KG <- (VarS %*% t(H)) %*% InvVarY

AdjS <- PredS + PredError

VarS <- (diag(3) - KG %*% H) %*% VarS

ll[i] <- PredError %*% InvVarY %*% t(PredError)

}

The point is how to vectorize the for loop while allowing AdjS and VarS to be updated. I appreciate your help.

Feb
25

I am not a fan of Markov Regime switching model, it is hard for me to really define how high is a high regime, or how low is a low regime, let alone the method to detect the regime switch. In case you like it, here is a good package for

Features of the package:

- Support for univariate and multivariate models.

- Support of any number of states and any number of explanatory variables.

- Estimation, by maximum likelihood, of any type of switching setup for the model. This means that you can choose which coefficients in the model, including distribution parameters, are switching states over time.

- A wrapper function for the estimation of regime switching autoregressive models, including multivariate case (MS-VAR) is included in the package.

- The values of standard error for the estimated coefficients can be calculated with 2 different methods.

- Includes a C version of hamilton’s filter that may be used for speeding up the estimation function (see pdf for details).

- Possibility of three distinct distribution assumptions for residual vector (Normal, t or GED).

- Support for reduced/constrained estimation (see pdf document for details).

**Markov Regime Switching Models in Matlab**, it provides functions for estimation, simulation and forecasting of a general Markov Regime Switching Regression.Features of the package:

- Support for univariate and multivariate models.

- Support of any number of states and any number of explanatory variables.

- Estimation, by maximum likelihood, of any type of switching setup for the model. This means that you can choose which coefficients in the model, including distribution parameters, are switching states over time.

- A wrapper function for the estimation of regime switching autoregressive models, including multivariate case (MS-VAR) is included in the package.

- The values of standard error for the estimated coefficients can be calculated with 2 different methods.

- Includes a C version of hamilton’s filter that may be used for speeding up the estimation function (see pdf for details).

- Possibility of three distinct distribution assumptions for residual vector (Normal, t or GED).

- Support for reduced/constrained estimation (see pdf document for details).