# Tagged Questions

Numerical computing environment developed to allow matrix manipulations, plotting of functions and data and implementation of algorithms.

119 views

### Stochastic Volatility CIR estimation

Would anyone have a code (pref. Matlab or R) for any type of estimation (QML, GMM) not using option prices of a stochastic volatility model driven by a CIR process described below? ...
105 views

### How to get around flat likelihood function when calibrating GBM parameters

(Hope this is the correct place for this question - I posted it first on stackoverflow:) I want to calibrate jointly the drift mu and volatility sigma of a geometric brownian motion, ...
24 views

### Aggregate interactive brokers data in matlab

I am using matlab and interactive brokers API. I am getting real time data using tickerID = ib.realtime({ct},'233',@(varargin)ibEventRealTimeData(varargin{:})); where ib is the interface to ...
25 views

I'm trying to find the optimal portfolio of options and stock which minimizes the standard deviation of the portfolio returns but also taking into consideration the bid and ask prices of the assets. ...
292 views

### constrained portfolio optimization by fmincon

I am working through this paper, http://www.nber.org/papers/w8922.pdf I want to implement the portfolio weight constraints see page 6-7. Here is the brief overview of my problem: Let ...
21 views

### Initial values for Heston Model calibration

I'm doing a Heston model in Matlab using simple Monte Carlo simulations (5.000 paths and 2 steps per day, simulating 360 days). When I try to calibrate the Heston parameters using fminsearch it takes ...
18 views

### How to decide if the ARCH coefficient is necessary in the GJR-GARCH model?

I did some analysis for CAC 40, the French market benchmark, for the period 2005-2014, and I tried to fit the data with a GJR(1,1) model in MATLAB. Then some warning showed Lower bound ...
36 views

### Do I need simulink to model the risks of an option portfolio

I wish to buy Matlab Home and learn to model the risks of a derivatives portfolio and then stress test it. So I am guessing I will need : Stochastic calculus Linear algebra Stats/Probability Some ML ...
727 views

### Johansen Cointegration Test

I just performed a Johansen Co-integration test on two stocks. The results I get are: ans = r0 r1 t1 true false I am using Matlab. Can ...
51 views

### How to identify the orders p and q for ARIMA model using least squares method?

I would like to identify the orders p and q for ARIMA model using least squares method in Matlab. I have got also two data files (one with noise and one without) Previously I identified p and q for ...
27 views

### Matlab loop statement is driving me mad [closed]

Can someone please help me out with this loop over here? Matlab simple refuses to consider the for o=k:k-20 statement inside the if statement. :pullingmyhair: ...
172 views

### How to simulate a CIR process using GPU and Matlab

I am trying to simulate a CIR process using Matlab and my GPU for effeciency. At the moment i run into some implementation problems due to the recursive nature of the discretization. The sheme I ...
91 views

### matlab interpretation of johansen cointegration test

I need some help understanding the results of Johansen Cointegration test run on MATLAB. I am quite new to econometrics and do not fully comprehend what MATLAB has come up with. I would be really in ...
33 views

### Interpreting Johansen co integration test

I am a little new to econometrics. Please pardon me for this silly question. I was running a Johansen cointegration test on two time series using the econometrics toolbox provided by James LeSage for ...
126 views

### VIX-implied Volatility calculator

Does anybody know any implied volatility calculator for VIX Options, possibily in Matlab? For Vanilla Options, I'm currently employing this function which is very fast and reliable (much more than ...
151 views

### Regime Switching for Dynamic Correlations

I would like to implement a Regime Switching for Dynamic Correlations in an out-of-sample analysis using MATLAB. After looking at the literature on the subject, they all refer to an article by Denis ...
120 views

### constrained portfolio optimization in matlab

I am working through this paper, http://www.nber.org/papers/w8922.pdf I want to implement the portfolio weight constraints see page 6-7. Here is the brief overview of my problem: Let ...
42 views

### How to estimate constrained a constrained VAR(1) with MATLAB?

