Automatic Code Generation For Quantopian Platform

We are pleased to announce that Price Action Lab has developed automatic code generation capability for the Quantopian platform.  This new capability will allow our software users to join the Quantopian community and take advantage of the features of this cloud-based backtesting and live trading platform.

The Quantopian platform provides “everything a quant needs to create a strategy and profit from it” and it is free to use. It allows quantitative traders to

  • Develop trading strategies online
  • Backtest strategies on 1-minute data
  • Participate in contests
  • Get a percentage of profits from licensing profitable strategies

At this point the platform can be used with equity and ETF data but there are plans to include futures and forex data.

The new code generation of Price Action Lab allows our customers to join the Quantopian community. This is a significant milestone in the development of Price Action Lab. The user of PAL needs only to copy and paste the generated code in a new algorithm in Quantopian and then compile it and test it there. After the results are available in PAL, the process of generating code for Quantopian and compiling a new algorithm takes less than a minute. Note that code is generated for individual patterns and systems that include both long and short patterns.

Example with full code

An example is available at the Quantopian forum. No registration is required but if you register you can clone the algorithm and perform your own analysis and/or modifications to it. Click here for the forum post.


The strategy code in the Quantopian backtest was generated from Price Action Lab search results. The in-sample for the results was from SPY inception to 12/31/2008 and the results were first published in an article on April 6, 2015. The Quantopian backtest shows realistic results in the out-of-sample from 01/02/2009 to 08/15/2016 based on 1-minute data with the code that was automatically generated by Price Action Lab.

There are 30 price patterns in the strategy, 23 long and 7 short. The patterns were identified in daily bars. The profit target is 2% and the stop-loss is at 4% and in the Quantopian code they are monitored in 1-minute bars. This particular strategy uses only the close of daily OHLC bars. Although the performance is lower than buy and hold, it is out-of-sample performance and free from look-ahead bias. Note that this system is just an example and it is not recommended in its present form for live trading but something similar could serve as a foundation for further development.

Price Action Lab users can just copy and paste generated code in an algorithm in Quantopian. We will continue improving the code generation of Price Action Lab based on feedback received. This is the first version, it has been challenging and the code is basic but it offers a good starting ground.

Instructions for downloading a demo of Price Action Lab can be found here.

Note that in addition to Quantopian code, Price Action Lab generates code for patterns and systems of patterns for Tradestation (EasyLanguage), Multicharts (EasyLanguage), NinjaTrader 7 and Amibroker (AFL), complete pattern code for Wealth-Lab 4 and TeleChart and pattern code for MetaTrader.


This entry was posted in Quantitative trading and tagged , , . Bookmark the permalink.

Leave a Reply