Languages

Book: Akka Essentials

January 14th, 2013

Over the last few years the has been a renewed interested in the actor pattern.  In the Microsoft stack, both Microsoft and MSR have provide extensions to .NET to leverage the actor model.  Likewise, in the Java/Scala stack, akka and Typeseafe has gained some traction, with akka 2.1.0 recently release.  Within the financial version, the actor model is of considerable interested due to the complexity of the systems that are developed within both the sell-side and buy-side.  Akka Essentials has therefore hit the shelves (for anyone who still buys a physical book) at the right time – especially if scroll down to the lower section of the akka home page, and view the list of “selection of production users” – UBS and Credit Suisse.

Arthur Whitney – A+ and K

January 7th, 2013 / Tales from a Trading Desk

With what appears to be a revamped kx systems web site, its curious to re-read Arthur Whitney’s A+ and K language journey.

Arthur Whitney is a Canadian computer scientist most notable for developing the APL-inspired programming languages A+ and K.[1] He also wrote the initial prototype of J, a terse and macro-heavy single page of code, in one afternoon, which then served as the model for J implementor Roger Hui, and was responsible for suggesting the rank operators in J.

He studied pure mathematics at graduate level at the University of Toronto (Canada) in the early 1980s.[3] He then worked at Stanford University (CaliforniaUSA). Currently he is the CEO and co-founder of Kx Systems.

Matching Engine with Scala and Cucumber – Market Orders

January 3rd, 2013

In the first two posts in this series, Prototyping a Matching Engine with Scala and Cucumber and Matching Engine with Scala and Cucumber – Crossing Limit Orders, we built a simple limit order book and a matching algorithm that crosses limit orders of opposite sides. In this post I am going to continue using Cucumber to test-drive the implementation of order book and matching engine – this time we are going to add support for another fundamental order type – market order.

Read the whole story…

Akka 2.1.0 Released

January 3rd, 2013 / Tales from a Trading Desk

Details here and here.  Key from my perspective is “cluster support (experimental, including cluster membership logic & death watch and cluster-aware routers, see more below)”.  The downside is the “experimental” tag that will continue until Akka 2.2 ‘Coltrane

What is an Actor?

January 3rd, 2013 / Tales from a Trading Desk

Finally got round to watching Channel9 The Actor Model.  Definitely worth a watch.

  • Processing
  • Storage
  • Communication

Tarjan’s strongly connected components algorithm in Scala

January 2nd, 2013

Recently I have been researching a matching algorithm for a certain sector of a swap market. This turned into a graph problem requiring finding strongly connected components of the graph (and then cycles) to generate possible multi-broker trades. I turned to Wikipedia for help and found this nice Tarjan’s algorithm:

Read the whole story…

Matching Engine with Scala and Cucumber – Crossing Limit Orders

December 25th, 2012

In the first post in this series, Prototyping a Matching Engine with Scala and Cucumber, we built a simple limit order book that properly maintains price and time priority for incoming Buy or Sell orders. In this post I am going to continue using Cucumber to test-drive the implementation of an algorithm that matches incoming limit orders against the opposite side order book.  The complete source code for this and other posts in the series is available from my GitHub repo: https://github.com/prystupa/scala-cucumber-matching-engine.

Read more…

Prototyping a Matching Engine with Scala and Cucumber

December 23rd, 2012

Implementing matching engine correctly can be tricky when you consider variety of order types offered by real exchanges. In addition to core limit and market orders exchanges offer additional execution strategies: market-to-limit, various types of pegged orders, stop orders, and others. Matching different order types is non-trivial, and there are many edge cases. In addition there are different rules for matching orders when session opens (i.e. auction mode) vs. continuous trading.

The resulting complexity strongly suggests a test driven approach for developing correctly working engine. In the following series of posts I’m going to gradually build a prototype of a functionally rich equity matching engine. Read more…

Casual invocations of Curry-Howard

December 22nd, 2012

The Curry-Howard isomorphism is an important discovery that seems (to me) to be underappreciated in the “working world” of most programming groups I’ve encountered.

Recently, on a client project, I fielded this challenging statement:
“If it really is true that types are propositions and programs are proofs, can you explain what (say) the disjunctive syllogism means as a statement about programs?”

In this case, I had an immediate answer, and I think that others who are coming to terms with Curry-Howard for the first time might also find this example instructive because it touches on some important aspects of reasoning about programs generally.

Java Boilerplate Reduction

December 4th, 2012 / Tales from a Trading Desk

