Archive

Archive for the ‘FIX Protocol’ Category

core arb

December 15th, 2009 4 comments
core arbitrage?

FIX interface?

Cloud computing looks to have turned yet another interesting corner.   This time the turn leads towards the development of a liquid, fully electronic new marketplace in “spot instances”.

Spot‘ means what you would expect it to in the context of trading: the current pricing for immediate delivery of a commodity.  ‘Instance‘ is the atomic element within Amazon’s cloud environment; an instance is the smallest chunk of computing capability which can be provisioned within the cloud.

Amazon is making markets in cores and they’re exposing functionality just as a regular exchange would: both through user interface ‘screens’ as well as programmable APIs.

From their announcement:

Spot Instances enable you to bid for unused Amazon EC2 capacity. Instances are charged the Spot Price set by Amazon EC2, which fluctuates periodically depending on the supply of and demand for Spot Instance capacity. To use Spot Instances, you place a Spot Instance request, specifying the instance type, the region desired, the number of Spot Instances you want to run, and the maximum price you are willing to pay per instance hour. To determine how that maximum price compares to past Spot Prices, the Spot Price history is available via the Amazon EC2 API and the AWS Management Console. If your maximum price bid exceeds the current Spot Price, your request is fulfilled and your instances will run until either you choose to terminate them or the Spot Price increases above your maximum price (whichever is sooner).

embedded optionality

While the inclusion of, effectively, a market data service is neat, probably the most interesting aspect of the initial protocol they’ve designed is that it contains embedded optionality and behaves a bit like barrier options.  That is, when I setup an ‘order’, I need specify a maximum price I’m willing to pay.  When the spot price drops below my max, I get “knocked-into” a contract and instances are allocated to me.  If the spot price rises above my max while I’m running, I get “knocked-out” of the contract and my jobs get terminated.

The intent is to allow for low-priority jobs to be dynamically run whenever pricing drops below a user’s threshold, but the (intended?) consequence is that it adds the delicious and malleable tang of path dependency to these instruments…

secondary markets, FIX, arbitrage..?

Amazon currently controls the market entirely, but it’s not hard to imagine a secondary market evolving.  Given that others are beginning to copy Amazon’s APIs, one can also imagine markets which operate across providers …  perhaps accessed via FIX?…

Who knows?  In the not-too-distant future, we may well be able to implement ‘core arb‘ strategies…or make markets in cores… or find that we can effectively hedge with disciplined exposure to the ‘core market’ or …

containing a strategy

August 19th, 2009 4 comments

My son recently had his first birthday and amazes me daily with his new feats as he runs around increasingly stably exploring the world around him.  It occurs to me that the system I use to trade every day, Stratbox, is approaching its fourth “birthday” in the next few months.  I hadn’t originally intended to write a system – an algorithmic trading platform – but found that existing products were limited, expensive and didn’t fit my mental model of what they should do.

This isn’t surprising as I wanted the system to support all of the activities associated with our algorithmic trading.  It turns out that that’s a lot to ask of a system.  It also turns out that you learn as you go and so the system continues to evolve.  A few years ago I’d posted about the basics of a strategy container and in this post I’m going to come back to this topic and describe some of the layers of code and thought developed since then.

First, let’s consider the role of a strategy container.  Its job is to intermediate between trading strategies and the external environments with which they interact.  It must also provide services that strategies can use (e.g., position management) and that it wouldn’t make sense for each strategy to re-implement.  In the past I’ve focused on the former responsibility of adapting strategies to external environments.  Why is this necessary and interesting?  Because it allows us to take the same exact strategy and run it live, or in simulation or in backtest, etc.  Interesting and necessary, but not what I want to focus on this time.  Instead, I want to look at the services provided to strategies; the ‘ecosystem’ a strategy container provides in the hope that strategies might flourish within it.

Read more…

using Quantlib from Java

June 14th, 2008 6 comments

A free/open-source library for quantitative finance

One of these days I’m going to give an overview of all the excellent open-source software I use on a daily basis. Until that day comes, I’ll observe that finance remains one of the big areas where open-source software has made relatively limited inroads.Java

