trading systems

Artur Matos arturmatos78@REDACTED
Thu Oct 1 19:06:28 CEST 2009


Hi Joel,

I tried to implement a backtesting/execution system in Erlang a few years
ago, but eventually gave up and moved to Java. I was not trading intraday at
that time (just using daily data) so performance was never much of an issue.
My biggest problem with Erlang is that it was lacking essential libraries,
and I guess this is still pretty much a problem today. Of the top of my
head:

 - Converting dates between different timezones - I needed this because I
trade in several exchanges around the world (NYSE, London, ...). You can
kinda do this in Erlang by setting the TZ environment variable before
calling date functions, but it is hacky and I could never put it to work.
 - Fixed point arithmetic, for things like money. You don't need that for
share prices and such, but you will need it at least in a few places if you
care for accuracy, like for computing PnLs and such. This is not so much of
an issue when you are backtesting, but at least in my case I want stuff to
be as accurate as possible when doing real trading.
 - Mathematical and scientific libraries. For things like statistical
arbitrage you will eventually need to compute more things besides
correlations, e.g. to do linear regressions and such. Erlang has no
libraries for this.
 - FIX connectivity, or interfaces for standard brokers, like Interactive
Brokers.
 - Graphical user interfaces. Implementing them in pure Erlang doesn't make
much sense because it is just too limited (although now you have bindings
for wx, so it might be better now).
 - Charts. Even if you are not doing technical analysis, you still need to
generate simple charts like equity curves and such when backtesting.

Most of these things can be implemented in Erlang and some of them are not
even that hard, but it slows you down considerably. And of course you can
always write parts of your application in other languages and interface them
with Erlang, but that is quite cumbersome as well.

I eventually went down that way - I implemented parts of my application in
Java - but then I got to a point where it doesn't make much sense to use
Erlang anymore. If you are using Java for the GUI, and Java for talking with
the broker, and Java for generating reports, what are you using Erlang for?
I could easily be much more productive in a language like Java that has
libraries for everything, even if Java is such a pain to use. Of course, I
would much prefer to use Erlang, but at least for this project the lack of
libraries was really a problem.

Things might be better now there is the new FFI interface and such, but for
now I would just avoid Erlang for trading. Of course you might have a
different set of requirements - this might not apply to you if you just want
to implement a simple trading bot, and have another system in place for
managing orders, executions, etc...

Artur.

On Oct 1, 11:45 am, Joel Reymont <joe...@REDACTED> wrote:
> Has anyone used Erlang to backtest trading systems?
>
> This basically involves loading price and timestamp pairs
> and iterating over them calculating various things like
> moving averages, correlation, etc.
>
> Off the top of my head, Erlang does not seem to be the most
> efficient platform for this because prices would need to be
> stuffed into ETS or copied around otherwise.
>
> The most efficient way to manage price data is to simply keep
> appending quotes to the end of an mmap-ed file. I would love
> to represent the mmap-ed memory as a binary and I think it may
> even be possible. It would require some tricky work at the
> driver level, though.
>
> What do you think?
>
>         Thanks, Joel
>
> ---
> fastest mac firefox!http://wagerlabs.com
>
> ________________________________________________________________
> erlang-questions mailing list. Seehttp://www.erlang.org/faq.html
> erlang-questions (at) erlang.org


More information about the erlang-questions mailing list