Back to Community
How to weight backtest for inflation, change-back to home currency, tax and dividends?

How can I take inflation and exchange rates - between the currency required to buy the stock and the investors home currency - into account when back-testing the value of an algorithm?

The first so I know my algorithm can outperform inflation, the second so I know whether if I invest in American stocks (in usd) might I find my returns significantly different when converted back to my home currency (gbp).

While we're at it, could you also take capital gains tax into account?

Also - :P - in a live-trading situation, could these be used for decision making? E.g. If the value of the dollar starts falling against the value of the pound at a fast rate, could you close positions and convert back to home currency? How does quantopian plan to handle home currencies in their live trading solution when it becomes available?

Also, is there any way to take a stocks reputation for paying dividends into account when deciding to buy? Can dividends be reflected in a backtest?

Sorry if I've been asking too many questions on this forum :P

3 responses

Hello Adam,

Regarding performance relative to inflation, perhaps you could write a separate algorithm to buy a comparative security (e.g. sid(38986), Vanguard Short-Term Govt Bd Idx ETF (VGSH)) or a basket of securities. In other words, create your own benchmark.

Nice idea. Would there be a way of adding the inflation as a second benchmark line?

Adam, that is a great list of questions. The short answer, of course, is that anything is possible with code. The longer answer is about prioritization, which things we're going to make easier soonest.

  • We don't have any near-term plans to build in other currencies. That definitely is something that could be built as a function within Quantopian or Zipline. You generally want to compare your algo's performance to the benchmark. I think one way to do it would be to compare your algo to a benchmark that is the S&P traded in pounds. Or, use the Sharpe ratio. It currently shows how your algo is doing compared to the "no-risk" US Government bonds. You could re-compute the Sharpe in your algo and compare it to a different signal, like British bonds.
  • Taxation is also possible, but very complex. There are thousands of different tax regimes across the world. There are a lot of things for us to do before we tackle that gnarly problem!
  • Using currencies as trading signals is definitely on our list - sooner than tax information, for sure. We want to make it easy to add almost any signal to your algorithm, and currency behavior is very high on the list.
  • We haven't put dividends into our database yet, but that is pretty high on the list. We'll do it this winter, I think.

As for adding a second benchmark line, I really want to do that. We've been doing some early design work on adding to our graphing capability. The way it would work is that in your initialization code you'd declare certain variables to be graph able. During your event handling you'd update the value of the variables. Then, in the backtest, you can see your data as a line on the graph. Any feedback on that idea?

Thanks for all the questions Adam. Let me know if I didn't answer one.


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.