43

Consider the standard error, and in particular the distance between the upper and lower limits: \begin{equation} \Delta = (\bar{x} + SE \cdot \alpha) - (\bar{x} - SE \cdot \alpha) = 2 \cdot SE \cdot \alpha \end{equation} Using the formula for standard error, we can solve for sample size: \begin{equation} n = \left(\frac{2 \cdot s \cdot \alpha}{\Delta}\...


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


18

I did some digging and found the following papers - most of them offering quite a distinct perspective compared to classical option pricing theory! Stock Options as Lotteries by Brian H. Boyer et al. (2011) The Efficiency of the Buy-Write Strategy: Evidence from Australia by Tafadzwa Mugwagwa et al. (2010) The following is my favorite: You could do some ...


16

I unfortunately can't point you to a great book on the exact subject that you're describing. The closest thing for beginners is "Quantitative Trading". It's a reasonable introduction, but I really wouldn't recommend it as a primary source. The author is at best incomplete (if not misleading) on a number of issues. My favorite book at the moment is ...


16

You're not really asking how to backtest a strategy. You already have run a backtest to generate simulated trades. What you're asking for is a way to assess the performance of those simulated trades. You can do this with the R package blotter. You'll need to setup your account and portfolio, then loop over each row in your CSV and call addTxn. For ...


15

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


13

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


12

I'll not say how most people do it, but rather how I think most people should do it. You should compare the actual strategy with a number of goes of randomly trading through the time period using the same constraints as the strategy. Basically this is a way of not mixing species of fruit and seeing what the distribution of luck is for the particular fruit ...


11

Interestingly enough there is no scientific theory that suggests what fraction of the data should be assigned to training and testing and results can be very sensitive to these choices. From Quantitative Trading by Ernest Chan (p. 53-54): Out-of-Sample Testing Divide your historical data into two parts. Save the second (more recent) part of the data ...


11

I find this one very helpful: Re-Examining the Hidden Costs of the Stop-Loss by Wilson Ma, Guy Morita, Kira Detko Abstract: In this paper, we present general implications of the impact of stop-losses to future returns. The use of stop-losses change return distributions, but not in the way that one would typically expect. We find that while stop-...


9

Since I, too, have been very interested in this question, I will share some of my findings in the dual hope of encouraging comments on the papers and eliciting more activity on this question. Ammann, Skovmand, and Verhofen (2008): Implied and Realized Volatility in the Cross-Section of Equity Options Ang, Bali, and Cakici (2010): The Joint Cross Section of ...


9

This is an evergreen. I've been discussing this with many people - without any clear-cut conclusion. The answer and the preferred solution depend on your trading style (e.g. frequency), your skills, the size of the team, and many other factors. For simplicity, I call "Research" the Matlab/R/etc. environments, whereas "Live" refers to the re-programmed C++/...


9

High VIX arguably leads to less predictability of the market factor (i.e. market timing), but high volatility does lead to greater predictability of the cross-section of returns. Indeed, linear risk factor models have higher explanatory power during bear markets. However, your goal is to build a better market timing model where the forecasts (and perhaps ...


9

We cannot give you a relative bid-ask spread that would make sense. The reason for that is that it really depends on several parameters: The type of financial asset you invest in (futures, funds, index, options, ...) The period during which you're trading (I think the liquidity in markets hasn't been the same over time). If you trade intraday, it depends on ...


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


8

Glad people are reading. Simple with more history in terms of time and indexes is better in my book. I have spent 13 years reading over 200 research papers, incorporating complicated and advanced techniques, and studying very reputable buy side research with no improvement in results. Readers are on their own to extend to lots of markets including Nikkei ...


8

The short answer (which represents one way of surely many ways to do it) is to watch the t-stat of a performance metric such as information coefficient vanish over time. IC is the correlation of predicted expected returns from your alpha strategy to the underlying benchmark. Look at the expected returns your alpha strategy predicted over the past N time ...


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


8

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


7

The only benefits I can imagine from re-coding in C++ would be speed. But speed doesn't seem to be a concern for your time horizon (especially if you write efficient Matlab code). Some may argue that C++ is more stable, but Matlab is plenty stable for live trading. However, the downsides of using two languages are even more significant than just ease of ...


7

For starters, I am not even sure why you need to ask this question. There is literally years of free tick data available for FX, just check out quant.SE's data wiki. Having said that, a Gaussian is a very poor fit to high-frequency data, particularly FX. Your strategy for simulating data depends on the idea behind the simulation. If you wish to actually ...


7

Yes, there is in fact a whole literature on this subject coming from the field of non-linear dynamics-- it is known as the method of surrogates. The idea is essentially to come up with a "scrambled" version of your original data set that preserves many of the basic statistical properties, though perhaps not the serial dependence structure which might be ...


7

This is a partial explanation in that trading strategies with longer horizons have higher information ratios, t-statistics, slope coefficients, and R^2 in general. In other words, if information ratios for both strategies are identical then the longer-term trading strategy is already worse. John Cochrane illustrates how longer horizons have higher t-stats ...


7

There is a huge difference between R (and Matlab, SAS, or other statistical languages) and relatively low-level languages such as C/C++/C#/Java in exactly this regard. The latter category is used more often for stable end-products, where speed and performance can be crucial, whereas the former category is used more often for model testing and prototyping. ...


7

In this case, the t-statistic is used to determine if the returns are statistically different from zero (the theoretical mean). A small t-statistic would imply that the null hypothesis (no significant excess return) cannot be rejected. Newey-West standard errors are used to correct for the correlations of error terms over time. I have written a Matlab ...


7

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


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


6

There are many details you need to take into account in order to do a proper backtest. Besides the correction regarding bar entry/exit prices mentioned earlier, you will also need to correct for the bid/ask spread, which may be wider than the high/low for some stocks at some times. Some other details are: Splits Dividends Ticker changes Warrants/rights ...


6

I don't think risk factors are that important here. This is a simple market timing strategy where you're either fully exposed to the market or not exposed at all. All he needs to show is that he's adding value above buy-and-hold by all of the in-and-out trading.


6

I'd say it depends on how close you want to be to reality and what the strategy entails. For instance one scenario when actual currency makes sense is when you want to take contract sizes and position limits into account, for instance agricultural futures contracts nearly always impose a position limit for one party in one or all contracts. If your ...


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