Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ option(BUILD_VISUALIZATION "Build visualization server" ON)
option(USE_TBB "Use Intel TBB for parallel algorithms" OFF)
option(USE_DPDK "Use DPDK for kernel bypass networking" OFF)
option(USE_LOCK_FREE "Use lock-free data structures" ON)
option(ENABLE_LTO "Enable Link-Time Optimization for release builds" OFF)

# LTO support
if(ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED)
if(LTO_SUPPORTED)
message(STATUS "LTO/IPO enabled")
else()
message(STATUS "LTO/IPO not supported by this compiler")
endif()
endif()

# Include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${WEBSOCKETPP_INCLUDE_DIRS}
Expand Down Expand Up @@ -191,7 +203,10 @@ set(CORE_SOURCES
core/persistence/journal/Journal.cpp
core/persistence/journal/JournalEntry.cpp
core/persistence/snapshot/SnapshotManager.cpp
core/routing/OrderRouter.cpp)
core/routing/OrderRouter.cpp
core/instrument/InstrumentManager.cpp
core/instrument/ResourceAllocator.cpp
core/utils/ThreadAffinity.cpp)

# Strategy library files
set(STRATEGY_SOURCES
Expand All @@ -203,7 +218,10 @@ set(STRATEGY_SOURCES
strategies/analytics/MarketRegimeDetector.cpp
strategies/rl/RLParameterAdapter.cpp
strategies/backtesting/BacktestEngine.cpp
strategies/config/StrategyConfig.cpp)
strategies/config/StrategyConfig.cpp
strategies/arbitrage/ArbitrageDetector.cpp
strategies/arbitrage/ArbitrageExecutor.cpp
strategies/analytics/CrossMarketCorrelation.cpp)

