Stockholm is a laboratory for algorithmic trading.
Once Stockholm is installed, you can run it from the command line as follows:
stockholmHere are the supported command-line options:
Usage: stockholm [OPTIONS] [COMMAND]
Commands:
backtest Backtest a trading strategy
run Run the trading bot (default)
historical Fetch historical market data as CSV
infer Run inference with a trained neural network
train Train a neural network on historical stock data
help Print this message or the help of the given subcommand(s)
Options:
--address <ADDRESS> Address of the running TWS or IB Gateway API [default: 127.0.0.1:4001]
--client-id <CLIENT_ID> Client ID to use for the API connection [default: 100]
-v, --version Print version
-h, --help Print help
You can evaluate the buy-and-hold, market-maker, and market-maker grid-search strategies over historical CSV files with the backtest subcommand. Run stockholm backtest --help for the available strategy parameters.
stockholm backtest --strategy buy-and-hold --data-paths historical_data/validation/*.csv
stockholm backtest --strategy market-maker --data-paths historical_data/validation/*.csv
stockholm backtest --strategy market-maker-grid --data-paths historical_data/training/*.csv
stockholm backtest --strategy neural-net --data-paths historical_data/validation/*.csvUse the run subcommand to trade a symbol with the live strategy:
stockholm run --symbol AAPLUse the historical subcommand to fetch historical bars as CSV:
stockholm historical --start 2026-07-31T13:30:00Z --end 2026-07-31T20:00:00Z --symbol SOXL --interval MIN5Use the train subcommand to train a forecasting model from separate training and validation datasets, then use infer to load the saved model and generate timestamped probabilities for the lower barrier being reached first, the upper barrier being reached first, or neither barrier being reached. Run either subcommand with --help for its data and configuration options.
stockholm train --training-paths monday.csv tuesday.csv --validation-paths wednesday.csv
stockholm inferGenerate SVG overlays of the open price and upper_probability - lower_probability for every validation file with the plotting script. Pass one or more CSV paths to plot a different selection.
./plot-inference.rb
./plot-inference.rb historical_data/training/SOXL-2026-06-15.csvYou'll also need to start an Interactive Brokers Gateway that Stockholm can talk to. You can run that in a Docker container via the provided run-ib-gateway.sh script:
./run-ib-gateway.shThe script expects the Interactive Brokers username to be in a file called $HOME/ib-username, and it looks for the password in $HOME/ib-password.
You probably want to run Stockholm and IB Gateway as daemons, e.g., with launchd or systemd. See the Configuring your operating system to run Stockholm as a daemon section below for instructions.
For debugging, you can connect to the VNC server at vnc://127.0.0.1:5900 using the default password vnc_password. In macOS, you can do this from Finder with Cmd+k.
Stockholm assumes a US Equity and Options Add-On Streaming Bundle (NP) market data subscription.
If you're running macOS or Linux (AArch64 or x86-64), you can install Stockholm with this command:
curl https://raw.githubusercontent.com/stepchowfun/stockholm/main/install.sh -LSfs | shThe same command can be used again to update to the latest version.
The installation script supports the following optional environment variables:
VERSION=x.y.z(defaults to the latest version)PREFIX=/path/to/install(defaults to/usr/local/bin)
For example, the following will install Stockholm into the working directory:
curl https://raw.githubusercontent.com/stepchowfun/stockholm/main/install.sh -LSfs | PREFIX=. shIf you prefer not to use this installation method, you can download the binary from the releases page, make it executable (e.g., with chmod), and place it in some directory in your PATH (e.g., /usr/local/bin).
If you're running Windows (AArch64 or x86-64), download the latest binary from the releases page and rename it to stockholm (or stockholm.exe if you have file extensions visible). Create a directory called Stockholm in your %PROGRAMFILES% directory (e.g., C:\Program Files\Stockholm), and place the renamed binary in there. Then, in the "Advanced" tab of the "System Properties" section of Control Panel, click on "Environment Variables..." and add the full path to the new Stockholm directory to the PATH variable under "System variables". Note that the Program Files directory might have a different name if Windows is configured for a language other than English.
To update an existing installation, simply replace the existing binary.
If you have Cargo, you can install Stockholm as follows:
cargo install stockholmYou can run that command with --force to update an existing installation.
Stockholm depends on IB Gateway, so the repository provides sample service definitions for running both programs as daemons. Adjust the paths, arguments, and other settings in these files as needed before installing them.
On macOS, launchd can be used to run Stockholm and IB Gateway as daemons. Copy local.stockholm.plist and local.ib-gateway.plist from the service_configs directory to /Library/LaunchDaemons/, copy run-ib-gateway.sh to /usr/local/bin/, and make sure all three files are owned by root.
Run the following commands to start the services:
sudo launchctl load /Library/LaunchDaemons/local.ib-gateway.plist
sudo launchctl load /Library/LaunchDaemons/local.stockholm.plistYou can view the logs with tail -F /var/log/ib-gateway.log /var/log/stockholm.log.
On most Linux distributions, systemd can be used to run Stockholm and IB Gateway as daemons. Copy stockholm.service and ib-gateway.service from the service_configs directory to /etc/systemd/system/, copy run-ib-gateway.sh to /usr/local/bin/, and make sure all three files are owned by root.
Run sudo systemctl enable ib-gateway stockholm --now to enable and start the services. You can view the logs with sudo journalctl --follow --unit ib-gateway --unit stockholm.