# Tag Info

27

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....

16

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) ...

15

If you do this, you would destroy the value of the statistical tests that you performed on the backtest. You had a hypothesis that the strategy would make money, but the hypothesis was rejected. You cannot say "I will accept the hypothesis that the opposite strategy is successful"; no statistician would agree with this conclusion. In that case, you might as ...

15

This is a very difficult question. First of all you should read Almgren's slides on the topic: Using a Simulator to Develop Execution Algorithms. First you need to backtest your strategy against a "replayer". Ok it is not perfect, but it gives you information anyway. Provided you add some "sanity limitation" to this simulator (i.e. do not allow you ...

9

A Sharpe ratio of at least 1 in backtesting is a promising start, but that is just one of many statistics of interest. The Sharpe ratio measures return per unit volatility, i.e., return per unit risk. Some other important Sharpe-like measures with different definitions of risk include: Return per unit turnover (aka yield): A high yielding strategy is more ...

9

Mostly because of convention and tradition. As Student T mentioned earlier, part of this is that it is common practice. You report to your clients or managers how well something performed in the past; you cannot report to them how well it performed in the future. You may have thought of some useful forward-looking measures, but unfortunately the adoption ...

8

You can find everything you want to know about this here (and in a very readable and easily reproducible form): How Students Can Backtest Madoff’s Claims by Michael J. Stutzer (2009) From the abstract: Markopolos’ writings neither described nor included any specific backtests of the strike conversion strategy. Fortunately, a backtest is relatively ...

7

To elaborate and emphasize a bit on what @Antoine says, using adjusted prices will be reasonable from a returns point of view, with dividends reinvested. That point, dividend reinvestment, is important because dividend reinvestment itself is a backtesting assumption, namely that dividends could be and would have been invested at the price you have in your ...

7

I will be glad to help, but let me first advise you away from working on this topic until you have an academic position. This topic has been poison for me, but I am slogging on anyways. Before you use anything I do, get permission from your academic advisor. I have an unpublished article on options pricing, and I am proposing a new branch of stochastic ...

7

If they publish information about all K trials, then you're right. But the author's point is that that's not typical practice. Typical practice is to not disclose that information, and it amounts to p-hacking where the statistical power of the test differs to what's being advertised.

6

possible update: http://pmorissette.github.io/bt/ based on http://pmorissette.github.io/ffn/ both were easily installed and somewhat usable for a novice. would love some examples other that github documentatiion

6

I think you are having it backwards: Optimising your lookback period is a sure recipe for disaster because it introduces data snooping bias. To develop a robust trading strategy you have to check whether it is sufficiently stable with different lookback periods (e.g. in a certain range). If results differ significantly that is a good sign that your system ...

6

While I've never used SIT, I have used quantstrat quite a bit and can attest to its strength. It has a solid developer community backing it (7 contributors on Github), is part of the TradeAnalytics project on R-Forge, and while it's still technically in beta, it should provide plenty of functionality. There is admittedly a pretty steep learning curve when ...

6

How can a trading strategy that happened to perform well in one sample path be guaranteed to perform as well out of sample? I think you are having it backwards - this is how I do it: Intuition about some economic, psychological, behavioral, technical etc. phenomenon. Trying to make my intuition precise in the form of a hypothesis. Trying to translate my ...

6

QuantConnect uses L1 data (bid and ask quotes) for its US Equities Backtesting. QuantConnect has a full break down of the data library, including free data for download in LEAN format at the data library page: https://www.quantconnect.com/data The open-source LEAN algorithmic trading engine can support trades and quotes, however, on QuantConnect website the ...

6

Proper backtesting is difficult, because of various biases that easily slip into the results if you are not careful. For example how do you compute historical P/E's. Well, you have historical E's and historical P's so you can divide P by E (as Dimitri Vulis suggests it is better to divide E by P, as most academic studies do). However beware of look ahead ...

5

Quantopian provides both the fundamental data (from Morningstar), as well as the backtest platform to reproduce results from the books you mentioned. Here's the introduction to our fundamentals offering: https://www.quantopian.com/posts/fundamental-data-from-morningstar-now-available-for-backtesting (disclosure: I'm the ceo of quantopian)

5

My understanding, in that context, is that signal indicates that you want to hold a share (signal is 1) or hold no shares (signal is zero). Therefore taking the diff will tell you if you want to buy (signal zero to 1, diff is 1), sell (signal 1 to zero, diff is -1) or do nothing (signal stays at zero or stays at 1, diff is zero).

5

The problem you describe isn't trivial. Mainly because once you have it solved for all current known cases someone will figure out a way to do something different and mess up your system. Here are some approaches that I have seen somewhat successfully used. I won't claim they will give you complete coverage of every case, but they may give you some ideas to ...

5

Trying to determine the historical market cap is difficult (especially with mergers/acquisitions/demergers and multiple share classes with different levels of ownership/voting). Another issue with looking at a fixed market cap level is that it's providing a form of selection bias. The further back you go in time, the less stocks will be included due to the ...

5

You are right to be sceptical of the beta of an international portfolio when it is calculated using daily returns. Beta estimates are often low for international portfolios because stock market returns are asynchronous. For example, Tokyo and the New York Stock Exchange have very different trading hours. Portfolios constructed with a tilt towards either ...

5

The answer above is not correct. Let's go by parts: Denote the mean of returns $\mu$. Denote the standard deviation of returns: $\sigma$. Therefore the sharpe ratio is: $$SR = \frac{\mu-r_f}{\sigma}$$ The corresponding standard errors are: $$se(\hat{\mu}) = \frac{\sigma}{\sqrt{t}}$$ $$se(\hat{\sigma}) = \frac{\sqrt{2} \sigma^2}{\sqrt{T}}$$  se(\hat{SR})...

5

My answer is similar to the one given for this other question. If you are mainly using the data for backtesting, there's very little reason to store the data in a MySQL database. The data generally follows a write-once, read-many (WORM) pattern, with no need for ACID semantics. You also don't have to enforce referential integrity on most of the data. If you ...

5

This was too long for a comment, so I'm writing it as an answer. I have provided some interesting literature that will give you insight into the common pitfalls of backtesting algorithmic trading strategies. Marcos Lopéz de Prado on backtesting: Marcos Lopéz de Prado provides some very good slides giving you a quick introduction to the goal of backtesting, ...

4

Providing my 2 cents here, listing 3 free methods below: CBOE's method: No code here, just a "white paper", thus you can code it with whatever language you desire. I kinda like this the most (disregarding how far off this could be from the reality). https://www.cboe.com/publish/micropdf/CBOE-SP500-Iron-Condor-CNDR-Methodology-Paper.pdf ...

4

These are the libraries I most prominently use for C++: QuantLib Boost C++ Libraries This is not specifically a library however it is extremely helpful, the Anaconda Compiler Tools. The Armadillo C++ library for linear algebra & scientific computing. The Intel Math Kernel Library for C++ (MKL). The Ta_Lib Technical Analysis Library has an API for C/C++...

4

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 ...

4

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 ...

4

The general idea For equity securities, a simple backtest will typically consist of two steps: Computation of the portfolio return resulting from your portfolio formation rule (or trading strategy) Risk-adjustment of portfolio returns using an asset pricing model Step 2 is simply a regression and computationally very simple in Matlab. What's trickier is ...

4

There are plenty of sites you can get this information from. etfdb.com and etf.com are two of the bigger ones. See this for an example: http://etfdb.com/etfdb-category/europe-equities/ http://etfdb.com/tool/etf-stock-exposure-tool/

Only top voted, non community-wiki answers of a minimum length are eligible