An open source programming language and software environment for statistical computing and graphics.

learn more… | top users | synonyms

1
vote
1answer
103 views

How to create a basket of currency pairs with the lowest correlation in R?

My strategy is designed to buy and sell all assets of a universe and rebalance periodically. It goes either long or short. To limit risk exposure to a single currency I would like the assets in the ...
1
vote
1answer
98 views

Forecasting using GARCH in R

I am using the predict and ugarchforecast functions in R. When I fit my models and try to forecast, I get either only increasing or decreasing values for sigma, does anyone know why? Thank you ...
4
votes
2answers
173 views

Thesis using Momentum strategies in R, tips on good books, guidelines etc on how to do the programming?

I am quite new to R and will be doing an empirical analysis of momentum strategies in R using a dataset from the index OSEAX from 1980 to 2014. The momentum strategy will for the most part resemble ...
5
votes
1answer
13k views

How to interpret results of Johansen Test?

I have two time-series a & b. The objective is to find out whether two series are cointegrated or not. I am using Johansen Test in R to find this out. I am using urca package of R. Here is the ...
1
vote
0answers
24 views

R quantstrat backtest with dollar based position sizing

I am attempting to tweak a quantstrat based backtest but have run into an issue. The maxPos limits are share based, and I would rather use a fixed dollar amount instead. So I've tried generating a ...
3
votes
2answers
83 views

Change periodicity on Rblpapi

So Dirk Eddelbuettel, Whit Armstrong, and John Laing released Rblpapi to CRAN recently, and it is awesome. I'm having some difficulty understanding how the overrides work though, hopefully someone can ...
0
votes
1answer
102 views

Technical Analysis - OBV indicator calculation in R

Here is a few references about OBV calculations: http://ta.mql4.com/indicators/volumes/on_balance_volume ...
0
votes
0answers
16 views

ROC — Output from Calculating Stock Returns Producing Lower Numbers Than Actual

I tried this on stack exchange, but think it is a better question here. I am beginning user and I need help with an error / bad output I am getting when calculating returns (using ROC) on stock ...
23
votes
7answers
2k views

Is R being replaced by Python at quant desks?

I know the title sounds a little extreme but I wonder whether R is phased out by a lot of quant desks at sell side banks as well as hedge funds in favor of Python. I get the impression that with ...
0
votes
0answers
18 views

Return.portfolio error from PerformanceAnalytics package

When using the PerformanceAnalytics package of R, I am getting an error from the Return.portfolio function whenever I ask it to rebalance_on any frequency. If the rebalance parameter is removed, the ...
5
votes
1answer
161 views

Calculate turnover for portfolio

I am trying to calculate the turnover for a portfolio strategy. First I generate some random data and assign it dates: ...
0
votes
1answer
77 views

What is the logic behind this backtesting code in R

I am new to R and I have found this simple backtesting code and can you explain me what is happening here. ...
2
votes
1answer
183 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? \begin{equation} ...
0
votes
0answers
53 views

Ledoit-Wolf portfolio weights calculation

I am trying to implement the Ledoit-Wolf minimum variance portfolio strategy on a real-world stock dataset. ...
3
votes
1answer
72 views

Tools/R-code to create gain/loss-asymmetry plots

The gain/loss asymmetry is a well known stylized fact: It basically states that real financial time series take longer for going up than going down. To detect it a heavy statistical machinery is ...
2
votes
1answer
135 views

Rebalancing portfolio weights

I have a matrix of returns and weights for every time period. ...
0
votes
1answer
52 views

FORECASTING Model AR(1) in an Autoregressive Form The Pi´s Parameters

Ive been implementing a little exercise to obtain the first 2 forecasting points of an AR(1) process. And i want to have the forecasting ponts using the three forms: Im folowing this pdf ...
5
votes
1answer
1k views

Tools/R code for predicting Dragon-Kings

The theory of the so called Dragon-Kings, esp. by Didier Sornette (ETH Zürich), basically states that financial crises and crashes are predictable (contrary to the theory of black swans). The ...
1
vote
1answer
2k views