Suppose I want to estimate the following VAR(1) model: $$Y_t = \mu + \Phi Y_{t-1} + \varepsilon_t$$ where $Y_t=(y_{1t}, y_{2t},…,y_{kt})'$, $\mu=(\mu_1,…,\mu_{k})’$ and $\Phi$ a matrix of ...
89 views

### What are the parameters of the function PORTVAR in Matlab?

According to the Matlab help, Portvar will give the "Variance for portfolio of assets" by entering the returns of the Assets and the corresponding weight. However, it does not explain the parameters ...
53 views

### Portfolio Performance Metrics

In comparing different long portfolios in stocks for 15 quarters, where at each quarter I re-balance the portfolio. So what I have done is made a function that outputs the rand value of the portfolio ...
103 views

### Equall Risk Contribution and The Most Diversified Portfolio [closed]

I am a master degree student on applied economics at Brazil and my thesis will be about smart beta strategies. I pretend to apply Equal Weigth, Mininum Variance, Most Diversified Portfolio and Equal ...
442 views

### How to calculate the volatility matrix with multiple stocks

calculating the volatility for a single stock is straightforward. However, I'm not sure whether my approach for calculating the volatility matrix for multiple stocks is correct: I assume a log-normal ...
572 views

### Learn backtesting using MATLAB

What are some good ressources (books, articles, ...) to learn backtesting of investment strategies using MATLAB ? It can be strategies related to fixed-income, equities, derivatives, ... whatever. ...
64 views

### Calibration of nested pricing models consistently on two different classes of derivatives

Hi everyone, I'm programming in MATLAB and I have the following optimization problem in calibrating several nested specifications of pricing models. Summary: I have two pricing models ($1$ and $2$, ...
85 views

### Simulate from time-dependent copula in MatLab using COPULARND

