Tag Info

Hot answers tagged

10

This is interesting because I see another trend: Matlab is being replaced by R, but I guess this is another story. I use R for my academic (I am also teaching this stuff) as well as my consulting work (I am mainly working in the $\mathbb{P}$ area, with some excursions into $\mathbb{Q}$). I tried Python but it didn't work for me. I think the main reasons I ...


8

I've used both R and Python with Pandas in a professional quantitative financial work to do both large and small scale projects. I would strongly recommend Python with Pandas over R for most new projects in the field especially in time series analysis. While I don't dispute vonjd in that you will find more libraries in R with algorithms on the bleeding ...


7

My deal is HFT so what I care about is read/load data from file or DB quickly in memory perform very efficient data-munging operations (group,transform) visualize easily the data I think is is pretty clear that 3. goes to R, graphics and ggplot2 and others allow you to plot anything from scratch with little effort. About 1. and 2. I am amazed reading ...


6

For data analysis, particularly for large data analysis project, pretty much most of the top quant hedge funds and a lot of the banks are using Python (over R) for a couple of reasons, although many still have bits and pieces of R for specific packages or functions (I work at a bank and interface with quite a few quant hedge funds on data analysis): ...


4

The NS model should be fit directly to bond prices. If you have the prices of all the Treasuries, you should use those directly. See this paper for how the Fed does it http://www.federalreserve.gov/pubs/feds/2006/200628/200628pap.pdf The "Daily Treasury Yield Curve Rates" are already fitted par yields (they're fitted using a cubic spline model to on-the-run ...


4

