Once you've built your full trading strategy, it's time to assess its performance under realistic conditions. On Quantopian, simulating a trading strategy with realistic conditions over historical data is called backtesting.
During the early alpha discovery stage of researching an investment strategy, Alphalens is the best tool for analyzing the effectiveness of a signal. With Alphalens, it is easy to iterate on ideas quickly. However, Alphalens explicitly ignores real world trading conditions like transaction costs, liquidity and more, which can render a signal untradable. Using Alphalens alone is not enough to confidently identify a successful trading strategy.
On Quantopian, backtesting is the best way to evaluate a strategy with realistic trading conditions. Backtesting simulates trades over minute-frequency historical data taking things like trading costs, order filling, and liquidity into account. Backtesting typically takes longer than signal evaluation with Alphalens, so it's best to start backtesting once you've identified an alpha factor that looks promising. You can backtest a trading strategy by implementing it as an algorithm in the IDE and pressing "Run Full Backtest". Below are some real world conditions that are modeled in the Quantopian backtester.
Whenever a trading algorithm places an order, the order affects the market. A buy order drives prices up, and a sell order drives prices down; this is generally referred to as the "price impact" of your trade. The size of the price impact is driven by how large your order is compared to the current trading volume. Price impact is included in a slippage model in backtesting. The slippage model also evaluates whether your order is simply too big: you can't trade more than market's volume, and generally you can't expect to trade more than a fraction of the volume. Price impact and order filling are wrapped in the slippage model of a backtest.
Brokerage firms usually charge a fee to process trades. Fees associated with trading assets are called "commissions". Commissions can have a significant impact on the returns of a strategy if it trades too frequently so it's important to model commissions in a backtest. On Quantopian commissions are modeled in backtesting.
After running a backtest, it is important to analyze the results to learn more about the behavior and performance of your strategy. Full backtests already have several metrics and plots available to help you analyze the result. You can also get deeper insight into the performance of your algorithm by creating a Pyfolio tearsheet.
To get a better sense of what you should be looking for in the results of a backtest, watch this tearsheet review webinar.