I would like to simulate from a t-copula with time-dependent correlation matrices. Say I have a series of 2000 correlation matrices (obtained from a copula-DCC model for data consisting of 2000 ...
75 views

### What is the most elegant way to write a trading (or asset selection) algorithm in MATLAB, based on a simple criterion?

Assume a $T \times N$ matrix $X$ of values for an asset characteristic at time $t \in \{1,2,\dots,T \}$, where $T$ is the observation period in months and $N$ is the number of assets and a ...
89 views

### Interpretation of Cointegration results, pValues and t-Stat

This is a follow up to: Cointegration results interpretation validation? I ran another Engel Granger Test on a pair, The results I get: ...
201 views

### Cointegration results interpretation validation?

Here is how I am interpreting results of a Johansen Cointegration Test and Engel-Granger Test for A and B. The results:(Using matlab) ...
111 views

### formulating MVO with costs

I am trying to formulate this simple MVO utility function with a linear transaction cost penalty added using Quadprog in MATLAB tcost = 0.001; lambda = 4; mu = vector of expected returns (say 4x1) S ...
167 views

### How to combine Gaussian marginals with Gaussian copula to obtain multivariate normals?

in the book "Numerical Methods and Optimization in Finance" I red the following: "Combining the Gaussian copula with Gaussian marginal gives a fancy way of expressing multivariate normals. However, ...
198 views

### Cholesky Decomposition on Correlation Matrix for Correlated Asset Paths

I found a matlab example for modelling correlated asset paths: http://www.goddardconsulting.ca/matlab-monte-carlo-assetpaths-corr.html In this model the author uses the matlab code chol() in order to ...
203 views

### Autoregressive distributed lag models ADL(p,q) howto in preferably matlab (stata/R/python/C# etc)

Could anyone provide me the details of how to determine the lag order of the distributed lags for an ADL(p,q) model in Matlab or another statistical package (and very much preferably in combination ...
87 views

### Handling IQFeed events in Matlab

I need to get some specific market data for my studies, and it seems like the most convenient way for me to do this is to use IQFeed data feed and MATLAB. But unfortunately, since I'm not a seasoned ...
354 views

### SVCJ (SVJJ) Duffie et. al Model implementation in Matlab

I'm attempting to implement aforementioned SVCJ model by Duffie et al in MATLAB. so far without success. It's supposed to price vanilla (european) calls . parameters provided, the expected price is: ...
349 views

### PDF Calculation by Fourier Inversion of Characteristic Function for Affine Intensity Process in Matlab

I'm trying to use the Fourier inversion formula to plot the PDF of an Affine Stochastic Intensity Reduced Form Credit Model, given its characteristic function. The characteristic function of an ...
475 views

### Sampling problem in portfolio optimization

In a summary I am trying to do the following Bond Subset 1 : Get list of USD Bonds --> Filter out Bonds which have YTM > y% DUR > 10 Y etc. .. This gives us Bonds which we are interested in. So ...
36 views

### Engle Granger test returns a 0 in matlab, while correlation factor is .80+. Am I doing something wrong?

Engle Granger test is giving me a ans = 0. The correlation factor is: 0.8+ Does this imply the No cointegration hypothesis is true? i.e. as per my understanding that there is cointegration? I am ...
948 views

### Optimal lag length selection criterion in GARCH(p,q) model using MATLAB

As assessed by the title, I'm trying to estimate a GARCH(p,q) model to forecast stock market volatility and, in order to be able to do that, I've to identify the optimal number of lags, p and q, to ...
169 views

### What are the equation that gives hurst exponent of value >0.7 and <0.3?

I had been working on algorithm which uses the Hurst Exponent. Once i random walk simulation on matlab, x = cumsum(randm(1000,1)), I was able to get a hurst value close to 0.5. To analyze the use of ...
222 views

### Copula Value At Risk

Let's suppose I have two asset in my portfolio. I want to compute Copula Value At Risk. Can you help me? This is the code I wrote: ...
306 views

### How do I simulate stock prices for a 10 asset portfolio, over a period of 10 years in MATLAB? [closed]

If I have given vectors for return and volatility (i.e. I have two 1x10 vectors), and I assume at first that their correlation is 0 (meaning my covariance-variance matrix is just diagonal), how do I ...
372 views

### How can I calculate the Cumulant-Generating Function in Matlab?

Let $M(h)$ be the moment-generating function, then the cumulant generating function is given by $$K(h)=\text{ln}M(h)=\\ =\kappa_1h+\frac{1}{2!}h^2\kappa_2+\frac{1}{3!}h^3\kappa_3+\ldots$$ where ...
177 views

### How can I introduce exogenous variables in the equation of the conditional variance?

Is it possible to introduce dummy variables or explanatory variables in the GARCH variance equation (garchset and garchfit).This is done in the mean (ARMAX) equation through the input 'Regress' in ...
67 views

### how to extract moments of GB from moment generating function?

I'm searching for the moments of geometric brownian motion using the gmm optimization program. the aim is to make the process y(t) of returns follows a normal distribution Are there any packages in ...
674 views

### fetch from yahoo! finance database - varying number of ticks

To test a model with real-life data, I used the fetch-function in matlab to connect to the database of yahoo! finance. My code to try and get 7 different assets' returns is the following: ...
608 views

### Continuous returns for negative roll-adjusted futures data

I've generated roll adjusted notional futures data by adding a roll adjustment to the settlement price then multiplying by contract multiplier through time. For example, for crude oil CL, on 15 March ...
360 views

### Matlab; How to specify Coupon frequency for Interest Rate Swap

I'm trying to price an interest rate swap and would like to change the default coupon payment frequency from 1 a year to 2 or 4 a year. I'm using ...
998 views

### Matlab - Differences between rng and rand

I was trying to run some Monte-Carlo simulations and if I used: rng(seed, 'Twister'); For some reason I would get "Option Values Can not be Negative" errors in the blsimpv function, but if I just ...
I am trying to calculate model free implied volatility $\sigma_{MF}$ for a relative performance index using the following method: \$\sigma_{MF}^2=2\sum_{i} [\frac{C(T,K_{i})}{K_{i}^2} - ...