Two production-quality packages fight that unhappy state: QuantLib – a comprehensive framework for quantitative finance – and QuickFix – a full-featured FIX engine. Both are C++ libraries and both provide very nice interfaces to facilitate integration with other languages, including Java. QuantLib is a big and complicated library and integrating it with Java is not totally obvious. Below, I’ll describe how to build and use QuantLib from Java.

These instructions are based on a unix installation. I’m not really a windows developer and don’t have all the shiny tools that windows developers use, so it’s not an area of focus for me. That said, I have managed to build QuantLib under windows by using MinGW+MSYS but it wasn’t terribly easy and I don’t currently have a working installation, so I won’t cover that here. If this is your aim, don’t be dismayed as it is possible and it had all the functionality I enjoy under linux.

Using QuantLib from Java (on linux)

  • Build QuantLib
    • Requires a working version of Boost. This may prove to be the hardest step of all and you’ll need to use the ample documentation provided by the Boost team.
    • Once you have a working copy of Boost, building QuantLib should require little more than
    • sh autogen.sh
      ./configure

      make
      sudo make install

  • Build QuantLib-SWIG
    • Requires a working copy of SWIG. Again, look to the SWIG instructions, but it should be easy.
    • Once SWIG is available, building the QuantLib/SWIG interfaces should only require:
    • sh autogen.sh
      ./configure \

      –with-jdk-include=${JAVA_HOME}/include \
      –with-jdk-system-include=${JAVA_HOME}/include/linux
      make -C Java
      sudo make install

  • Now you’ll have a Jar file with all of the SWIG/JNI stubs in it available in /usr/local/lib/QuantLib.jar. Add this to your classpath.
  • Programs which call QuantLib functionality will need to have the LD_LIBRARY_PATH set. This can be done by invoking the vm with something like:
  • -Djava.library.path=/usr/local/lib

  • Programs which call QuantLib functionality will also need to explicitly load the QuantLib libraries. This can be done with something like the following static block appearing before your main method:
  • static { // Load QuantLib
    try { System.loadLibrary("QuantLibJNI"); }
    catch (RuntimeException e) { e.printStackTrace(); }
    }

  • That’s it. Now test your configuration by running the examples in Quantlib-SWIG/Java/examples.

It’s worth understanding how Quantlib is being used from java. SWIG is creating a JNI interface into those methods within Quantlib which have been exposed through their declaration in the swig *.i files. These files are found in Quantlib-SWIG/SWIG and they determine what functionality from Quantlib will be available to you. You’ll likely need to get familiar with a subset of those files that you care about. If you find that some functionality you care about isn’t exposed in those files, you may need to expose it yourself.

There’s a learning curve, but it’s worth traversing so you can get at all the rich functionality so many smart people have put together.

finding a niche at trade tech

March 7th, 2008 2 comments

This week we spent a few hours at the tradetech conference to see what people in the industry are up to and see some demos. Their “certified” logo inevitably reminded me of an old colleague who would from time to time mimic an old saturday night live skit. We saw some interesting things and, most importantly, found that our creative niche remains our own.

The booths we checked out included a few of the big sell-side firms shilling their creatively-named execution quality algos and their white-labeled oms/ems offerings. They had, by far, the best shwag (I should thank Merrill for their nice umbrella and commend citi for the very knowledgeable lady at their booth) but their algo offerings weren’t very interesting to me as they aren’t of the alpha-seeking variety.

Read more…

Putting the pieces together

October 12th, 2007 No comments

it all fits?

I’ve zipped through a whole bunch of algorithmic trading stuff over the last several posts. Judging from the expressions on the faces of some very smart and experienced wall st professionals when I’ve covered the same material, it’s not obvious stuff. So, I’m going to back-track a bit by describing what each of the pieces are and how they fit together.

We’ll start with a trading strategy. What is it in an algorithmic trading context? Conceptually, it’s a simple enough thing. It’s something that can study market data and can manage positions. That’s really it. Its “eyes” monitor one or many sources of market data and its “hands” are poised over an Order Management System. There’s obvious potential for complexity with this simple definition and we’re even leaving out potentially important elements, but for now we’ll take this to be pretty much it.

Read more…