A REST API for pysystemtrade metrics, created with Flask
- read ony, designed to be useful for monitoring, metrics or telemetry
- allows access to pysystemtrade data such as:
- process status
- capital
- positions
pysystemtrade is not published on the Python Package Index, so by default it is defined as a git dependency:
[tool.uv.sources]
pysystemtrade = { git = "https://github.com/robcarver17/pysystemtrade" }
But if you have the API app running on the same machine, you could define it as a local editable dependency instead
$ uv remove pysystemtrade
$ uv add --editable /home/user/path/to/pysystemtrade
One way to pick up the pysystemtrade config is to use the PYSYS_PRIVATE_CONFIG_DIR environment variable, as described here
PYSYS_PRIVATE_CONFIG_DIR=/home/user/private_config_dir flask --app pst_flask_api run
Using this technique, the file could be the same file as used by pysystemtrade, or not. It can be anywhere you specify, but must be called private_config.yaml. The only config values needed are those for MongoDB, and path to Parquet files
mongo_host: 127.0.0.1
mongo_db: production
mongo_port: 27017
parquet_store: /home/user/data/parquet
So, if you are using the default mongo configuration, you would only need the parquet one
process status: http://127.0.0.1:5000/process
- sample output, pretty for readability
capital: http://127.0.0.1:5000/capital
- sample output, pretty for readability
positions: http://127.0.0.1:5000/positions
- sample output, pretty for readability