Systematic trading stuff



I spent 7 years working for AHL, a large systematic hedge fund (earlier in my career I also spent about 18 months trading exotic rate options for an investment bank, Barclays Capital). My first job was to develop and manage a systematic mult-asset global macro trading strategy. Subsequently I managed a multi billion dollar portfolio of fixed income strategies (futures, swaps, bonds and credit derivatives). See the 'about' page for more.

Since leaving the hedge fund industry I have written a live systematic trading system written in python and using the interactive brokers C++ API interfaced through swigiby, which I trade my own money with. The system trades nearly 40 futures markets with an average holding period of several weeks, and has a mainly trend following character.

I have written a book on systematic trading
 


My open source python backtesting and futures trading system

I post regular updates on my trading at elitetrader. My trading account is also visible on fundseeder (TA4483751). I'm currently (March 2017) ranked in the top 5 out of all traders, in the top 3 for systematic and technical traders, and I'm 1st in the futures category.

 

Research

 

Occasional articles on my own trading system


Writing a simple execution algo

Why I don't like short end german bonds anymore 

Simulating my futures system  

Futures trading performance, one year on 

... and two years on

A tale of two positions

Obligatory Brexit Post (Will I be okay?)

Obligatory Brexit ex-Post (Yes)

Occasional general articles on systematic trading


Why black box hedge funds should have lazy risk managers

Why you shouldn't employ too many geniuses

 Seven deadly sins of trading

Head to head: Technical vs Fundamental trading systems 

Why you need two systems to run automated trading strategies 

Should billionaires and bricklayers have the same investments? 

Can a small retail trader beat a large fund?

Humans or computers - which make better traders? 

Diversification and small account size

Developing a new trading rule - breakout

Capital correction

Can you eat geometric returns?


Series: Using random data to design trading systems


Introducing random data

Random data: Trading the equity curve

Random data: Optimising portfolio weights the right way (TBC)


Series: Systematic risk management



Systematic Risk Management


Technology

 

Series:Python code used in the book

 

Python code for the trading rules in the book

Python code for optimisation (one period and bootstrapping), and producing different sample periods

Python code for optimising in the presence of costs with pysystemtrade


Series: How to get interactive brokers native python API working



Getting historic data


Getting streamed market data

Series: How to get python and interactive brokers API interacting via swigby 101

(Deprecated: I suggest using the native python API instead - see the above series of posts)

Start here

Getting historic, snapshotted prices

Getting real time streaming prices

Placing orders and receiving fills

Getting positions and accounting information 



Series: A guide to the nuts and bolts of implementing a systematic futures trading system

 

Data capture

Futures rolling 

Deciding positions 

Execution 

Accounting

Checks and balances



Series: Pysystemtrade - my open source python backtesting engine


Original motivating post

Estimating forecast scalars

Instruments weights, correlations, and diversification multipliers

Optimising in the presence of costs

Developing a new trading rule - breakout

Capital correction


 

Other articles on systematic trading technology


My technology stack

Things I wish interactive brokers would do with their API software

Writing a simple execution algo

Using sqllite to store data

Using python to calculate your UK tax liability for trading profits

My open source python system

Docker and automated trading systems


