2
$\begingroup$

I am trying to run a local backtest using Python and Zipline seems to be the most popular package out there. Does any one have isnight on ingesting fundamental data for the backtest? The documentation is limited on the topic.

Alternatively if anyone has other suggestions on backtesting fundamental data that would be welcome as well.

$\endgroup$
1
$\begingroup$

Unlike price data which is ingested as a bundle, fundamental data in Zipline is usually used via Pipeline and thus requires writing a custom PipelineLoader that knows how to load the particular fundamental dataset you're using. I'm not aware of much documentation for writing a custom PipelineLoader apart from digging into the source code.

As an alternative, QuantRocket supports pulling Reuters Worldwide Fundamentals via Interactive Brokers and backtesting with either Zipline or Moonshot. The demo repository contains a sample HML strategy for Moonshot as well as one for Zipline.

$\endgroup$
  • $\begingroup$ @nosigma If this answer clears up what you were looking for—please mark it as accepted. $\endgroup$ – ofey73 Sep 6 '18 at 18:21
0
$\begingroup$

An online alternative I used in the past is Quantopian - the authors of Zipline. Python based, sign up is free, access to Morningstar Fundamentals, excellent inbuilt research environment using Jupyter, great tear sheets for backtesting, very good tutorials + documentation, and a very active community.

You can submit your algorithms to compete in a contest, and receive direct funding.

$\endgroup$
0
$\begingroup$

Backtesting.py supports any kind of OHLC data. If you'd like to feed it other fundamental data, you just add extra columns to the input data frame.

$\endgroup$
  • 1
    $\begingroup$ On that link are you claiming that George Soros and Warren Buffett are "Users" of your python library?? To be honest I don't believe that and it puts me off what otherwise seems to be good developmental work. $\endgroup$ – Attack68 Jan 18 at 13:44
0
$\begingroup$

I think the best way is not using Python lib since it can difficult to see what code is behind, even if you can have access to the source code. The best way is to develop your own BT, using the following structure :

  1. A script for loading data (you have two solutions, first there are plenty of paying API for loading data. In my case, I use BeautifulSoup package to scrap data from Yahoo, google, etc. You can have access to historical and tick data). This script will load data and format your data (best way is as series since its faster). You can also use the MongoDB or DropBox API. In my case, I use free dropbox API to store my database and my script will request this API
  2. A Main script for the BT. For exemple an Abstractclass "Backtester". And the, you will create "EquityBasket(Backtester)", "MeanReversion(Backtester)" etc for each strategies; These scripts will be purely maths script to compute the weights, quantities, returns etc
  3. The same structure of script as for Backtester but for algorithm used. In fact, you will have the possibility, in "MeanReversion(Backtester)" to create a self._model(XX) and then in the compute of the mean reversion signal for exemple : signal : self._model.get_signals() etc
  4. Finally, a kind of console to call each script. The parameters should be store as a JSON in a txt file to make in the console : params = get_params_from_json, bt = MeanReversion(params), and then res = bt.run.

I hope it's clear, i have work on many BT scripts, do not hesitate if you have further questions

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.