Integrating R with Bloomberg

In the past, I have used the package RBloomberg to directly pull bloomberg data into R. I've also seen it go by the names Rbbg or R[Name Redacted]. It seems to me, however, that this package no longer ...
3
votes
1answer
124 views

Are all stocks and stock indexes just white noise

In the paper Super-Whiteness of Returns Spectra from Erhard Reschenhofer of University of Vienna it is commented the following "Until the late 70’s the spectral densities of stock returns and stock ...
2
votes
1answer
82 views

Fit linear model to higher moments of CAPM

How can one fit a linear model to the higher moments of CAPM in R? Fitting a linear model to the second moment (classical CAPM) would be ...
3
votes
1answer
92 views

Simulate (imaginary) asset prices using random numbers that follow a Frank Copula

I didn't understand how to simulate asset prices by using non normal random numbers. I am assuming that it would be incorrect to use the standard Geometric Brownian Motion, since it is based solely ...
0
votes
0answers
43 views

Issues with +100 symbols in Quantstrat, Erratic Trades

I've tested my code against individual symbols and very small groups of symbols. I'm finding the more symbols I add the fewer trades I get. For instance, if I just include the first five symbols, all ...
0
votes
0answers
53 views

Forecast of ARMA-GARCH model in R

I managed to forecast a GARCH model yesterday and run a Monte Carlo simulation on R. Nevertheless, I can't do the same with an ARMA-GARCH. I tested 4 different method but without achieving an ...
0
votes
2answers
64 views

How to get list of all symbols in fred database?

I am trying to query every single series in the fred database using r. I have checked out both the quantmod and fImport packages, and they work fine, though it seems that quantmod fits my use a bit ...
0
votes
1answer
77 views

how do I loop through all the stocks with quantmod and ttr?

I just started with quantmod package. If I want to select stocks based on their recent performance, then I need to loop through all the stocks in, say, NYSE. So I need: get all the stock symbols ...
2
votes
2answers
101 views

Any package to run VAR-GARCH or VECM-GARCH models in R?

I need to estimate a multivariate VECM-GARCH (or simply VAR-GARCH) in R. Browsing on the internet, I did not find anything yet. Do you know if such kind of packages exists? Please, note that a BEKK ...
0
votes
0answers
31 views

Interpretation of Johansen cointegration test in R