# Exchange library files
set(EXCHANGE_SOURCES
Expand Down Expand Up @@ -330,6 +348,11 @@ endif()

target_link_libraries(pinnaclemm ${PINNACLEMM_LIBS})

# Apply LTO to main executable in release builds
if(ENABLE_LTO AND LTO_SUPPORTED)
set_property(TARGET pinnaclemm PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

# Tests
if(BUILD_TESTS)
enable_testing()
Expand Down Expand Up @@ -488,6 +511,33 @@ if(BUILD_TESTS)
Threads::Threads
Boost::filesystem)
add_test(NAME DisasterRecoveryTests COMMAND disaster_recovery_tests)

# Instrument Manager tests
add_executable(instrument_manager_tests tests/unit/InstrumentManagerTests.cpp)
target_link_libraries(
instrument_manager_tests
core
risk
strategy
exchange
GTest::gtest_main
Comment thread
chizy7 marked this conversation as resolved.
GTest::gtest
Threads::Threads)
add_test(NAME InstrumentManagerTests COMMAND instrument_manager_tests)

# Arbitrage Detector tests
add_executable(arbitrage_detector_tests tests/unit/ArbitrageDetectorTests.cpp)
target_link_libraries(arbitrage_detector_tests core strategy
GTest::gtest_main GTest::gtest Threads::Threads)
Comment thread
chizy7 marked this conversation as resolved.
add_test(NAME ArbitrageDetectorTests COMMAND arbitrage_detector_tests)

# Cross-Market Correlation tests
add_executable(cross_market_correlation_tests
tests/unit/CrossMarketCorrelationTests.cpp)
target_link_libraries(cross_market_correlation_tests core strategy
GTest::gtest_main GTest::gtest Threads::Threads)
Comment thread
chizy7 marked this conversation as resolved.
add_test(NAME CrossMarketCorrelationTests
COMMAND cross_market_correlation_tests)
endif()

# Benchmarks
Expand Down Expand Up @@ -558,6 +608,18 @@ if(BUILD_BENCHMARKS)
add_executable(risk_check_benchmark tests/performance/RiskCheckBenchmark.cpp)
target_link_libraries(risk_check_benchmark core risk benchmark::benchmark
Threads::Threads)

# Multi-instrument benchmarks
add_executable(multi_instrument_benchmark
tests/performance/MultiInstrumentBenchmark.cpp)
target_link_libraries(
multi_instrument_benchmark
core
risk
strategy
exchange
benchmark::benchmark
Threads::Threads)
endif()

# Install targets
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<a href="docs/ORDER_ROUTING.md">Order Routing</a>&nbsp;&nbsp;•&nbsp;&nbsp;
<a href="docs/PERFORMANCE_BENCHMARKS.md">Performance Benchmarks</a>&nbsp;&nbsp;•&nbsp;&nbsp;
<a href="docs/api/reference.md">API Reference</a>&nbsp;&nbsp;•&nbsp;&nbsp;
<a href="docs/exchange/connector_guide.md">Exchange Connectors</a>
<a href="docs/exchange/connector_guide.md">Exchange Connectors</a>&nbsp;&nbsp;•&nbsp;&nbsp;
<a href="docs/MULTI_INSTRUMENT_GUIDE.md">Multi-Instrument</a>
</p>
</div>

Expand Down Expand Up @@ -52,6 +53,11 @@ PinnacleMM is a high-performance, production-grade market making system designed
- **Disaster Recovery**: Atomic risk state persistence, position reconciliation, and labeled backup management
- **Kubernetes Deployment**: Production-ready StatefulSet with health probes, PVC, network policies, and pod disruption budget
- **Enterprise Security**: AES-256-CBC encryption with unique salts, 100,000 PBKDF2 iterations, secure password input, comprehensive input validation, audit logging, rate limiting, and certificate pinning
- **Multi-Instrument Trading**: Simultaneous trading across multiple symbols with `InstrumentManager` orchestration
- **Cross-Exchange Arbitrage**: Venue price discrepancy detection with fee-adjusted opportunity scanning and dry-run execution
- **Cross-Market Correlation**: Pearson/rolling correlation, lead-lag analysis, Engle-Granger cointegration, and signal-based spread adjustment
- **Per-Symbol Risk Tracking**: Atomic per-symbol position, PnL, and volume tracking with configurable per-symbol limits
- **Dynamic Resource Allocation**: CPU core distribution and thread pinning for multi-instrument deployments
- **Comprehensive Testing**: Extensive test suite ensuring reliability and performance

## System Architecture
Expand Down Expand Up @@ -161,6 +167,12 @@ cd build && ./pinnaclemm --mode simulation --enable-ml --json-log --json-log-fil
# Combined: ML + visualization + JSON logging
cd build && ./pinnaclemm --mode simulation --enable-ml --enable-visualization --json-log --json-log-file sim_ml_data.jsonl

# Multi-instrument simulation
cd build && ./pinnaclemm --mode simulation --symbols BTC-USD,ETH-USD

# Arbitrage detection (dry-run)
cd build && ./pinnaclemm --mode simulation --symbol BTC-USD --enable-arbitrage --arb-dry-run

# The visualization dashboard will be available at:
# - WebSocket: ws://localhost:8080 (or custom port with --viz-ws-port)
# - REST API: http://localhost:8081 (or custom port with --viz-api-port)
Expand Down Expand Up @@ -453,6 +465,9 @@ docker run -it --name pinnaclemm-live \
- **Market Regime Detector**: Hidden Markov Model-based detection of 8 market regimes
- **RL Parameter Adapter**: Reinforcement learning for dynamic strategy parameter optimization
- **Advanced Backtesting Engine**: Historical replay with Monte Carlo analysis and statistical testing
- **Instrument Manager**: Multi-instrument orchestration with per-symbol order books, strategies, and simulators
- **Arbitrage Detector**: Cross-exchange price discrepancy detection with fee-adjusted scanning
- **Cross-Market Correlation**: Statistical lead-lag analysis and cointegration testing for signal generation
- **Real-Time Visualization**: Web-based dashboard with Chart.js and D3.js visualization
- **FIX Protocol Engine**: Professional-grade FIX connectivity for institutional trading
- **Persistence System**: Crash recovery with memory-mapped files
Expand Down Expand Up @@ -548,6 +563,12 @@ open build/test_dashboard.html
# or manually: file:///path/to/PinnacleMM/build/test_dashboard.html
```

### Multi-Instrument & Optimization
- [Multi-Instrument Guide](docs/MULTI_INSTRUMENT_GUIDE.md) - **Multi-symbol trading with InstrumentManager**
- [Cross-Exchange Arbitrage](docs/CROSS_EXCHANGE_ARBITRAGE.md) - **Venue spread detection and execution**
- [Cross-Market Correlation](docs/CROSS_MARKET_CORRELATION.md) - **Statistical correlation and signal generation**
- [Performance Optimization Guide](docs/PERFORMANCE_OPTIMIZATION_GUIDE.md) - **LTO, CPU affinity, object pooling, lock-free fixes**

### Exchange Integration
- [FIX Protocol Integration Guide](docs/FIX_PROTOCOL_INTEGRATION.md)
- [FIX Testing Guide](docs/TESTING_GUIDE.md)
Expand Down Expand Up @@ -621,6 +642,12 @@ cd build
./disaster_recovery_tests # 8 tests - state persistence, backups
./risk_check_benchmark # Risk check latency benchmarks

# Test multi-instrument and optimization components (Phase 5)
./instrument_manager_tests # 9 tests - lifecycle management
./arbitrage_detector_tests # 8 tests - opportunity detection, fees
./cross_market_correlation_tests # 7 tests - correlation, lead-lag
./multi_instrument_benchmark # Startup scaling benchmarks

# Memory safety validation with Address Sanitizer (development builds)
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_SANITIZERS=ON .. && make -j8
./pinnaclemm --mode simulation --symbol BTC-USD --verbose
Expand Down
24 changes: 24 additions & 0 deletions config/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@
"keepSnapshots": 5,
"compactionThreshold": 1000000
},
"instruments": [
{
"symbol": "BTC-USD",
"enabled": true,
"useLockFree": true,
"enableML": false,
"baseSpreadBps": 10.0,
"orderQuantity": 0.01,
"maxPosition": 10.0
}
],
"arbitrage": {
"enabled": false,
"minSpreadBps": 5.0,
"minProfitUsd": 1.0,
"maxStalenessMs": 500,
"scanIntervalMs": 10,
"dryRun": true,
"venues": ["coinbase", "kraken"],
"venueFees": {
"coinbase": 0.001,
"kraken": 0.0016
}
},
"risk_management": {
"limits": {
"max_position_size": 10.0,
Expand Down
Loading
Loading