Stack OverflowWhat programming language(s) is algorithmic trading software written in?
[+24] [13] Imran
[2010-01-03 21:40:29]
[ language-agnostic programming-languages financial ]

Anyone know what programming language(s) is algorithmic trading software mostly written in? Also known as automated trading, algo trading, black-box trading or robo trading.

If I wanted to write the above software where would I start? Any tips/trick/advice greatly appreciated.

(1) What are some examples of algorithmic trading software? - Thomas Matthews
(1) Probably the same language(s) used to run offshore gambling websites. - benzado
(4) The following IBs predominantly use C++ for client-side and prop algo trading infrastructures: Credite Suisse, Goldman Sachs, Deutsche Bank, UBS, RBS, Barclays and BNP Paribas - Matthieu N.
(1) +1 for teaching me something new. I had never heard about algorithmic trading software - Nifle
Thomas, Nifle: Try Wikipedia on Algorithmic Trading at - Dirk Eddelbuettel
[+20] [2010-01-03 21:45:34] Aaron Fi

JaneStreet uses OCaml. Here's a tech talk about why they chose a functional programming language to implement their trading software:

Thanks for the video link. I was aware of Yaron's paper "Caml trading - experiences with functional programming on Wall Street" at, but not this talk. - Don Wakefield
[+15] [2010-01-03 21:56:48] Adal [ACCEPTED]

I'm working on the same thing right now (FOREX), and I'm using Python.

