Stratis is a python-based framework for developing and testing strategies, inspired by the simplicity of tradingview's Pinescript. Currently, stratis is in the early stages of development, and is not yet ready for production use. However, it is encouraged to try it out and provide feedback via GitHub issues.
Stratis is a part of Shenandoah Research's Open source Trading Software Initiative and developed by Polyad Decision Sciences software engineers!
The following code demonstrates how to create a strategy that prints the timestamp and close price of the
OHLC data every hour. The on_step
decorator is used to run the function on every step of the OHLC data. You can find
more info about how to create strategies here.
Using the Strategy
class, along with the on_step
decorator, you can create strategies that are as simple or as complex as you want, with
the full power of python at your disposal.
class OHLCDemo(Strategy):
@on_step # the on_step decorator runs the function on every "step" of the OHLC data
def print_ohlc(self):
# strategy shorthands for the OHLC data
timestamp = self.data.timestamp
close = self.data.close
# if the timestamp is a multiple of 3600000 (1 hour), print the timestamp and close price
if timestamp % 3600000 == 0:
print(f'{timestamp}: {close}')
data = CSVAdapter('data/AAPL.csv')
strategy = OHLCDemo().run(data)
It is heavily recommended to use Docker to run stratis. This is because stratis requires a number of dependencies that can be difficult to install.
To install Docker, follow the instructions here.
Once Docker is installed, you can run stratis by running the following command:
# Clone the repository
git clone https://github.com/robswc/stratis
# Change directory to the repository
cd stratis
# Run the docker-compose file
docker-compose up -d # -d runs the container in the background
For more advanced usage, you can run app with python directly. To do this, you will need to install the dependencies
listed in the requirements.txt
file. You can do this by running the following command:
pip install -r app/requirements.txt
You can now run the app by running the following command:
cd app # change directory to the app folder
python python -m uvicorn main:app --reload # reloads the app on file changes (useful for development)