Publications by The Average Investor
Connecting to a DB2 database from R
Unlike RMySQL and RSQLite there is no RDB2. However, I found it pretty straightforward connecting to a DB2 database using the JDBC driver and the RJDBC package. For all this to work, DB2 should be setup to use TCPIP, which is not used by default. You need to set the DB2COMM DB2 environment variable to TCPIP: db2set DB2COMM=TCPIP db2stop db2st...
1865 sym R (604 sym/7 pcs) 18 img
Tools
All the tools I am using at the moment are free of charge. The one that comes to mind first is R. It’s a language for statistical computing which comes with a decent GUI. R comes with some time series support out of the box, but there are plenty of packages (R extensions are called packages) which provide powerful functionality. I remember usin...
1801 sym 16 img
RSI(2) and the pre 80s Market
In his detailed research on RSI(2) indicator, MarketSci emphasized several times that the contrarian strategies based on the RSI(2) indicator didn’t start working until the 80s. I remembered this observation recently when I observed another interesting anomaly … In statistics, an important initial step in studying time series data is to consi...
2245 sym 20 img
Open-sourcing some of my automation code
To automate my trading I use a mix of scripts. Everything goes – R, Python, shell, C++, etc. For some time now I have been satisfied with the tools I have created. They run once a day, gather data from EODDATA, update the database, run some R magic to decide what needs to be done for trading and finally, I get an email with the report. Good eno...
1053 sym 18 img
Investing with the Odds
In this previous post, I showed that a look at the correlations in the daily returns of S&P 500 should have lead to a very profitable investing strategy. I also promised to show the results of this strategy in the 80s, but I am not going to do that, because MarketSci has done so in several posts already. Instead, let’s try to find a more recent...
1864 sym R (396 sym/1 pcs) 20 img
ARMA Models for Trading, Part I
Lately I have been testing trading models based on methods from various fields: statistics, machine learning, wavelet analysis and others. And I have been doing all that in R! In this series, I will try to share some of these efforts starting with the well-known from statistics Autoregressive Moving Average Model (ARMA). There is a lot of written...
2118 sym 16 img
ARMA Models for Trading, Part II
We left the last post at the point of determining the best ARMA model. Before continuing the discussion, however, I would like to make a few points that might seem a bit questionable or unclear: We model the daily returns instead of the prices. There are multiples reasons: this way financial series usually become stationary, we need some way to ...
2221 sym R (1221 sym/2 pcs) 16 img
ARMA Models for Trading, Part III
In the last post I showed how to pick the parameters for the ARMA model. The next step is to determine the position at the close. One way to do that is by a one day ahead prediction, if the prediction comes negative (remember the series we are operating on is the daily returns) then the desired position is short, otherwise it’s long. library(qu...
1800 sym R (595 sym/3 pcs) 16 img
ARMA Models for Trading, Part IV
All posts in this series were combined into a single, extended tutorial and posted on my new blog. The last post promised to show some back testing results for the ARMA techniques. I decided to use the S&P 500 index for this purpose. ARMA vs Buy and Hold What really impresses me in the above char it the staggering performance of this approach d...
2435 sym 6 img 1 tbl
Low-hanging R Optimizations on Ubuntu
A friend of mine brought my attention recently to the fact that the default R install is way to generic and thus sub-optimal. While I didn’t go all the way rebuilding everything from scratch, I did find a few cheap steps one can do to help things a little. Simply install the libatlas3gf-base package. That’s all, but it boosts the performance ...
1970 sym R (169 sym/2 pcs) 4 img