[erlang-questions] trading systems

Joel Reymont joelr1@REDACTED
Thu Oct 1 21:32:33 CEST 2009


On Oct 1, 2009, at 7:49 PM, Jayson Vantuyl wrote:

> I would really recommend starting out with a naive implementation.   
> If anything it will give you something to use as a baseline for  
> comparison and profiling will tell you how much you can eventually  
> save with a more complex approach.

True. I think I'll still start by experimenting with mmap-ed binaries,  
or at least a binaries-based approach. These can always be mmap-ed  
later.

> Also, play with HIPE.  It currently is a bit unstable for general  
> use, but judicious HIPE compilation of key modules might be very  
> helpful.

Yes, I may try porting HiPE to x86-64 when I have time to spare.

> Out of curiosity, what features of Erlang make you want to try  
> this?  It would seem that it's made more for fault-tolerance /  
> scalability and less for the absolute lowest-latency.

Let's consider a few alternatives from the point of view of someone  
who is trying to built a platform for sale, me. The platform is to  
allow many users to host and run their trading strategies unattended,  
somewhere on a server co-located near the exchange. The platform has  
to have a web-based user and admin interface. I want to be able to  
compile strategies to machine code for fast execution. I also want  
some kind of typing to catch my errors and give me an additional layer  
of assurance.

I can write the whole thing in Lisp. Lisp has a built-in compiler and  
good web servers. I can take an HTTP POST-ed strategy and compile it,  
making sure it will run fast. I have a free license to a commercial  
Lisp but it requires royalties. I don't think I want to go there and I  
don't want to spend money on a non-royalty commercial Lisp either.  
Neither Lisp will give me fault tolerance, scalability or typing.

OCaml. I like the static typing, speed and ease of use (for me). I had  
the most pleasant experience of all writing and debugging my compiler  
in OCaml. OCaml does not have a built-in compiler, though. I will need  
to schedule jobs to compile strategies. The OCaml web server (Ocsigen)  
is not exactly proven and OCaml does not give me scalability of fault  
tolerance.

C++. I like the static typing and Boost Spirit v2.1 seems like the  
ticket for writing the compiler. Performance can truly be squeezed  
here. I could build my engine into a web server (nginx?) and use LLVM  
or NanoJIT to compile strategies. I will surely spend a hell of a long  
time developing compared to other solutions. C++ does not give me  
scalability but I could use ZeroMQ or something similar. Fault  
tolerance will need to be ensured by making each trading strategy into  
a separate process.

Erlang. There's a layer of typing with dialyzer. The web servers are  
good, there's scalability and fault tolerance. Building a compiler  
should be straightforward with leex and yecc. I can take HTTP POST-ed  
strategies and compile them. There's always HiPE for that ultimate  
performance boost. Performance may not be top-notch in the end but  
development should be fast and debugging straightforward.

I can safely discard Lisp. I would like to use OCaml but I won't since  
I'll have to built a distribution infrastructure, bind to ZeroMQ for  
scalability and NanoJIT or LLVM for compilation to machine code. I  
don't really see the point.

I see migrating to C++ as need arises, chunk by chunk. Erlang may end  
up as the message bus or I may swap it out entirely. This won't happen  
for a while or may never happen at all. Erlang just seems like the  
lesser of all evils or, perhaps, the golden middle.

---
fastest mac firefox!
http://wagerlabs.com






More information about the erlang-questions mailing list