Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using an orderbook algo to analyse a trade log like collective2 VIX DayTrader

Many quants have multiple accounts... some for algo based trades and some for manual trading.

You might find it informative to replay your manual trades back thru the Quantopian backtester to see what garyha's excellent pvr reporter finds and also run Q's Research pyfolio tool to the backtest.

To me this is a good way to visualize and measure performance. I call it an orderbook algo because the algo isnt thinking on its own; it is just replaying the trades that were made.

Just for fun, I thought I would run it with the trades reported by one of the top traders currently on the collective2 site - JamesFraser's "VIX DayTrader" https://www.collective2.com/details/98408819 .

(Recap: collective2 lets you copy/follow traders who are making trades (presumably) in their own account with real money. The trades are published by collective2 after the position is closed. The orderbook can be downloaded as a CSV and with a bit of data-wrangling converted to a python dictionary. collective2 also does a recreation of the performance using the same technique with lots of backtest metrics as well.)

In this example, the first trade is 17Nov2015. pyfolio needs 6 months of data so the Q backtest starts in Oct so there is few weeks of idling at the start.

Its a fun exercise so I thought I would share how I did it.

Disclosure: I have no connection with collective2 or with the VIX DayTrader trader.

Richard
http://quant-coder.prokopyshen.com

2 responses

Nice Richard - as a user of both Q and C2 always wanted to be able to get both of them to speak (though not happening here, but a step at least) ... interestingly the metrics per C2 and Q are quite different, with C2 showing 68.5% cum return and 13.0%DD - will dig into the methodology difference at some point. Curious as to why converted to a python dict instead of just saving the trade log as a csv and using fetcher?

Umar - I might be underestimating what fetcher can do, but I have generally only used it when I have a time-series. The c2 CSV file is a kitchen-sink full of data that I dont think would be easy to wrangle into a time series for fetcher. I would love to be corrected on this.

I think of tradelogs as a list of events and as a long time python user a dictionary was the tool that came to hand. I wanted to be able to handle multiple trades at the same time which I could do with a dictionary keyed by timestamp with each entry containing a list of trades made. The tactic I used was a form of code generation. I used Excel to reformat the c2 CSV trade log in to the needed python statements to create the lists which I then cut and paste in to python source code.