A reader, Andrew Whaley, just left a comment on a previous note on genetic programming,
Hi Max
Glad I discovered this, I've been exploring using Genetic Programming to build MetaTrader EA's for automated trading of forex. I've also has some limited success using genetic programs to predict buy/sell order values for index trading. Please check my blog (link above) and I'm also setting up a new site to specifically document my approach and findings at http://www.thegenetictrader.com
My approach has been to create a rich terminal set that includes as much data as possible e.g. o/c/h/l values, various moving averages, various indicators e.g. RSI, CCI etc. and the programs choose which they want to use. The programs could involve as much complexity as needed to actually synthesize some of these indicators but this would take very many generations so I think having a rich set at the outset should short circuit the process.
I've had to roll my own using Scheme (a Lisp derivative). I chose Scheme because prefix languages are the natural choice for the simple reason that the syntax can be easily read and modified programmatically. Scheme has similar performance characteristics to C but with a higher level of abstraction which helps to makes short work of the problem.
The resultant Scheme code is then fairly easy to recode in MetaTrader.
Anyway, good luck and I'll keep checking back.
Regards
Andrew
I mention it because Andrew has a great example of genetic programming on his site. He includes code so it will make GP more concrete if you've read about it but not implemented it. His code is written very clearly.
Update from Andrew:
Hi Max,
I thought you may be interested in an update to my work; after a couple of months of struggle, I'm starting to come up with strategies that are generally profitable i.e. show profits on data they haven't been trained on.
The profits are very modest but I'm encouraged to continue. My blog has the details of the effort so far and the strategies.
Regards
Andrew
19 comments:
The Clojure Language
In grad school I took an A.I. course in which Scheme was the programming language. For the same reason as Andrew I was recently investigating LISP/Scheme. My concern about this family of languages is its marginal status within contemporary programming practice.
Then I came across Clojure. It appeared ~2007 and is a “modern” descendent of LISP/Scheme, built on top of the Java Virtual Machine, with full access to the Java libraries. The integration w/ the JVM is so seamless that Java code can call Clojure code. Clojure and adds several powerful data types and other features to LISP. It is not “OO” but does enable parent-child hierarchies, and its polymorphic capabilities are actually broader than most OO languages. It has also replaced some of LISP’s more idiosyncratic keywords – “car”, “cadr” & “lambda” -- with the more intuitive “first,” “rest,” and “fn.” There is a plug-in for in the Netbeans IDE. There is reportedly an effort to port this language onto .NET. Like LISP/Scheme, the command line interface – the REPL – provides a fun way to learn the language. I’d encourage you to try it.
The language web site is quite good, there’s a Google group, and there are several excellent tutorials ---
http://clojure.org
http://clojure.blip.tv/
http://en.wikibooks.org/wiki/Clojure_Programming
http://groups.google.com/group/clojure
Netbeans Plugin: http://enclojure.blogspot.com/
http://www.amazon.com/Programming-Clojure-Pragmatic-Programmers-Halloway/dp/1934356336/ref=sr_1_1?ie=UTF8&s=books&qid=1252723447&sr=8-1
Max -- I just left the comment about Clojure, but did not leave my name, which is Charles
Regards,
Looks very cool Charles. It would be interesting to combine with IB's Java API for a GP system. I would like an excuse to go back to anything like Scheme.
Regards,
Max
I've had a look at Clojure and the other two main JVM Schemes; Kawa and SISC. They offer the tremendous benefit of leveraging the mass of existing libraries but they tend to introduce compromises - performance being the main one, lack of tail-call optimisation and lack of support for continuations are the others to watch for. SISC has the most complete Scheme implementation but performance is dreadful. Clojure doesn't really pretend to be Scheme and is aiming to be more of a practical Lisp like language on top of the imperative JVM core, which I think has more mileage for general web app development.
Scheme's lack of mainstream support and libraries isn't really a problem for GP because the language has everything that you need built in i.e. list manipulation and eval. With Gambit Scheme, which is what I use, you can easily glue some C code in there if you need it and you get pretty good performance even when interpreted which makes it a superb platform for GP.
Performance can kill you with GP because each generation can end up taking hours to compute with a large population processing over a lot of historic data. I'm looking at using Termite (a feature of Gambit Scheme) to distribute the workload over multiple machines and cores to speed up the search.
There's your excuse :-)
-Andrew
Thanks for this guys, I'm working on a similar program to this written in Python. I posted a question recently to twitter (nissimk) to which I got no replies: how do you know the optimal number of iterations for a genetic algorithm? I'd like to discuss this topic more with you guys. Can we start some sort of group? I'm paranoid about spam, but you can mail me at nissimk at google's popular web based email service. Thanks,
-Nissim
Fyi,
If you want to explore GA in clojure in more detail, browse
http://ur.ly/33wD (complete simple example with commentary)
and possibly http://ethanjfast.com/14/show
Regards,
John.
That's really useful John. Thanks
Regards,
Max
Which is the best way to hedge currency risk when investing in international markets?
As an Example,
If I am buying japanese bond futures by converting USD to JPY and want to hedge currency risk.So I short JPY/USD futures contracts,then would I have to pay margin for this hedging?
And I also want to know how to hedge with fx swaps? ...As Fx swaps is the most liquid market with daily turnover around 1.5 trillion $++
Continuous hedging is even impossible .so is there any tool which can track Currency+investment movements?
You guys might take a look at Altreva. Although it's unfortunately a closed source program, it's one of the most interesting GP based programs I've found so far. The program has a decent documentation which could be inspiring for developers. http://altreva.com/
Jim,
Altreva looks interesting. Have you used it, to comment on its performance?
Regards,
Max
I've tried a early beta version of Altreva a few years ago. What I remember from those experiments was that the results could be promising using low volatility equities, but that it took a long time before a bad performing model became profitable when using daily data (slow adaptation because of too many agents? too less diversity?). In the near future I will run some experiments with the current version using intraday data.
Slave(China) has sad no to Master(US) for borrowing money.So USD would be in freefall as Gold/Siver will sky rocket as expected.China must be right now busy in dumping USD and buying Gold.
Hi Max,
I thought you may be interested in an update to my work; after a couple of months of struggle, I'm starting to come up with strategies that are generally profitable i.e. show profits on data they haven't been trained on.
The profits are very modest but I'm encouraged to continue. My blog has the details of the effort so far and the strategies.
Regards
Andrew
Andrew,
Good to see that you're being honest and self-critical about your strategies' performance. Keep in touch. I added you to the list of other writers at the right, whatever that's worth.
Regards,
Max
Post a Comment