Tag Info

Hot answers tagged

21

Don't have to switch -- it's not either / or after all. Use either where it has an advantage: R for explorations, modeling, ... and C++ for industrial-strength and high-performance implementations (at a possible cost in terms of time to code). And (with the obvious Rcpp plug coming) you can even combine both of them.


15

R can be pretty slow, and it's very memory-hungry. My data set is only 8 GB or so, and I have a machine with 96 GB of RAM, and I'm always wrestling with R's memory management. Many of the model estimation functions capture a link to their environment, which means you can be keeping a pointer to each subset of the data that you're dealing with. SAS was much ...


11

I am not an R advocate, but can witness that R is trivially very, very good at data analysis. It is essentially a LISP-like functional language domesticated enough to make you productive in one afternoon. It is unbeatable at getting data in your system, analyzing them, and producing high-quality output, be it latex reports or charts. I have used several ...


11

There are many specialised products for HF tick data. In addition to KDB which you mentioned, there is OneTick, Vertica, Infobright, and some open-source ones like MonetDB etc. (see http://en.wikipedia.org/wiki/Column-oriented_DBMS). My experience is that Column Oriented Databases are overrated when it comes to tick data, because very often you request the ...


8

The greatest weakness and greatest strength of R is that it is not a strongly typed language. Therefore easy tasks in strongly typed languages such as re-factoring, auto-compiler checks, unit testing, etc. can be more difficult in R. On the other hand, one can rapidly prototype in the R language. R is an interpreted language -- it will dynamically convert ...


7

Take a look at the sde package; specifically the dcOU and dsOU functions. You may also find some examples on the R-SIG-Finance mailing list, which would be in the results of a search on www.rseek.org.


7

I don't know why it was removed, but the R package "orderbook" was available: http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Kane~et~al.pdf http://cran.r-project.org/web/packages/orderbook/index.html In the IBrokers package, the function "reqMktDepth" is used for streaming order book data. ...


7

If you've got a list of trades, I would first suggest using the blotter package to enter those transactions and compute your cash P&L. Then you can use the tradeStats function to see trade related statistics, or the portfReturns function to extract percent returns for your portfolio of symbols as a contribution to total account equity returns. After ...


7

The "Component ES" section of ?ES says: For the decomposition of Gaussian ES, the estimated mean and covariance matrix are needed. For the decomposition of modified ES, also estimates of the coskewness and cokurtosis matrices are needed. The estimate of the coskewness and cokurtosis matrices are what take such a long time. You can calculate them ...


7

The clearest and most intuitive article I have seen so far is Kritzman et al., Regime Shifts: Implications for Dynamic Strategies in FAJ (May / June 2012) It not only shows how you can use HMM for financial modelling but it also goes through the actual estimation algorithm (Baum-Welch) step-by-step and even gives full MATLAB-code. From the abstract: ...


6

You can directly imply a probability distribution from a volatility skew. Note that, for any terminal probability distribution $p(S)$ at tenor $T$, we have the model-free formula for the call price $C(K)$ as a function of strike $K$ \begin{equation} C=e^{-rT} \int_0^\infty (S-K)^+ p(S) dS \end{equation} Therefore we can write \begin{equation} e^{rT} ...


6

The PortfolioAnalytics package will create weights without reference to current weights, if that's what you want. It should also have much of the reporting that you like from Rmetrics fPortfolio. There is a longer seminar presentation on Portfolioanalytics from 2010's R/Finance conference here: Complex Portfolio Optimization with Generalized Business ...


6

This is the website to the R/Finance conference this year. Tons of great links. http://www.rinfinance.com/agenda/ Brian Peterson's slide (Building and Testing Quantitative Strategy Models in R) mentions Portfolio-Analytics (which I think is based on R/Metrics). And here is a paper based on Portfolio-Analytics. ...


6

As a disclaimer, I'm a noted advocate of using Python to build production systems for quant finance (old talk but: http://python.mirocommunity.org/video/1531/pycon-2010-python...). I've been very successful at doing it and largely as the result of my example many other quant shops have chosen the Python route to excellent results. The pandas Python library ...


6

So one such visualization package is demonstrated in http://www.tradeworx.com/movie/booklet_demo/temp/booklet_demo2.mov. AFAICT it looks like a tk script. Trading Technologies (TT) sells another visualization tool. But TBH writing your own tool takes a few hours and allows you to focus on what information you are interested in finding.


6

Here is my code: require(xts) require(urca) # Load data gld <- read.csv("~/Downloads/CBA.csv", stringsAsFactors = FALSE) gdx <- read.csv("~/Downloads/WBC.csv", stringsAsFactors = FALSE) # Convert to xts gld <- xts(gld[, 4], as.POSIXct(gld[, 1], tz = "GMT", format = "%Y-%m-%d", tzone = "GMT")) gdx <- xts(gdx[, 4], as.POSIXct(gdx[, 1], tz = ...


6

A simple google search should get your started: I like this one the best because it compares different packages: http://stat-www.berkeley.edu/~brill/Stat248/kalmanfiltering.pdf and here couple more: http://www.r-bloggers.com/the-kalman-filter-for-financial-time-series/ http://cran.r-project.org/web/packages/dlm/index.html ...


5

To expand on what Joshua has already stated, here is a truncated parameter list of similar functions, along with the package to which they belong. quantmod::Delt(x1,type = c("arithmetic", "log")) quantmod::periodReturn(x, type='arithmetic') # log would be "log" TTR::ROC(x, type=c("continuous", "discrete")) PerformanceAnalytics::CalculateReturns(prices, ...


5

What about customizing KNIME (Open source aswell) for this particular problem? I am no expert, just my two cent. KNIME comes with Weka(I dont mean complete Weka, but a basic machine learning functions) & R integration aswell(Importing/Exporting R codes are easy), Text Mining, Neural Nets etc. I reckon, KINME(www.knime.org) with it's enterprise ...


5

Getting something up and running quickly -- i.e. data manipulation and exploration are activities R are adept at, and there are a plethora of packages to help you. Flexibility and speed (of research) are R's primary strengths. I feel memory and computing power are less expensive than the thought cycles used to explore an idea. If you're entering a ...


5

You can have a look at rgarch. It's quite versatile. From what I remember, you have to get it explicitly from R-Forge, as it's not available from CRAN. See the rgarch website for more details. Last time I checked, usage was something like this: spec.gjrGARCH = ugarchspec(variance.model=list(model="gjrGARCH", garchOrder=c(1,1)), ...


5

Systematic Investor also did a two part series implementation in R which is also quite helpful as he details the pitfalls too. Post One: http://systematicinvestor.wordpress.com/2012/11/01/regime-detection/ Part Two: http://systematicinvestor.wordpress.com/2012/11/15/regime-detection-pitfalls/


5

Mh, well I am not sure about already implemented functions, sure, I think they will exist. I give you a solution, with the direct implementation of the EWMA, so it does not need a preimplemented function. Here is the code: # just simulating some values, not sensible ones, just for # demonstration purposes returnseries<-runif(1000, min=-0.2, max=0.2) ...


4

FWIW, here's the approach I used. I keep the dates as an integer in YYYYMMDD form and merge the calls and puts in to a data frame both. Then I use ddply to operate on each matched call and put to find the future SPX close and call/put bid-offer average boa. library(plyr) both <- merge(calls, puts[, c("date", "exdate", "strike", "boa", "delta", "vega")], ...


4

If I were starting fresh, I would choose -IPython -Numpy+Scipy -Pandas (http://wesmckinney.com/blog/) You can get a one-click install from Enthought, http://enthought.com/. Python is hot on the heels of R as an exploratory data analysis solution for finance, and it's a heck of a lot more fun to write code in (imho:). Plus, python tends to play well with ...


4

The code of Euler Maruyama simulation method is pretty simple (nu is long run mean, lambda is mean reversion speed): ornstein_uhlenbeck <- function(T,n,nu,lambda,sigma,x0){ dw <- rnorm(n, 0, sqrt(T/n)) dt <- T/n x <- c(x0) for (i in 2:(n+1)) { x[i] <- x[i-1] + lambda*(nu-x[i-1])*dt + sigma*dw[i-1] } return(x); }


4

Using MySQL for financial data is not unreasonable. But for tick data are you ever going to do anything except a query on a date range? For analyzing tick data in R I generally keep it in a disk file, one tick file per day, and load the files in as I need them. Using .RData files instead of csv files is quicker. I've also used custom C++ classes before, to ...


4

The difference is not an artifact of floating point arithmetic; it's a difference in compounding frequency. The returns in your example are fairly close to zero, so they don't look that different. Larger changes in price will cause larger differences between the two calculation methods. Pat Burns wrote a nice blog post about the difference between ...


4

You want to set the parameter n.roll to the number of n.ahead, n.roll rolling forecasts you want. (The n.ahead parameter controls how many steps ahead you want to forecast for each roll date.) Thus by setting n.roll to a number almost equal to your sample size, and critically setting the out.sample parameter almost equal to your sample size, you're telling ...



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