30 comments:

  1. hi Rob, are your systems available for purchase , subscription? Thanks, Robin

    ReplyDelete
    Replies
    1. No, never. There's enough material in my book and on this website to reproduce the trading system I use, for free.

      Delete
  2. Hi Rob,
    How does your framework handle the inevitable loss of power or internet connection?
    E.g, maybe your framework detects a condition that requires an order to be placed but the power goes out or your internet connection goes down.

    Given the description of the hardware you use to run your system it sounds like the code is NOT hosted in some datacenter but rather executes in an environment (such as your home) where such a situation can (and does) occur.

    Thanks

    ReplyDelete
    Replies
    1. Hi Robert, Great question. Yes I run my stuff 'at home'.

      There are a number of possible scenarios. In scenario one, I lose my internet connection, but then get it back.

      Some services, eg get account value and get price will fail gracefully (treat what they get the same as a NaN).

      Orders that haven't been submitted will be delayed. Given how slowly I trade, I can live with this.

      More seriously if an order is submitted and I miss a fill then I'll get a break between what I think my position is, and what the broker records say. Right now I lock the position to avoid duplicate trades until I've manually fixed the problem (see http://qoppac.blogspot.co.uk/2015/07/systems-building-execution.html)

      NOTE - there is room for improvement here. I plan to rewrite this process to periodically check all fills received for the day and update the database; then automatically clear any position locks.

      In an extreme situation if a process fails then the cron job will restart it the next day. The only thing that won't restart is the IB API gateway.

      In scenario two I lose power. The system has to be manually restarted. In the short term this is very similar to a loss of internet.

      In an extreme situation (on holiday) I might lose power for a couple of weeks before being able to restart. When I restart the system will backfill all the daily prices and the required trade will then happen. Given the speed I trade at, I've tested the expected effect of this and I can live with it.

      Delete
  3. FC wrote this comment, which I accidentally deleted:

    "Hello! I am super excited about your stuff and that you are UK based. Do you have an opinion about these:
    https://labs.ig.com/
    http://docs.labs.cityindex.com/
    Is the tax advantage worth the development trouble, credit risk and worse bid-ask spread? "

    ReplyDelete
    Replies
    1. I don't have a problem with spread bets, but it's certainly true that if a future was available on the same terms (same tick size) I'd trade the future.

      Usually that isn't the case. For example you can trade FTSE 100 at £1 a point but the future is £10. So spread bets can be especially useful if you have a smaller account, but the wider spread means you'll need to trade more slowly.

      Fortunately my account is large enough that I can just stick to futures.

      I discuss this problem in my book.

      Delete
    2. Excellent - I've already ordered your book. Awaiting delivery from publisher.

      Delete
  4. Hi Rob,I read really great reviews about your book and was adviced by a friend to take a look into it, however, I'm a novice to trading and investing, can you advice me what to read and learn before I start reading your book?

    ReplyDelete
    Replies
    1. Thats a difficult question as it depends on what level you're at and which direction you want to go in. If you want to trade futures then reading Jack Schwagers books would be a good start.

      Delete
  5. Hi Rob,
    Great book. I wanted to let you know that we specialize in executing systematic trading strategies for clients in the futures and commodities markets. We support several different platforms including TradeStation, TradingBlox, Mechanica, and provide access to nearly every CFTC approved product around the globe. If you know anyone that needs help with putting their strategies into the market, we can help with execution and reconciliation and do an excellent job (for over 20 years now).

    Please contact me if you would like to learn more about the services we provide.

    Thank you.
    Shane Wisdom
    www.wisdomtrading.com

    ReplyDelete
  6. Hi Rob,
    first of all, thanks for writing the book, I found it really detailed and helpful.

    I've noticed a minor bug, in a summary just below Table 37, last item "Trailing stop loss when short" has a bug in math: $30 + (4 * $1.5) = $46

    Thanks!
    Goran

    ReplyDelete
  7. Hi Rob,
    In your book you mention how hard it is to overcome the costs in spread betting. For most EU citizens winnings on spread betting is tax free. Is that part of that calculation? Cheers

    ReplyDelete
    Replies
    1. No I didn't include tax in the calculation. But spread betting is around 10 times more expensive than say trading futures. Tax would need to be insanely high on futures to make spread betting more competitive.

      Delete
    2. Ok, yes that is pretty sick. When is the new book coming?

      Delete
  8. Hi Rob,
    Have you done any covered call writing? It seems like a good fit for a systematic trading system. Cheers

    ReplyDelete
    Replies
    1. I haven't, but yes short volatility strategies like this are a good thing.

      Delete
  9. Hi Rob,
    I came across your website while looking for someone who uses python for trading. Thankfully I found you. I would like to thank you for the informations you share with us.
    I am totally interested in your book. However, I have a question about the content. Do you explain a strategy that you use to trade futures or strategies that can be employed? Because I never trade futures and I would like to start to trade by learning step by step from guidelines of your book if that is the case. What should I expect from your book?
    Thanks in advance.

    ReplyDelete
    Replies
    1. Hi. Yes I explain some basic strategies to trade futures (also ETF's and spread bets). But they assume some familiarity with futures already. Read something like https://www.amazon.com/Trading-Commodities-Financial-Futures-Step-/dp/0134087186/ (first four chapters)

      Also there isn't any python in the book.

      Delete
  10. Hi Rob,

    after reading your book, your blog (here) and your journal (Elitetrader) I decided to give it a try to program a system based on the framework you propose in your book. My question is about the update rate you use during live trading? Your book emphasizes to not trade too much due to the involved costs. On the other hand, from your journal I get the impression that your system runs continuously as time stamps are all around the clock. How often do you refresh/recalculate instrument parameters such as volatility, and account parameters such as volatility target? I was thinking myself to calculate account parameters once per day, preferably on a moment when all instruments are not trading (account value relatively stable). And recalculate instrument parameters once per hour (only when they are trading). Should I sample instrument parameters more often?

    ReplyDelete
    Replies
    1. It depends on your holding period. Currently I probably update too much (hourly), given a holding period of a couple of weeks or more. I could easily update everything daily, and indeed in the next iteration of my code that is what I plan to do.

      Delete
    2. Thank you. As my trading rules will be slow do I expect similar holding periods. A daily update rate will probably be fast enough. However, with several exchanges in multiple time zones involved does that lead to the question: "what is end of day?" Maybe I'll decide to take action at the end of the trading day of each involved exchange.

      Delete
  11. Hi Rob, I think I noticed an error in your new Carry calculation worksheet (https://docs.google.com/spreadsheets/d/1ipugeBCk_W-K4_9wnQmU6RfVvZoIRzFfKrw3ly-h8QA/edit?usp=sharing). Cell G22 has: "=IF(AND(C22<>0,F22<>0,C22-F22),C22-F22,G21)". I think you should delete the third element in the "And" function.

    ReplyDelete
    Replies
    1. Fixed. Thanks a lot

      Interesting how Excel casts into logical type.

      Delete
    2. Glad to help, thanks for all your advice in response to all my posts. I have been paper-trading your "Chapter 15" system for a few days now. Could you please confirm the following with regard to your carry strategy: On November 4th, the closing price of Dec 2016 Eurodollar was 99.075, and the closing price of Jan 2017 Eurodollar was 99.070. Therefore the trading signal would be long. So, I should be long the Jan 2017 contract, correct? What if the spread was significantly higher on the Jan 2017 contract. Would it be okay to go long the Dec 2016 contract? Would there be any reason to look at the Jan vs Feb 2017 contract, or should we always be looking at the closest two contracts in determining the forecast? Thanks.

      Delete
    3. Which contract you should trade I discuss more here: http://qoppac.blogspot.co.uk/2015/05/systems-building-futures-rolling.html . How to measure carry I discuss more in the appendices of my book.

      Delete
  12. Hi Rob, in your book you mention that is preferable to measure carry on equity futures by using the spot price. Yet, in your python system, for EUROSTX, you use the further contract (which is not held) versus the nearer contract (which, of necessity, must be held). A second question, if I may: you mention in your book that you target 37.5% annual volatility in your own futures system, but fundseeder reports your annual volatility at about 8%. Do you know why? Thanks.

    ReplyDelete
    Replies
    1. a) It's preferable to use spot, but I don't personally do it because of the hassle of getting sychronised data.

      b) I can't remember exactly what I said in my book but I target 25%. But the fundseeder figures is lower because I have set a higher notional account value. More here https://www.elitetrader.com/et/threads/fundseeder-my-experience.298394/

      Delete