A high-performance automated trading system built with Rust, designed to execute trading strategies based on webhook alerts from TradingView or other sources.
- Webhook Alert Processing: Receive and process trading signals via HTTP webhooks
- Multiple Broker Support: Currently supports Alpaca with extensible architecture for additional brokers
- Strategy Management: Configure and manage multiple trading strategies with different parameters
- Order Management: Automated order placement with retry logic and error handling
- Asset Support: Trade both crypto and stock assets
- RESTful API: Complete API for account management, positions, orders, and activities
- PostgreSQL Integration: Persistent storage for alerts, strategies, and trading history
- Docker Support: Easy deployment with Docker and Docker Compose
The system is built as a modular Rust application with the following components:
- API Layer: Axum-based HTTP server handling webhooks and REST endpoints
- Core Trading Engine: Processes trade signals and manages order execution
- Broker Clients: Abstracted broker interfaces for easy integration
- Database Layer: SQLx-based PostgreSQL integration with migrations
- Configuration: Flexible configuration system using environment variables
- Rust 1.70 or higher
- PostgreSQL 12 or higher
- Docker and Docker Compose (optional)
- Clone the repository:
git clone https://github.com/yourusername/market.git
cd market
- Set up environment variables:
cp .env.example .env
# Edit .env with your broker API credentials and database settings
- Run database migrations:
sqlx migrate run
- Build and run the application:
cargo run --bin market
Deploy the entire stack using Docker Compose:
docker-compose up -d
This will start:
- The Market trading system on port 80
- PostgreSQL database on port 5432
The application uses a configuration file and environment variables. Key settings include:
- Broker Configuration: API keys and endpoints
- Database Settings: PostgreSQL connection parameters
- Strategy Parameters: Max retries, retry delays, enabled strategies
- Server Settings: Port and host bindings
POST /webhook
- Receive trading alerts
GET /account
- Get account informationGET /assets
- List available assetsGET /watchlists
- Get watchlists
GET /positions
- List current positionsGET /orders
- List orders with filteringGET /activities
- Get account activities
- Strategy endpoints for CRUD operations (implementation in progress)
market/
├── market/ # Main trading application
│ ├── src/
│ │ ├── api/ # HTTP API handlers and objects
│ │ ├── clients.rs # Broker client implementations
│ │ ├── core.rs # Core trading logic
│ │ ├── strategy.rs # Strategy definitions
│ │ └── main.rs # Application entry point
│ └── migrations/ # Database migrations
├── m-cli/ # CLI tool (in development)
├── docker-compose.yml
└── Dockerfile
cargo test
cargo build --release
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is proprietary software. All rights reserved.