Getting started

The Python-built algorithmic backtester

PyAlgosim provides a simple way for amateur algorithmic traders to get a feel for automated trading. It is meant to be simple to use, and quick to produce results. We are always accepting contributions and suggestions to make the software better!

PyAlgosim allows you to backtest trading strategies accross S&P 500 data from January 2nd, 1998 to August 8th, 2013!

To get started using the PyAlgosim algorithmic trading backtester, you must download the most recent version of the software. You can easily do this by either cloning the repository from GitHub here or directly download the latest release from here.

Requirements

All that is required to start using PyAlgosim is:

  • Python 2.7.X

Project structure

On downloading, the project has a very specific structure that you should keep for everything to work as intended. Alternatively, you could set up your own structure, but it would require additional configuration (and would probably be a pain). After initialization, the project structure should look like this:

.
├── LICENSE
├── PyBank.py
├── PyAlgosim.py
├── README.md
├── raw_data/
├── tests/
└── utils/
    ├── __init__.py
    ├── initialize.py
    ├── reset.py
    ├── stocks.db
    └── tickers.json
          

What's inside tests/ and raw_data/ is not very important. However, note that the initialize.py script accesses the raw_data/ directory to build the database, so you should keep this structure as is.

For PyAlgosim to work, the project structure should stay like this. If you move the stocks.db file or the tickers.json file, you will need to reference them during the creation of a PyAlgosim object.

The program in which you wish to use the PyAlgosim and PyBank modules in should ideally reside in the top-level directory of the project (that is, in the same directory as the PyBank and PyAlgosim files) for everything to run as smoothly as possible.

Initialization

To get PyAlgosim working, you must initialize the project from the directory in which you have placed it. All the backtesting that you wish to do should be done from within this directory, as specified later on in the documentation.

Initialization is required to create the database file which will hold all the stock information, and to create the ticker list that the backtester will use throughout the simulations. To initialize PyAlgosim, go to the command line and type the following commands:

$ cd ~/path/to/PyAlgosim
$ cd ./utils/
$ python initialize.py

That should run the initialization script, which will use the raw_data directory to generate the required files. Once it is done, you can start using PyAlgosim!

Why is initialization necessary?

The database file that PyAlgosim uses to backtest algorithms is too big to upload to GitHub, so the project generates the database file during initialization, using raw .csv files which are much smaller.

Go on to the documentation