I am using urca package of R for Johansen Cointegration test in 2 stocks datas( A and B. My question is very elementar, but have cause some problems for me. How I interpret the critical values, for ...
0
votes
0answers
35 views

How to construct a cointegrating vector using more than 2 price series in R?

I use now this code from hier Why does the following data fail my cointegration test? with slightly modification of possibility to load something directly from Dropbox file storage . ...
5
votes
1answer
381 views

Definition of risk factors for market risk scenario testing

I am doing a research for stress testing in market risk. The usual process I found out for scenario testing is: Define risk factors upon the portfolio Define the desired scenarios Vary the risk ...
-3
votes
1answer
69 views

Constant decreasing volatility, GARCH forecasting

I am trying to forecast the volatility using GARCH modelling in R. I fit an ARMA(1,1)-GARCH(1,1) model, but my sigma predictions are constantly decreasing. Anybody know why? ...
0
votes
2answers
124 views

Fractals indicator (Bill Williams) R Quantstrat

Hi has anyone seen or know how to create an indicator for fractals in quantstrat? fractals explained http://forex-indicators.net/bill-williams/fractals example code (only interested in type 1 ...
0
votes
0answers
57 views

Can you tell me what this RBloomberg formula means?

I've been asked to re-create a spreadsheet that used RBloomberg using a different data source. But I'm having trouble figuring out exactly what one of the spreadsheet's formulas does. Can anyone tell ...
4
votes
2answers
203 views

good R package for vectorized option pricing

I am using for now the package fOptions but it doesn't allow for vectorized computation of black76 prices and delta. Which package can be used to do that? As noted ...
0
votes
1answer
60 views

Accuracy of GARCH& ARCH forecast

I'm learing ARCH&GARCH model. I have four questions that I don't know the answers 1st: ARCH & GARCH are often used to evaluate equities. Does it mean that ARCH and GARCH are fitter for high ...
12
votes
2answers
5k views

How to derive the implied probability distribution from B-S volatilities?

The general problem I have is visualization of the implied distribution of returns of a currency pair. I usually use QQplots for historical returns, so for example versus the normal distribution: ...
2
votes
1answer
47 views

VaR calculation accuracy/comparison/effectiveness through different R packages

My question is what would be the better( in terms of estimation accuracy) method of VaR calculation among below two:, also any small code snippet will be great as a starting point for me. 1st method: ...
2
votes
1answer
104 views

out-of-sample variance using rolling window

I am currently working on the comparison of the constructed portfolios using out-of-sample variance criteria. I am going to use rolling window procedure for the comparison. First, I choose a window ...
10
votes
4answers
4k views

R: Fast and efficient way of running a multivariate regression across a (really) large panel (First pass of Fama MacBeth)

I am attempting to run a rolling multivariate regression (14 explanatory variables) across a panel of 5000 stocks: For each of the 5000 stocks, I run 284 regressions (by rolling over my sample ...
0
votes
1answer
25 views

Residuals in the Ljung box test

does anybody know what type of residuals is used in the Ljung box test in R? raw or standardized? Because basically when I fit a GARCH model using garchFit, the summary() function gives me all the ...
1
vote
0answers
116 views

GARCH modelling and forecasting

I have a few questions regarding GARCH modelling and forecasting and it would be great if someone could help me. I am modelling the log return of oil spot prices using various GARCH models: GARCH, ...
4
votes
2answers
236 views

R package for portfolio

In the context of modern portfolio theory, one often wishes to minimise $\mathbf{w}^{\mathrm{{\scriptstyle T}}}\boldsymbol{\Sigma}\mathbf{w}$ subject to $\mathbf{w}^{T}\boldsymbol{\mu}=c_{1}$, ...
3
votes
1answer
105 views

Fitting transition matrices in R by solving for coefficient

I'm using various matrices to impute a fitted transition matrix for credit ratings by solving for a variable [S]. Essentially the idea is to determine a base matrix and stress matrix to compare to a ...
3
votes
0answers
75 views

Computing Value at Risk for portfolio in R

I know how to compute VaR with long positions using PerformanceAnalytics. What about a portfolio consisting in two equities A and B, 100 USD long positions in each, and 2 stock options for the same ...
0
votes
0answers
30 views

comparison of speech signal processing and financial data

I have read that in speech signal processing analysis when voice is segmented in brief temporary segments the series segments transitions from being non stationary to stationary. My question is if ...
1
vote
2answers
147 views

Kalman filtering

Is it possible to the extract the latent factor f from the following equations using kalman smoothing? f is the unobserved state value while z is observed series. From the literature i could read ...
2
votes
1answer
129 views

rollapply with Arima model: testing for stability of coefficients

I am trying to fit an arima model on a rolling window using rollapply.My aim is to plot a graph of the evolution of the coefficient, plot the error and the standard deviation. well i encountered the ...
16
votes
7answers
5k views

What tools exist for order book analysis and visualization?

What tools exist for order book analysis and visualization? In particular, if one wanted to examine a limit order book and understand how it changes throughout the day where would you turn for ...
5
votes
1answer
478 views

Kelly Capital Growth Investment Strategy (Example in R)

In the paper Response to Paul A Samuelson letters and papers onthe Kelly Capital Growth Investment Strategy pages 5 and 6 Dr William T Ziemba, gives a praticle example on Kelly Growth. I’m trying to ...
2
votes
2answers
239 views

Is there a way to adjust R PerformanceAnalytics function VaR with EWMA or GARCH method?

Is there a way to upgrade R PerformanceAnalytics function VaR with more risk sensitive approaches like EWMA or GARCH? Or is there another R package which can handle the issue?