A high-performance, real-time cryptocurrency options pricing system built in C++ with a focus on low latency and efficient market data processing.
This system provides end-to-end infrastructure for cryptocurrency options pricing, from real-time market data ingestion to sophisticated pricing calculations. It's designed for high-frequency trading environments where microsecond-level performance matters.
- Real-time Market Data: WebSocket connectivity to major crypto exchanges
- High-Performance Processing: Optimized C++20 codebase with SIMD JSON parsing
- Low-Latency IPC: Unix domain sockets for inter-process communication
- Live Orderbook Management: Efficient price level tracking and BBO calculation
- Options Pricing Engine: Advanced mathematical models for derivative pricing
- Modular Architecture: Clean separation of concerns for maintainability
- Production Ready: Comprehensive testing and robust error handling
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Exchange β β Feed Processing β β Options Pricing β
β Connectivity βββββΆβ & Normalization βββββΆβ Engine β
β (WebSocket) β β (JSONβBinary) β β (Black-Scholes) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Types Module β β Orderbook β β IPC Connection β
β (Data Models) β β Management β β (Unix Sockets) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
| Module | Purpose | Key Technologies |
|---|---|---|
| ExchangeConnectivity | Real-time WebSocket connections to crypto exchanges | Boost.Beast, SSL/TLS |
| FeedProcessing | JSON parsing and data normalization | SimdJSON, Message routing |
| Orderbook | High-performance price level management | STL containers, BBO tracking |
| Types | Core data structures and messaging protocol | Template metaprogramming |
| IPCConnection | Inter-process communication | Unix domain sockets |
| Pricing | Options pricing algorithms | Mathematical models |
- C++20 compatible compiler (GCC 10+, Clang 12+)
- Bazel 6.0+ for build system
- Linux/macOS (Unix domain sockets)
- Internet connection for market data
# Clone the repository
git clone https://github.com/27sanjeevd/Fast-Crypto-Options-Pricing.git
cd Fast-Crypto-Options-Pricing
# Build the main application
bazel build //:main
# Build all modules
bazel build //...
# Run tests
bazel test //...# Run the main application (connects to crypto.com)
bazel run //:main
# Run individual components for testing
bazel run //IPCConnection:IPCConnectionTest
bazel run //FeedProcessing:FeedProcessingTest#include "ExchangeConnectivity/ExchangeConnectivity.h"
#include "FeedProcessing/FeedProcessing.h"
int main() {
// 1. Connect to exchange and start receiving data
std::vector<std::string> tickers = {"BTCUSD-PERP", "ETHUSD-PERP"};
ExchangeWebsocketClient client(tickers, {"/tmp/market_data.sock"});
client.Start();
// 2. Process incoming market data
FeedProcessing processor("/tmp/market_data.sock", "/tmp/bbo_output.sock");
std::thread processing_thread([&]() { processor.Run(); });
// 3. System runs continuously processing real-time data
std::this_thread::sleep_for(std::chrono::hours(24));
// 4. Graceful shutdown
client.Stop();
processing_thread.join();
return 0;
}- Market Data Ingestion: < 100Β΅s from exchange to internal processing
- JSON Parsing: < 50Β΅s using SimdJSON SIMD optimizations
- Orderbook Updates: < 10Β΅s for BBO calculation
- IPC Communication: < 20Β΅s for local socket transmission
- End-to-End: < 200Β΅s from market data to pricing calculation
- Market Data: > 100,000 messages/second per instrument
- Orderbook Updates: > 1,000,000 price level changes/second
- Options Calculations: > 10,000 pricing calculations/second
- Orderbook Storage: < 1MB per instrument (typical depth)
- Message Buffers: Zero-copy parsing where possible
- Total Memory: < 100MB for full system under normal load
Modify connection parameters in ExchangeConnectivity/ExchangeConnectivity.cpp:
const std::string HOST = "stream.crypto.com";
const std::string PORT = "443";
const std::string TARGET = "/exchange/v1/market";Configure instruments in your main application:
std::vector<std::string> tickers = {
"BTCUSD-PERP", // Bitcoin perpetual futures
"ETHUSD-PERP", // Ethereum perpetual futures
"BTC_USDT", // Bitcoin spot
"ETH_USDT" // Ethereum spot
};Customize communication channels:
const std::string MARKET_DATA_SOCKET = "/tmp/market_data.sock";
const std::string BBO_OUTPUT_SOCKET = "/tmp/bbo_output.sock";
const std::string PRICING_INPUT_SOCKET = "/tmp/pricing_input.sock";# Test individual modules
bazel test //ExchangeConnectivity:all
bazel test //FeedProcessing:all
bazel test //Orderbook:all
bazel test //IPCConnection:all# Test complete data pipeline
bazel test //FeedProcessing:FeedProcessingTest
# Test IPC communication
bazel test //IPCConnection:IPCConnectionTest# Run performance tests
bazel test //Orderbook:OrderbookBenchmark
bazel test //FeedProcessing:ParsingBenchmarkEach module contains detailed documentation:
- ExchangeConnectivity - WebSocket market data connectivity
- FeedProcessing - Data processing and normalization
- Orderbook - High-performance orderbook management
- Types - Core data structures and messaging
- IPCConnection - Inter-process communication
- Pricing - Options pricing algorithms
- C++20 Standard: Modern C++ features and best practices
- Google Style Guide: Consistent formatting and naming
- RAII: Resource management through smart pointers
- Template Metaprogramming: Type-safe generic utilities
- Bazel: Hermetic builds with precise dependency management
- External Dependencies: Boost, SimdJSON, GoogleTest, BoringSSL
- Optimization:
-O3compilation with architecture-specific tuning
- Define Data Types: Add exchange-specific types in
Types/ - Implement Connectivity: Create WebSocket client in
ExchangeConnectivity/ - Update Parser: Extend
DataNormalizationfor new message formats - Integration Testing: Verify data flow through complete pipeline
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Run the full test suite (
bazel test //...) - Submit a pull request
The system provides detailed logging at multiple levels:
std::cout << "WebSocket connected successfully!" << std::endl;
std::cerr << "JSON parsing error: " << error.what() << std::endl;# Monitor message processing rates
processor.GetBookSnapshotCount();
processor.GetBookDeltaCount();
processor.GetTradeCount();# Build with debug symbols
bazel build --compilation_mode=dbg //:main
# Run with debugger
gdb bazel-bin/main- CPU: Modern x86_64 with AVX2 support (for SimdJSON)
- Memory: Minimum 4GB RAM, 8GB+ recommended
- Network: Low-latency internet connection
- OS: Linux (Ubuntu 20.04+) or macOS (Monterey+)
- Configure firewall for exchange connections
- Set up monitoring and alerting
- Configure log rotation
- Test failover scenarios
- Verify market data connectivity
- Benchmark performance under load
- Process monitoring with automatic restart
- Redundant market data connections
- Circuit breakers for external dependencies
- Graceful degradation during outages
- Additional exchange integrations (Binance, FTX)
- Enhanced options pricing models (Heston, SABR)
- Risk management module
- Web-based monitoring dashboard
- FPGA acceleration for orderbook processing
- Machine learning market prediction
- Multi-asset portfolio optimization
- Cloud deployment automation
- Distributed processing across multiple nodes
- Alternative data source integration
- Advanced derivatives support (swaps, futures)
- Regulatory compliance framework
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for questions and ideas
- Email: Contact maintainer for private inquiries
- Boost Libraries: Essential networking and utility components
- SimdJSON: Ultra-fast JSON parsing performance
- Google Test: Comprehensive testing framework
- Bazel: Reliable and scalable build system
- Crypto.com: Market data API and documentation
Built with β‘ for the future of cryptocurrency derivatives trading