Except Zipline, are there any other Pythonic algorithmic trading library I can choose? Especially, for backtesting?
Aside from Zipline, there are a number of algorithmic trading libraries in various stages of development for Python.
From the commercial side, RapidQuant looks very interesting though I haven't tried it yet. It's from some of same developers that brought us the excellent Pandas data analysis library. I think Wes McKinney (Pandas's main author) is involved.
From the open source side, you might check out ultra-finance. It aims to be a fully featured event-driven based backtesting system.
Also check out PyaAlgoTrade. It's coded to allow for distributed testing of strategies on Google's cloud infrastructure. It incorporates the open source TA-Lib technical analysis library.
Finally, take a look at TradeProgrammer. It also uses the TA-Lib library. The package is free to use for backtesting, but its live trading version is commercial.
Aside from that, I think that many proprietary traders build their own systems. There is definitely something to be said for using a tool you understand on that level.
Edit (2016-06-21): Now with live data/trading integration with Interactive Brokers. It has taken a while but it has finally arrived.
Edit (2017-09-20): live data/trading includes Visual Chart and Oanda (legacy accounts), order types, timers and market calendars, update with Python 3.6 and the community and other links updated
A (now) very mature (imho) Python backtesting framework is "backtrader":
- Home Page: https://www.backtrader.com
- Documentation: https://www.backtrader.com/docu
- Blog: https://www.backtrader.com/blog
- Community: https://community.backtrader.com
- Repository: https://github.com/mementum/backtrader
Can run in (pseudo)event-mode (called 'next') or (pseudo)vectorized mode (called 'runonce')
- In "next" mode it can also be configured to work in "exactbars" mode which will keep memory consumption to the minimum (disabling plotting along the way)
Order/Trade notification to strategies (this obviously is always an event)
Supports CSV (some specific sources and a Generic CSV loader) binary sources (VisualChart, Pandas, Blaze) and online (Yahoo Finance Data - beware of the changes/quirks/problems introduced by Yahoo in 2017)
Data Resampling and Data Replaying
Mix datas of different timeframes (including a data and its "resampled" counterpart)
A fine (imho) broker implementation supporting stocks-like and futures-like (with margin) instruments with user implementable commission schemes if needed, including slippage.
The nicest part is cash adjustment for future-like instruments on each bar
Orders: Market, Limit, Stop, StopLimit, StopTrail, Bracket, OCO, Future-Spot compensation, Market-On-Close
Sizers for automated staking
cheat-on-close and cheat-on-open modes to work with already past prices or prices to come, when not having access to lower resolution data
Has a comprehensive list of implemented indicators
Integration with TA-lib
A few analyzers (AnnualReturn, Sharpe, TradeAnalyzer)
Can optimize strategies and use multiple cores for the task
Plotting support via Matplotlib (>= 1.4.1) with a high degree of configurability and flexibility (plots look nice)
A text writer for console output of data points (csv) and datas/strategies/indicators/analyzers summaries
Supports market calendars
Timers even during backtesting
Heavy use of metaclasses and operator overloading in order to implement ease of use and a declarative expression approach for the strategy/indicator logic and implementation
Works with Python 2.7 / 3.2 / 3.3 / 3.4 / 3.5 / 3.6
Disclosure: I am the author having worked during 2015 on this as a hobby project but aiming at making it as feature complete and professional as possible
It is of course left to the reader to decide if the aforementioned statements and goals have been reached
As mentioned by edouard each framework has its own quirks and I actually started this after toying around with pyAlgoTrade and not really liking the API, which is of course a matter of personal taste.
Interactive Brokers hosted a webinar on Nov. 10 2016 about Implement Algo Trading coded in Python using Interactive Brokers API. The presenter gave a good explanation on the applicability of IBridgePy, which is a Python package used to connect to Interactive Brokers C++ API for execution of python codes in live markets.
The webinar was recorded so that you can listen to it anytime you want. The link of the webinar is here: https://www.interactivebrokers.com/en/index.php?f=2227 In the page, IB categorizes their webinars in several topics: TWS, Trading, API, etc. After you click the tab of "API", you will see all of the webinars about API. IBridgePy works like a standalone quantopian and it is much easier than IBpy. IBridgePy can be found here www.IBridgePy.com
One of the greatest things about IBridgePy is that IBridgePy can run Quantopian's codes without any changes! http://www.ibridgepy.com/tutorials/#Migrating_from_Quantopian_to_IBridgePy Disclosure: I am the author of IBridgePy.
There is a module called
visualize-wealth that provides:
- Documentation auto-generation capability with sphinx
- Portfolio construction methodologies in 3 ways (trade blotter, weight allocation frame, and static allocation series)
All basic statistical measures, including many sophisticated ones such as CVaR, Mean Absolute Tracking Error, Cornish Fisher Approximation (to incorporate skew and kurtosis), correlation structure preserving algorithms, Appraisal & Information Ratios, and M^2 (to name a few)
NOTE: The sphinx documentation renders into MathJax equations with clickable links and papers around more academic concepts
- Excel file with manual calculation to most of the analytical calcs, allowing the user to dig into the manual calculations if they should like (the results of this file are actually used as the data to test the module calcs)
- Utilities to work with Yahoo!'s API as well as HDFStores, to construct portfolios from
- Classification algorithms to determine the "likely asset class" of a time series, to enable asset selection and tactical allocation attribution functionality.
FULL DISCLOSURE: I am the developer of the
visualize-wealth module and have been building it entirely on my own for the past 14 months.
I have also been searching for algo trading in Python.
According to my findings:
there are many such librairies available, open-source or proprietary,
they are all built quite specifically. as a result, when you know how to use one, it is the only one you are able to use.
their stage of development is quite heterogeneous and future uncertain, eg what did happen to rapidquant.com cite above?
no such library is well off and outperforming all other competing librairies.
With all the above, I would rather build my own tools as suggested above by someone else.
Take a look at pinkfish. Disclaimer, I am the author.
You can have a look at :
TradingWithPython library (TWP Library) http://www.tradingwithpython.com/.
Like Quantopian / Zipline it uses Python Pandas library.
It includes an Interactive Brokers module to trade realtime.
While still in alpha, I like qstrader: https://github.com/mhallsmoore/qstrader
However they both also have their tools on Github.
QuantConnect GitHub is a open-source C#, F# and Python algorithmic trading platform. QuantConnect data source is QuantQuote compared to Quantopian's data source which is Quandl.
Quantiacs GitHub offers their open-source toolkit in Python and Matlab. Quantiacs uses their own data source.
Data is important to backtesting. Hopefully these two will give you some alternative to implementation and data source.
Trying to start framework which allows lots of flexibility. https://github.com/bpsmith/tia