Native HTML5 iOS

December 4th, 2012 / Tales from a Trading Desk

Justin offers some thoughts on delivering a Native HTML5 iOS application.  Worth a read given most companies don’t want to support two code bases per application as a min:  a HTML browser desktop and iOS Objective-C

P: Safe Asynchronous Event-Driven Programming

November 27th, 2012 / Tales from a Trading Desk

Another day, another language: P, a domain-specific language to write asynchronous event driven code.

Safe Parallelism

November 13th, 2012 / Tales from a Trading Desk

Joe hint’s at a bigger picture with regards “Uniqueness and Reference Immutability for Safe Parallelism”.  Mary Jo Foley says Midori project is the “large project” referenced in the research.  How many more years do we need to wait before we see something commercial?

Java to Clojure

November 5th, 2012 / Tales from a Trading Desk

Pithering provide a view on moving from Java to Clojure within a large European investment bank.  Video from EuroClojure2012 provide insight into the middle office derivatives project.  Elasticsearch leveraged to free the data.

Zipkin – Distributed Tracing

October 29th, 2012 / Tales from a Trading Desk

Another Open Source project from Twitter.  Functionality and the screen shot on the home page make interesting reading.

Zipkin is a distributed tracing system that helps us gather timing data for all the disparate services at Twitter. It manages both the collection and lookup of this data through a Collector and a Query service

Not surprise to see Cassandra usage in the architecture

Anyone used Zipkin from a Capital Markets perspective?

Scala IDE – Versions are Too Painful

September 27th, 2012 / Tales from a Trading Desk

During the last few evenings I’ve been doing some work with Scala.  Initially I started off with Eclipse as the IDE of choice.  But after remember how much I dislike Eclipse, I moved over to IntelliJ.  I prefer IntelliJ’s refactoring support, but for some reason just found the run/debug particularly painful with Scala, so ended up reverting back to Eclipse.  With ScalaIDE installed, and thus Scala 2.9.2, I experienced the frustration of creating a Maven Scala project, and finding the MySpec test failed to build.  It turned out, either rightly or wrongly, that the solution was to correct :( the pom.xml for the scala-library, junit and specs.  Specs probably being the key, and hence moving to Specs2.  Which leads me to the previously blogged view, IDE’s and versions are still to painful in 2012.  It just shouldn’t be this hard to get an environment running and start development. :(

Facebook iOS App Thoughts

September 3rd, 2012 / Tales from a Trading Desk

Reading Facebook’s thoughts on iOS vs HTML it appears that the “write once and ship across multiple platforms” view isn’t working for Facebook in the  iOS devices space.  Reminds me of Sun slogan.  Wonder if Apple care?

ZeroMQ + Java Bindings on OSX

August 2nd, 2012 / Tales from a Trading Desk

Sometime ago I under took the joy of building ZeroMQ on OSX.  It wasn’t actually that bad an experience thanks to the usual Google assistance.  Here are the notes for anyone following:

  • Download the latest stable release from here
  • The “To build on UNIX-like systems” is generally correct for OSX, apart from the fact that if you don’t execute “brew install pkg-config” prior to the building, you’ll end up with the “newline token” and PKG_CHECK_MODULES error as per stackoverflow
  • When installing pkg-config as per above, I found I had to copy the pkg.m4 file into /usr/share/aclocal and /usr/share/aclocal-1.10 as I couldn’t be bothered to check which aclocal was being used :(

FPGA & Hardware Accelerated Trading

July 11th, 2012 / Tales from a Trading Desk

HFTReview is running a four part series on FPGA & Hardware Accelerated Trading.  Worth a read.  For me GPU’s are still king for a majority of cases since good developers can get access to the technology easily (buy a GPU card) and leverage familiar IDE’s and tooling.  I think Mike O’Hara’s comment below provides a hint of the challenges around developing an FPGA solution.  However, I do see FPGA’s as being the right technical solution for certain business problem.

Taking an abstracted language like C++ and translating it into hardware is challenging

Stealers vs Disruptor

July 9th, 2012 / Tales from a Trading Desk

Interesting read over on low-latency.com on Sungard’s Stealer initiative.

Stealers is basically a general purpose, concurrent programming framework that gives us the ability to create a high throughput or low latency system without having to deal with the shared memory design problems of concurrent applications

Sounds very actor-ish:

The other approach is to use a message passing style of developing applications where there is no global shared memory and inside the system all processing happens using messages that are passed around.

Google Groups has some views on the stats.