C++ is needed only for really fast strategies (mili/microsecond level) or for huge amount of data (think arbitraging the S&P 500 index versus it's 500 component stocks, BTW, another microsecond level job)

You can use pretty much what you fancy if you won't trade less than a minute apart. It also depends on the API of the broker you use. Some offer FIX (socket programming), others Windows COM APIs, other Java APIs.

To answer your question, most use C++. Here's a job offer of the kind [1]


Just out of interest, which API are you working against for order execution? - grm
The Order2Go API offered by - Adal
FYI, it appears order2go was eaten by and from what I've seen, for the hobbyist is quite expensive. - Kort Pleco
Order2Go is also offered by FXCM - Adal
[+10] [2010-01-03 23:40:15] Dirk Eddelbuettel

You are not defining your terms well.

Automated trading (or black-box trading) can be written in anything, provided your trade horizon is long enough and your latency requirements are not stringent. That's where the stuff from the late-night commercials comes in and you get Windows applications with their own scripting languages etc. Some people do this in spreadsheets on daily closing prices or coarse-enough 'bars' of data, and daily trade frequency. However, at higher frequencies and/or model sophistication, the door opens for Python, Matlab, R, ... as well as compiled languages.

High-frequency trading is a different matter as trade horizons are much shorter and latency requirements can be critical. In this domain, the language of choice is C++ (as you can confirm by perusing job ads) with the odd sprinkling of Java or C#, as well as outliers as OCaml used by Jane Street.

[+9] [2010-01-03 23:56:41] Uri

I work in a the field, so here is my knowledge about US companies:

Quite a few algorithmic hedge funds are C++ and Linux centric. Examples include Tower Research Capital, Hudson River, Knight, etc. They typically have their infrastructure done in-house, and benefit from C++ speed. C++ is generally more common in investment banks as well. Bloomberg is also C++ based though they don't do their own trading.

However, some serious players are actually in the Java world: D.E. Shaw is the most notable and probably largest. Two Sigma investments are also major players in Java, and then there are a lot of small players.

I'm less familiar with the Chicago and Austin markets (other algo powerhouses) but it still seems to be primarily C++ and Java.

I know that there is at least one firm in NYC that does only OCAML (Jane Street?), and they hire lots of Ph.Ds. who tend to come from a PL/functional background. I have heard stories of .NET shops but they're less common, likely because of licensing costs - Linux is more common in this domain because you can ramp up a lot of firepower quickly.

Finally, quite a few smaller houses buy access to APIs to do algorithms. The company I work for, for instance, provides a trading platform and a Java based API that one can use to implement specific algorithms. A lot of the complexities of programming are hidden so the quants can focus on the algo side.

I would seriously advise against writing your own trading platform. The market is saturated, and you usually have to hand optimize for years to get good performance. If you have an idea for a clever algorithm, you may be better off licensing a trading platform or joining an actual fund.

[+4] [2010-01-03 21:44:13] alemjerus

Most of what I know is written in C++, less in Java, and some bits in C# and .NET ASP

[+4] [2010-01-03 22:28:29] Adam

It depends on what API your brokerage provides. The one I use for this sort of thing is Interactive Brokers [1], which provides APIs [2] in DDE for Excel, Java, C++, and ActiveX. When I first started developing my ATS, there were some eccentricities to their C++ API, so I'm using the Java interface. It looks like the C++ API has improved since, but I've already got a large body of working code. The APIs may provide different features for individuals versus institutions. FIX interfaces are an industry standard, but it may be difficult to get direct access as an individual. Depending on which broker you select, YMMV.


(3) If you're serious about latency and are fortunate enough to have direct exchange connectivity, then you probably want to use whatever 'native' protocol the exchange may have as it's likely to be faster than FIX. TSE had something called chumon before, not sure what's used today. - ehnmark
[+4] [2010-01-04 00:02:54] Dan Tao

Just adding my two cents: the company I work at uses primarily .NET (C# and--believe it or not--VB.NET). As others have pointed out, you're probably not going to find a lot of managed languages like Java or anything in .NET for high-frequency trading (e.g., tens or hundreds of trades per second), but for algorithmic trading in general, a managed language can be a smart choice for the faster development speed. We are adding and changing functionality on a constant basis and would not be able to do so nearly as rapidly working in a language like C or C++.

The biggest issue with a managed language in this context is not garbage collection per se, but specifically garbage collection that occurs at a time-critical moment such as when a high volume of trades are being executed. Since the CLR handles this by itself, the developer has little control over such situations, which is fine (even desirable) in a typical business application but terrible in a real-time trading environment.

The standard strategy that I'm aware of (and that we use) to minimize this potentially catastrophic scenario (a quote lagged by 50ms could be bad; one lagged by 1s could be devastating) is to use resource pooling and recycle the same objects over and over in favor of creating new ones. The less garbage you create, the less there is to collect.

Besides that, constant performance profiling is obviously a must. A lot of the code in our codebase looks pretty ugly because of all the performance optimizations we've made (and continue to make). That's just the way it is, unfortunately, when you're competing with other traders to get to the market a few microseconds sooner.

[+2] [2010-01-03 21:44:39] Hassan Syed

Depends, these days a 4th gen language like Java or C# for normal e-commerce (other such languages will also function -- e.g., Erlang or Python); however, there is a real-time aspect to the --hard-core -- trading side.... such systems use expensive -- non-standard -- hardware to eliminate latency and naturally software is written in C++ or C. every ms counts when you want to out-do others competing with you.

(3) The real killer is garbage collection. - ehnmark
Foh shizzle; there are other things which behave in a non-deterministic way as well -- e.g., user-space green thread schedulers (Erlang), fully interpreted execution (python), or multi-pass optimized JIT (Java). - Hassan Syed
Java and C# are not 4th generation languages. - P-Nuts
(2) It really depends on what you consider hardcore and high performance. These days the space for ultra low latency (microsecond range) is often migrated to silicon. If you're above silicon and do some intelligent things (pinned and efficient memory) you can certainly get micro and nano second processing on algo models. - Ajaxx
[+2] [2010-01-03 21:49:40] anon

I've come across autotrading software written in languages as diverse as VB6 and Java (hmm, maybe not that diverse). The stuff that actually talks to the exchanges to do the trades always seems to be written in C++ though.

[+1] [2010-01-03 23:51:37] Eric

Some systems, e.g. StreamBase [1], let you define your trading algorithms in a proprietary language (which may be a visual language or something declarative instead of a common programming language).

Engines of this type can be created using anything from Java (to run on any server) to machine language (to run on specialized hardware).


[+1] [2010-12-22 21:34:01] jay

Garbage collection issues can really spoil the idea of designing a trading platform in java. However software like Terracotta's bigmemory can be used which gives Java applications instant, effortless access to a large memory footprint, free of the constraints of garbage collection.

Is anyone using java with Terracotta or similar products in developing a trading palform ? Would love to hear some experiences.


[0] [2010-08-18 13:29:15] herrold

We have run the Trading Shim project (link below) for several years, which is designed to provide the connector between a Java based, FIX translation and account management gateway, called the TWS, which connects to the upstream exchanges, account detail, and data farms of the broker: Interactive Brokers; and on the downstream toward the trader's strategy and management clients. It exposes a simple text command interface on its input, and results datastreams in several formats (syslog, logfile, standard out)

The shim is written in C++, and is released under a GPL3+ license. The testing harness (which simulates a client) is written variously in shell, Ruby, Python, and basically any language which can read from standard in, and write to standard out. So ... any language.

I collect a linkfarm to several such projects and products, note their implementation lamguage, and the licenses under which they are released here [1]


[0] [2012-04-17 03:15:42] Gabriel Becedillas

I've been spending some time writing a Python library for algorithmic trading (actually for backtesting strategies). You can take a look at it here: