Tag Info

Hot answers tagged

4

Ah, this is becoming a common question, just in R now. Please look at this [question] (GARCH model and prediction), it has R code to do the prediction. In brief, you keep predicting one day ahead. $\sigma_{t+k}^2 =w+\alpha u_{t+k-1}^2+\beta \sigma_{t+k-1}^2$. You already know $ w,\space \alpha \space and \space \beta $ the starting values are the last ...


3

Your spread does not look similar to the random walk. Many of the observations are the same as the previous observation. This means most of the first differences are zero, which is why the test indicates your series has a unit-root. The current value is very good at explaining what the next value will be.


3

Have a look at fPortfolioBacktest. An example can be found here: https://r-forge.r-project.org/scm/viewvc.php/pkg/fPortfolioBacktest/man/portfolioBacktesting.Rd?view=markup&revision=4086&root=rmetrics Edit: you may want to try backtestPlot(smoothedPortfolios) to visualise the strategy performance.


2

If you wander about the theoretical result of fitting parameters, the book GARCH Models, Structure, Statistical Inference and Financial Applications of FRANCQ and ZAKOIAN provides a step-by-step explanation. I think that it is not a big problem to implement these steps to R.


2

An easy way to perform what you need is do it this way: if your data are daily then : > prices <- data$cl > log_returns <- diff(log(prices), lag=1) would provide you with daily log returns, if you change the $lag=1$ to $lag=5$ then you will get weekly moving log returns.


2

A free to use Excel Add-on providing QuantLib-backed derivatives pricing analytics directly in Excel is available at http://www.deriscope.com Disclosure: answerer is author of the package.


2

You cannot add a date column to an object returned by getSymbols or get.hist.quote. These function return matrices. Matrices can only store data of the same type, in this case the matrices contain double values (real numbers). You can add a column of class Date to the objects if you transform them into a data frame: For getSymbols: library(quantmod) ...


2

To determine the optimal number of states in a HMM is indeed an intricate one. Please have a look at the following paper: The Number of Regimes Across Asset Returns: Identification and Economic Value by M. Gatumel and F. Ielpo (2011) From the abstract: A shared belief in the financial industry is that markets are driven by two types of regimes. Bull ...


2

periodicity calls: p <- median(diff(.index(x))) if (is.na(p)) stop("can not calculate periodicity of 1 observation") p can be NA if x has 1 observation, or if you have missing values in your index (because there's no na.rm=TRUE in the median call. > xx <- xts(1:10, as.POSIXct(c(1:5,NA,7:10),origin='1970-01-01')) > periodicity(xx) Error in ...


1

Are you aware of the findata.org site and its directory? The code is also in a bazaar repository as well as GitHub repo.


1

I like Quantlib http://quantlib.org/index.shtml http://cran.r-project.org/web/packages/RQuantLib/index.html The QuantLib project is aimed at providing a comprehensive software framework for quantitative finance. QuantLib is a free/open-source library for modeling, trading, and risk management in real-life. QuantLib is written in C++ with a clean object ...


1

The mean could be the long run variance which is sig2 = fit.Constant/(1-fit.GARCH{1}-fit.ARCH{1}); I hope this explains. If not, note I ran this model through Matlab, I get different values. you can paste your m1 and m2 values and some other intermediate results so I can see why Matlab differs. EDIT: The question refers to forecasting the returns. ...


1

For the first, people regularly compute VaR or CVaR over time and plot the results. For two and three, the documentation for the ETL function says that you can either calculate it using a Gaussian approach or Cornish-Fisher expansion. These are both analytical methods. The Gaussian approach uses only the mean and variance (effectively assuming that the ...


1

This is the equity line i got after i repeated your code. how is this good ? may be you have run with only one set of numbers. any ways here are a few things you can do to come closer to reality : take the close prices as lognormal distribution instead of a normal distribution. you are adding up the returns later on. this is only right if you have ...


1

There is no guarantee that the optimization method always converges! In an introduction the author of the package recommends using the "hybrid" solver, which starts out with the "solnp" and goes through the other solvers, if it doesn't converge. According to him, this should at least guarantee convergence in 90 % of the cases. ...


1

There are three languages : c++, R , python. Performance wise : c++ > python >> R Packages available : R >> python >> c++ Ease of manual exploratory analysis : R > python >> c++ Ease of adding GUI like features and interactivity: python > c++ >> R Ease of programming small projects : R > python >> c++ Ease of programming large projects : c++ > python ...



Only top voted, non community-wiki answers of a minimum length are eligible