Free software for free markets

Co-inciding with the first DebConf in Switzerland, one of the world's leading financial centers, the first official packaging of open messaging and market data distribution framework OpenMAMA for a Linux distribution has just been uploaded. The packages, along with the Avis low-latency event-router middleware/transport were uploaded to the Debian unstable catalog this week and will soon be available conveniently to install with apt-get.

OpenMAMA was developed by NYSE Technologies and includes code originally developed under their previous brand Wombat Financial Software. The project was recently placed under the strategic umbrella of the Linux Foundation.

Packages for Fedora and EPEL

The initial packaging effort has identified a number of build system bugs, patches have been contributed upstream. The resolution of these issues and the experience gained with the Debian package will make it relatively easy to package for RPM-based platforms in the near future.

Not just for finance

While it is clear that OpenMAMA's designers had financial services in mind (and the low-latency, high throughput transport of market price data in particular), the solution is generalised and likely to be useful in other domains where asynchronous messaging and inter-process communication is required.

In fact, this distinction is made particularly clear by the division of OpenMAMA into two subprojects:

  • OpenMAMA itself is a general-purpose programming API for asynchronous messaging. It hides the details of various low-level transports, including the open source Avis event router and popular proprietary solutions like Tibco Rendezvous. Java programmers have had such a generalised API for many years (JMS), whereas OpenMAMA brings a similar paradigm to the C/C++ developer.
  • OpenMAMDA is a further layer on top of OpenMAMA designed to encapsulate market data. It competes directly with proprietary solutions such as those from Reuters and Bloomberg. OpenMAMDA comes with specific APIs for news, order books and options and could be extended for other markets.

Commercial background

Reuters and Bloomberg are well known as two of the main vendors in the market data industry. Both of them (and other competitors) provide a range of data services and related software. Buying a data feed doesn't automatically give access to the software from the same franchise: the software and APIs are promoted as a valuable product in their own right. It is actually quite possible (and not unheard of) for an institution to run a Reuters Market Data System (RMDS) software stack fed by a data feed from Bloomberg or vice-versa.

When an IT department or third-party vendor of trading systems wants to transport data between applications (or between multiple users of a single application) they will not typically do it themselves and one of these APIs is usually chosen. OpenMAMA appears to be a strong contender for such use cases.

Bloomberg has recently made their API public, although OpenMAMA goes much further by making their source code public too.

Development samples with the OpenMAMA API

Programming the OpenMAMA API appears to be relatively consistent with the event-loop model that many developers are already comfortable with.

For a very fast start, two compelling examples are the basic publisher and basic subscriber.

Here is a sample of the code from the basic subscriber, demonstrating how to start the event loop and receive event notifications in a callback class:

static void createSubscriber (void)
{
    try
    {
        gSubscription = new MamaBasicSubscription;
        gSubscription->createBasic (gTransport,
                                    gDefaultQueue,
                                    new SubscriptionCallback (),
                                    gTopic);
        gSubscription->setDebugLevel (gSubscLogLevel);
    }
    catch (MamaStatus &status)
    {
        cerr << "Error creating subscription: " 
             << status.toString () << endl;
        exit (1);
    }
}

and here is some basic code that processes messages asynchronously:

class SubscriptionCallback : public MamaBasicSubscriptionCallback
{
public:
    virtual ~SubscriptionCallback () {}

    virtual void onCreate (MamaBasicSubscription*  subscription)
    {
        if (gQuietLevel < 2)
        {
            printf ("Created inbound subscription.\n");
        }
    }

    virtual void onError (MamaBasicSubscription*  subscription,
                          const MamaStatus&       status,
                          const char*             subject) 
    {
        printf ("Error creating subscription: %s\n", 
                status.toString ());
        exit (1);
    }

    virtual void onMsg (MamaBasicSubscription* subscription, 
                        MamaMsg&               msg)
    {
        if (gQuietLevel < 2)
        {
            printf ("Recieved msg.\n");
        }

        DisplayIterator it;
        msg.iterateFields (it, NULL, NULL);
    }

    //JG: need to add in onDestroy as this is abstract and must be implemented
    virtual void onDestroy (MamaBasicSubscription*  subscription, void * closure)
    {
        if (gQuietLevel < 2)
        {
            printf ("Destroyed subscription.\n");
        }
    }

};

Practical uses outside financial services

Some people may feel that having a low-latency market-data system is overkill for anybody not running a trading desk. Not so. OpenMAMA may well prove useful and convenient as a one-stop-shop API for multi-currency accounting software (Postbooks, GnuCash, etc), for multi-currency web sites (e.g. UberCart) and many other applications.