If you can add linear constriants (as you can do in quadprog) then you can formulate $w \mu = c_1$ as linear constraint, no matter what $\mu$ is (and first delete it from the objective by setting the parameter to zero. The only problem is the one norm. Let my clarify, this is: $$ \sum_{i=1}^n |w_i| < c_2 $$ Thus you allow for short sales but you want to ...


3

You can use Matlab too, that, in my humble opinion, is simpler than R from a syntax point of view. The model you need for is run by the Matlab function arima that can be used with seasonality option to do what you have to do. Here you can find an example and a brief explanation of the model. Type ctrl + F and search for: "Specify a seasonal ARIMA model" ...


3

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.


3

Answering my own question as it could be useful for others. Actually package fOptions is vectorized. The only constraint (and that make sense) is that you can't compute at the same time 2 different greeks, or mix up calls and puts. So assuming that you want to compute the delta of a set of puts, the code will be the following: ...


2

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. ...


2

7 years ago I had to solve the problem of a efficiency frontier under linear constraints on the asset weights and also stumbled upon Markowitz Critial Line Algorithm. I still have a directory with some resources in it. Since Bryce already gave a practical implementation with R code by Eric Zivot, I will concentrate on some papers which might help. I ...


2

PortfolioAnalytics, has the ability to optimize portfolios based on factors or whatever groups/characteristics you enter. https://r-forge.r-project.org/R/?group_id=579 Please refer to the vignette in the package in the package PortfolioAnalytics (https://r-forge.r-project.org/scm/viewvc.php/pkg/PortfolioAnalytics/vignettes/?root=returnanalytics I use it ...


2

I would suggest you to add spreads to the implied hazard rates, spreads that you regress on the macroeconomic factors. Then you stress by calculating the spreads corresponding to the stressed factors.


2

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


2

I'm going to separate your question in two. The key thing you're asking is that how does Return.rebalancing treat your different frequencied and number of asset return and weight objects. Data munging: It subsets the first ncol(weight) columns of R (as ncol(edhec) > ncol(weights) ncol R is now 11. Checks if the first date in R is less than the first date ...


2

Actually, neither of your two results are quite correct. As explained in the Details for the Return.calculate function, most of the PerformanceAnalytics functions use discrete returns, not log returns. To get the correct results, you will have to convert your data from log returns to simple returns. Compare the charts from the following: ...


2

The documentation of the R package PerformanceAnalytics provides examples for both the Return.annualized() and Return.cumulative() functions. The annualized return scales up sub-annual returns to an annual return. You may observe the difference by typing Return.annualized (without any parameters) in your R console to see the functions implementation. Look ...


2

Use PortfolioAnalytics See my previous response here: http://quant.stackexchange.com/a/16002/2154 , you will find links to the documentation there. You can use the constraint function to add a factor exposure constraint of 0. use add.constraint(your_portfolio_name,type='factor_exposure',B = your_vector_of_betas,lower=0,upper=0)


2

You can do this using the optim function in R. One possible solution is as follows: base <- c(0.9190, 0.0739, 0.0072, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0113, 0.9126, 0.0709, 0.0031, 0.0021, 0.0000, 0.0000, 0.0000, 0.0010, 0.0256, 0.9119, 0.0533, 0.0062, 0.0021, 0.0000, 0.0000, 0.0000, 0.0021, 0.0536, 0.8794, ...


2

Looking at your code, you seem to be mixing the risk minimization formulation of the mean-variance problem with the risk aversion formulation. Both formulations include the "budget" constraint, that the sum of the weights equal 1, and can require that each of the weights be greater than zero, the "long-only" inequality constraints. In the risk minimization ...


2

For a Ornstein-Uhlenbeck process, the maximum likelihood parameters are the ones from least squares regression. If your process is: $$ dX=\kappa (\theta-X)dt+\sigma dW $$ you can do a linear regression in the form $$ \frac{dX}{dt}=a+bX+\epsilon $$ So your parameters will be: $$ \kappa=-b $$ $$ \theta=-\frac{a}{b} $$ $$ \sigma=std(\epsilon dt) $$


2

Similar to Juan Gil's answer but a bit differently I would say the following based on this: The OU process $$dX_t = \kappa(\theta-X_t)dt + \sigma dW_t$$ can be (Euler-Maryuama discretization) discretized at times $n \Delta t,n=1,\ldots,\infty $ which gives with $t = k \Delta t$ $$ X_{k+1} - X_k = \kappa \theta \Delta t -\kappa X_k \Delta t + \sigma (W_{k+1} ...


2

Both R and Python can do this very nicely. For Python you would need the pandas package and its dependencies. pandas has a lot of basic statistics, but for more advanced statistics like it looks like you want to do, you can use the statsmodels package, which can work directly with pandas data types. It can also download the csv files directly off the ...


2

R package TTR has rolling window algorithms and understands day counting etc. It stands on the shoulders of xts (which extends zoo) and quantmod


2

There are a couple of issues with your example. First, for this ticker, there is a problem with the Yahoo price data for the period 2014-11-26 through 2014-12-03 in which the prices drop about 80% and then return to their trend line. This appears to be related to a stock split which Yahoo isn't handling properly and isn't real. Its causing part of your ...


2

In the paper you cited in the question, the equation (1) is not the equation of state in kalman filter model, but an $AR(3)$ estimated via OLS as shown in Stock & Watson (2002). What the authors estimated in the paper using the Kalman filter is the latent variables $f_t,_h$ and the relative lags through which they estimated both the equation (1) and ...


2

For the tasks listed, both Python and R preform very well. There are some packages in Python not in R and visa-versa, my solution for this is to simply call R from Python. This allows for the best of both worlds. It is also important to note I do not write any R code other than calling an R library from Python. Calling Python from R does not work equally ...


2

I wonder if it's possible to use solve.QP from quadprog by using dummy variables. One dummy variable $y_i$ would be used for each $w_i$, each $y_i$ would be constrained to be greater than zero, and the leverage constraint would be applied to the sum of the $y_i$. Problem formulation would look like $$ \text{min } w^tΣw $$ subject to the ...


2

For non-normal asset price models you could look at the theory of Lévy-processes. If we assume that you work in the physical probability measure $P$ and that the random numbers that you have generated are daily log-returns, then you can do the following: Asset $i$ has starting price $S_0^i$ and for the future prices you can put $$ S_t^i = S_0^i ...


1

Not too sure about the second part of your questions but as far as VaR, R has some pretty neat functions. First I took you subset A and converted it to discrete returns since using actual prices for VaR may be a bit harder to interpret. # Load PerformanceAnalytics for VaR & Calculating Returns library("PerformanceAnalytics") # Calculate Returns a ...



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