How to Run a Screen Backtest Using the API in Google Colab

Example on running a screen backtest and charting the results using the p123api wrapper

Marco Salerno
Written by Marco SalernoLast update 25 days ago

In this article I will demonstrate running a screen backtest using the Screen Backtest function in the API wrapper p123api on Google Colab. Google Colab allows you to write and execute python code through the browser. For more info on the p123api wrapper click here

You will need a google account to run it. The sample has two sections of code. The first code section runs the backtest and stores the results in a variable called 'sb'. Every statistic that you see on the website will be stored in 'sb'. Run this code section as follows:

  1. Enter your API ID and KEY

  2. Change any settings you like (see the screen backtest API documentation here)

  3. Press Play

The first time you run this it will install the p123api in your Colab environment. Next it runs the screen backtest and stores the output in a JSON variable 'sb' which is printed at the end. The output should look similar to this:

The second section of the code produces more humanly readable output. Click the Play icon to run it.

First it draws a chart

Then it prints a table of the data with a sampling of the rows

Did this answer your question?