The dataset we are using was created like so:
Monday, December 17, 2012
The dataset we are using was created like so:
As a commenter pointed out, if you are using a data frame the data types must all be the same otherwise they will be subjected to type conversion. This may or may not be what you want, if the data frame has string/character data as well as numeric data, the numeric data will be converted to strings/characters and numerical operations will probably not give what you expected.
Our own functions
Using sapply and lapply
Tuesday, August 28, 2012
For those interested, it uses 2 GLSL Shaders, one that takes the spectral curve as input and uses a ping-pong FBO to calculate the offsets, and the other to turn those offsets into displacement, colour etc.
Tuesday, July 31, 2012
My secret shame
Apple is cool for other reasons
Monday, July 30, 2012
Background and idea
Often we are looking at a particular sector, and want to get a quick overview of a group of companies relative to one another. I thought I might apply Multidimensional Scaling (MDS) to various financial ratios and see if it gave us anything useful.
As an aside, this is the first R program I wrote devoid of any for loops. I finally feel I am coming to grips with the language.
Tuesday, July 24, 2012
Actually last weekend my credit card number somehow got stolen, which meant the new laptop I had on order has been postponed while I wait for my new card. I had been planning to do a bunch more stuff once it arrived as my current one is showing its age a bit, but I ordered it in June and there was a 4 week wait till it shipped, then the card thing happened the day before it was going to ship! But that's about it.
I did manage to get this done over the weekend, it's 150k particles traversing a vector field generated from Perlin Noise. When the new machine arrives I want to delve into GPU programming and 1 million particles is the goal.
Anyway, it's a bit cold and wet here right now, hope you're somewhere sunny and warm.
Music is Olson by Boards of Canada.
Sunday, May 20, 2012
The focus of the test is the proportion of zeroes and ones for the entire sequence. The purpose of this test is to determine whether the number of ones and zeros in a sequence are approximately the same as would be expected for a truly random sequence. The test assesses the closeness of the fraction of ones to ½, that is, the number of ones and zeroes in a sequence should be about the same.
We can see that positive returns tend to follow positive returns and vice versa, at least for this 5 week look back period. This is somewhat deceptive as a negative return, though negative, may still be higher than the previous one implying a loss.
However, it does reflect my understanding of how prices move a little better, in that they trend for a while then range for a while and vice versa, and things may not be as random as we might expect. My confirmation bias somewhat sated.
Sunday, April 22, 2012
Friday, April 13, 2012
The details are available in his paper A Quantitative Approach to Tactical Asset Allocation and were further expanded on in his book The Ivy Portfolio both of which are must reads.
The short version is to use diversified asset classes, long only, and only long when the price is above the 10 month simple moving average (approx 200 day). The assets he tests are U.S. Stocks, International Stocks, U.S. Government Bonds, Commodities and Real Estate, accessible via ETFs.
A rotational extension can also be added by investing only in the top 1-3 asset classes showing some degree of relative strength, which is defined as the average of 3, 6 and 12 month returns. They must also be over the 10 month SMA to be candidates.
The system updates monthly at the end of the month, it is about as hands off as you can get for active management.
There is an ETF for those so inclined, GTAA, but I am experimenting with a put selling implementation, which I might start tracking here month to month. I wrote a small R script using quantmod to display the relevant information for given symbols, which should be available here: Tactical Asset Allocation R script
The output looks like this:
Sym R3m R6m R12m Close AvgRet OverMA
4 VNQ 0.09295631 0.22412597 0.08488552 63.65 0.13398927 TRUE
1 VTI 0.11671109 0.22466699 0.05037598 72.26 0.13058469 TRUE
2 VEU 0.10908623 0.13282091 -0.10915250 44.22 0.04425155 TRUE
5 DBC 0.07048208 0.11194076 -0.05767911 28.80 0.04158124 TRUE
3 IEF -0.02193049 -0.01718305 0.10473673 103.28 0.02187440 TRUE
Let me know if you have any comments or find any bugs.
Sunday, February 12, 2012
We have Linear Regression
Followed by Neural Networks
One remaining item is Logistic Regression, I am yet to find a library in R that behaves as I want, so that will come at some future date. I've been sitting on this post for ages and got sick of waiting. As an aside I find the documentation in R to be variable at best, which can make it somewhat of a pain to work with. When it is good, yes it can be very good but often it is quite poor ...
R is great for data analysis and exploration, but I have found myself moving back to python for many more mundane tasks.
Anyway for those interested in the code, I have put it on Github. The data is from an exercise in the Stanford course, and by tweaking the parameters I really got a good feel for how the various algorithms work in practise.
Once I finish my backtesting engine I will probably put it up on Github as well, and then I can start digging into the applications of ML techniques for trading systems.
Friday, February 10, 2012
I have been busy learning machine learning techniques, writing a market data replay/limit book backtesting framework in python, and messing around with the Processing graphics environment.
More to come on the first two later, but here is a sketch of something I made in Java/Processing