Getting Started with backtrader

A few weeks ago, I ranted about the R backtesting package quantstrat and its related packages. Specifically, I disliked that I would not be able to do a particular type of walk-forward analysis with quantstrat, or at least was not able to figure out how to do so. In general, I disliked how usable quantstrat seemed to be. The package’s interface seems flexible in some areas, inflexible in others, due to a strange architecture that I eventually was not willing to put up with anymore.

Continue reading


Transaction Costs are Not an Afterthought; Transaction Costs in quantstrat

DISCLAIMER: Any losses incurred based on the content of this post are the responsibility of the trader, not the author. The author takes no responsibility for the conduct of others nor offers any guarantees.

Introduction: Efficient Market Hypothesis

Burton Malkiel, in the finance classic A Random Walk Down Wall Street, made the accessible, popular case for the efficient market hypothesis (EMH). One can sum up the EMH as, “the price is always right.” No trader can know more about the market; the market price for an asset, such as a stock, is always correct. This means that trading, which relies on forecasting the future movements of prices, is as profitable as forecasting whether a coin will land heads-up; in short, traders are wasting their time. The best one can do is buy a large portfolio of assets representing the composition of the market and earn the market return rate (about 8.5% a year). Don’t try to pick winners and losers; just pick a low-expense, “dumb” fund, and you’ll do better than any highly-paid mutual fund manager (who isn’t smart enough to be profitable).

Continue reading