A C++ options trading platform designed for paper trading and strategy development. This modular system provides real-time data processing, options chain analysis, and automated trading capabilities through the Alpaca API.
The project is organized into several modular components:
strawberry-trading/
βββ api/ # HTTP client and API integration
βββ apps/ # Applications (paper_trader)
βββ core/ # Core trading logic and data structures
βββ logging/ # Thread-safe logging system
βββ scheduler/ # Task scheduling and timing
βββ strategies/ # Trading strategies implementation
- API Module: HTTP client for Alpaca API integration with support for options data, market data, and order management
- Core Module: Options chain processing, Greeks calculations, and fundamental trading data structures
- Logging Module: Thread-safe singleton logger with file output and multiple log levels
- Scheduler Module: Task scheduling and timing utilities for trading operations
- Strategies Module: Trading strategy implementations and backtesting framework
- CMake 4.0.3+
- C++20 compatible compiler
- libcurl - HTTP client library
- nlohmann/json 3.12.0+ - JSON parsing and serialization
sudo apt update
sudo apt install cmake build-essential libcurl4-openssl-devbrew install cmake curl nlohmann-jsongit clone <repository-url>
cd strawberry-trading
mkdir build && cd build
cmake ..
make -j$(nproc)Executables are generated in build/bin/:
paper_trader- Main paper trading application
- Real-time options chain processing
- Greeks calculations (Delta, Gamma, Vega, Theta, Rho)
- Implied volatility analysis
- Strike price and expiration filtering
- Real-time and historical stock/options bars
- Latest quote data
- Configurable timeframes
- Market data snapshots
- Market and limit orders
- Multiple order types (stop, stop-limit, trailing-stop)
- Time-in-force options (DAY, GTC, IOC, FOK)
- Order status tracking
- Portfolio position tracking
- Real-time P&L calculations
- Risk metric monitoring
Set your Alpaca API credentials as environment variables (.zshrc, .bashrc):
export ALPACA_API_KEY="your_api_key"
export ALPACA_SECRET_KEY="your_secret_key"Configure logging in your application:
#include <logger_alias.hpp>
int main() {
logger.set_log_file("trading.log");
logger.info("Starting trading application");
// Your trading logic here
}#include <common/optionchain.hpp>
#include <logger_alias.hpp>
// Process options chain data from Alpaca
std::string chainData = api.getOptionChain("AAPL");
OptionChain chain(chainData);
// Extract Greeks
auto deltas = chain.get_deltas();
auto gammas = chain.get_gammas();
// Find specific option
Date expiry = Date::from_string("2024-01-19");
Option option = chain.find_Option("AAPL", expiry, 'C', 150.0);
logger.info("Found option: " + option.name);cd build/bin
./paper_trader- Headers: Located in
include/directories within each module - Source: Located in
src/directories within each module - CMake: Each module has its own
CMakeLists.txt
- Create strategy class in
strategies/src/ - Add corresponding header in
strategies/include/ - Implement required strategy interface methods
- Register strategy in main application
Build and run the paper trader application to test functionality:
make paper_trader
./bin/paper_trader- Stock bars (historical/real-time)
- Option bars (historical/real-time)
- Latest quotes
- Option chain snapshots
- Greeks and implied volatility
- Order placement (market/limit)
- Order status tracking
- Portfolio positions
- Multi-leg option strategies
- Bracket orders
- Account information
- Balance tracking
- Trade history
- API keys should never be committed to version control
- Use environment variables or secure configuration files
- Enable paper trading mode for development and testing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- Open an issue on GitHub
- Check the documentation in the code comments
- Review the example applications in
apps/