Automated paper trading desk for quantitative trading strategies. Allows club members to develop, deploy, and run their own trading strategies in an isolated environment.
- Go Server - Central trading desk that communicates with Alpaca API
- Python Strategies - User trading strategies running in isolated Docker containers
- Protocol Buffers - Efficient communication between strategies and server
- SQLite Database - Trade history and strategy management
Using Makefile (recommended):
make setupOr using scripts directly:
./scripts/setup.shThis will:
- Check dependencies (Go, Docker, Python, protoc)
- Generate protobuf code
- Build the Go server
- Build the strategy Docker image
# Copy example environment file
cp .env.example .env
# Edit .env with your Alpaca API credentialsUsing Makefile:
source .env && make runOr using scripts:
source .env && ./scripts/run_server.shThe server will start on http://localhost:8080
Using Makefile:
make deploy # Deploy all strategies
make status # Check status
make stop # Stop all strategiesOr using scripts:
./scripts/deploy_strategies.sh start
./scripts/deploy_strategies.sh status
./scripts/deploy_strategies.sh stopDesk/
├── src/
│ ├── server/ # Go trading desk server
│ │ ├── cmd/server/ # Main server entry point
│ │ ├── internal/ # Server implementation
│ │ ├── go.mod
│ │ └── README.md
│ ├── strategy-env/ # Python strategy environment
│ │ ├── desk_client/ # Python client library
│ │ ├── examples/ # Example strategies
│ │ ├── strategies/ # User strategies go here
│ │ ├── Dockerfile # Strategy container image
│ │ ├── deploy_strategies.sh
│ │ ├── strategy_manager.py
│ │ └── README.md
│ └── protos/ # Protocol buffer definitions
│ └── order.proto
├── scripts/ # Build and deployment scripts
│ ├── setup.sh # Complete setup
│ ├── build_server.sh # Build Go server
│ ├── build_strategy_image.sh
│ ├── generate_protos.sh # Generate protobuf code
│ ├── run_server.sh # Run server
│ ├── deploy_strategies.sh
│ └── clean.sh # Clean artifacts
├── bin/ # Compiled binaries (gitignored)
├── docs/ # Documentation
├── Makefile # Build automation
├── .env.example # Example environment variables
├── .gitignore # Git ignore rules
└── README.md
mkdir -p src/strategy-env/strategies/my_strategy
cd src/strategy-env/strategies/my_strategy#!/usr/bin/env python3
import json
import sys
from desk_client import place_order
def main():
for line in sys.stdin:
market_data = json.loads(line.strip())
symbol = market_data.get("symbol")
price = market_data.get("price")
# Your trading logic here
if price < 150.0:
response = place_order(
symbol=symbol,
qty="10",
side="buy",
order_type="market",
time_in_force="day"
)
if __name__ == "__main__":
main(){
"user_id": "your_username",
"name": "My Trading Strategy",
"description": "Strategy description",
"version": "1.0.0",
"env": {
"CUSTOM_VAR": "value"
}
}./scripts/deploy_strategies.sh start| Command | Description |
|---|---|
make setup |
Complete initial setup |
make build |
Build server and strategy image |
make server |
Build Go server only |
make strategy-image |
Build strategy Docker image only |
make proto |
Generate protobuf code |
make run |
Start the trading desk server |
make deploy |
Deploy all strategies |
make stop |
Stop all strategies |
make status |
Check strategy status |
make clean |
Remove all built artifacts |
make clean-docker |
Clean + remove Docker containers/images |
make rebuild |
Clean, regenerate protos, and rebuild |
make help |
Show all available commands |
| Script | Description |
|---|---|
scripts/setup.sh |
Complete initial setup |
scripts/build_server.sh |
Build Go server binary |
scripts/build_strategy_image.sh |
Build Docker image for strategies |
scripts/generate_protos.sh |
Generate protobuf code |
scripts/run_server.sh |
Run the trading desk server |
scripts/deploy_strategies.sh |
Deploy/manage strategies |
scripts/clean.sh |
Clean built artifacts |
- Technical Design Document - Complete architecture documentation
- Strategy Environment README - Strategy development and deployment guide
Using Makefile:
# Rebuild server after Go code changes
make server
# Regenerate protobufs and rebuild everything after .proto changes
make rebuild
# Rebuild strategy image after Python library changes
make strategy-imageOr using scripts:
# Rebuild server after Go code changes
./scripts/build_server.sh
# Regenerate protobufs after .proto changes
./scripts/generate_protos.sh
./scripts/build_server.sh
./scripts/build_strategy_image.sh
# Rebuild strategy image after Python library changes
./scripts/build_strategy_image.sh# Build server manually
cd src/server
go build -o ../../bin/trading-desk ./cmd/server
# Build strategy image manually
docker build -t trading-desk-strategy src/strategy-env/
# Run server with custom config
DB_PATH=./custom.db PORT=3000 ./bin/trading-desk- Go 1.23+
- Docker
- Python 3.8+
- Protocol Buffers compiler (protoc)