Skip to content

ncdevshiv/titan-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Titan Protocol - MetaTrader 5 DMA Bridge

License Buy Me A Coffee

Created by: Shiv (ncdevshiv@gmail.com)
Support: β˜• Buy Me a Coffee


The Titan Protocol Bridge is an Ultra-Low Latency, Zero-Copy Direct Memory Access (DMA) Gateway designed to decouple MetaTrader 5 (MT5) from tight database/frontend constraints. It streams high-frequency tick data, Level 2 Deep Order Books (DOM), and Trade Metadata in a strictly normalized, database-agnostic format via Eclipse Iceoryx.

πŸ’– Support This Project
If you find this project useful, please consider buying me a coffee! Your support helps maintain and improve this open source project.

This guarantees maximum protocol neutrality allowing any consumer (C++, Rust, Go, Python, Svelte via WebSockets, DuckDB, ClickHouse) to attach and receive payloads flawlessly without parsing text strings or writing to disks.

Build Status

Component Status
Rust/C++ FFI (CXX Bridge) Working
Iceoryx Zero-Copy Publishing Working
CRC32 Validation Working
Sequence Deduplication Working
Data Circuit Breaker Working
Max Slippage Guard Working
JSON Structured Logging Working
Release DLL Build Working

Test Coverage

44 comprehensive tests covering:

  • Protocol Module: CRC32 validation, sequence deduplication, gap detection, multi-symbol tracking
  • Circuit Breakers: TPS limiting, trip/reset cycles, window rollover
  • Max Slippage Guard: Buy/sell validation, price updates, limit enforcement
  • Clock Sync: Triple-clock initialization, EMA smoothing, multi-update handling
  • Configuration: JSON loading, error handling for missing/malformed configs
  • Error Handling: Error code validation, system error creation, context handling
  • Protobuf Integration: Tick, DOM, and metadata encoding/decoding
  • End-to-End: Full integration tests across all modules

Run tests with:

cargo test

Architecture Highlights

  • 100% Zero-Copy Streaming: Relies on Iceoryx iox::popo::Publisher bypassing standard kernel OS socket and file IO overheads.
  • Rust/C++ FFI via CXX Bridge: Seamless integration between Rust business logic and Iceoryx C++ APIs.
  • Fail Loudly Mandate: No silent failures exist. Any missing Iceoryx routers, structural violations, or internal thread poisoning immediately halts processes safely with structured panics mapped to ErrorCode enumerations.
  • Protobuf First: Messages crossing the boundary are encoded in Google Protobuf arrays representing true architectural standardization (schemas/titan.proto).
  • Configurable Integrity Guards: Circuit-breakers strictly isolate downstream consumers from bad upstream burst profiles (DataCircuitBreaker) and malicious pricing deviations (MaxSlippageGuard).
  • CRC32 Validation: All ticks undergo integrity verification via crc32fast to detect corrupt DMA transfers.
  • Sequence Deduplication: Automatic ghost tick filtering and gap detection for reliable streaming.
  • JSON Structured Logging: All events logged in structured JSON format with timestamps, modules, and error codes.

What Actually Works

  1. Rust/C++ FFI via CXX Bridge: Full integration with Iceoryx C++ APIs through the shared_memory.rs bridge.
  2. Iceoryx Zero-Copy Publishing: Tick, book, metadata, and command streams via shared memory.
  3. CRC32 Validation on All Ticks: Every tick validated for integrity before processing.
  4. Sequence Deduplication and Gap Detection: Prevents ghost ticks and detects network gaps.
  5. DataCircuitBreaker with TPS Limiting: Configurable rate limiting with automatic trip/reset.
  6. MaxSlippageGuard for Execution Validation: Prevents fills beyond acceptable slippage thresholds.
  7. JSON Structured Logging: Comprehensive logging to stdout and titan_bridge.log.
  8. 44 Comprehensive Tests: Full unit and integration test coverage.
  9. Release Build Produces Working DLL: target/release/titan_bridge.dll ready for MT5 integration.

Key Dependencies for Build

The Bridge operates fundamentally via C++ bindings via CXX bridged through Rust.

Rust Dependencies (from Cargo.toml)

  • cxx = "1.0" - C++ interoperability
  • once_cell = "1.18" - Lazy static initialization
  • serde = "1.0" - Serialization framework
  • serde_json = "1.0" - JSON serialization
  • chrono = "0.4" - Date/time handling
  • crc32fast = "1.3" - CRC32 checksum validation
  • prost = "0.13" - Protobuf encoding/decoding
  • bytes = "1" - Byte buffer utilities
  • uuid = "1.8" - Session UUID generation

System Prerequisites

For Windows:

  • Rust Toolchain: Must be explicitly set to standard Windows ABI stable-x86_64-pc-windows-msvc.
  • Cargo Configuration: Must include dynamic linking to C Runtime definitions (CRT):
# .cargo/config.toml
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=-crt-static"]
  • CMake: >=3.18 (for building Iceoryx)
  • Protoc: Vendored hermetic Google Protobuf Compiler (included in protoc_bin/)

Iceoryx Version

  • Iceoryx: v2.95.8 (located in third_party/iceoryx)

Setup and Bootstrapping

Run the Windows PowerShell bootstrap.ps1 script to install all components autonomously:

.\bootstrap.ps1

This executes:

  1. Verification/installation of the Rust toolchain via rustup
  2. Verification/installation of CMake via winget
  3. Cloning and building Eclipse Iceoryx RouDi daemon from third_party/iceoryx
  4. Building the Titan Bridge Rust DLL with dynamic CRT linking

Manual Build (if bootstrap fails)

# Ensure CMake is installed and in PATH
# Build Iceoryx manually
cd third_party/iceoryx
cmake -B build -S iceoryx_meta -DBUILD_STRICT=OFF
cmake --build build --config Release
cd ../..

# Build the Rust DLL
cargo build --release

Usage

The titan_bridge.dll produced in target/release/ is seamlessly loaded into ea/HighPerformanceBridgeEA.mq5.

To run the full simulation locally or execute tests:

cargo clean
set CARGO_TARGET_DIR=target_custom
cargo test
cargo build --release

Module Structure

src/
β”œβ”€β”€ lib.rs              # Main DLL entry points and FFI interface
β”œβ”€β”€ errors.rs           # ErrorCode enum and SystemError struct
β”œβ”€β”€ config.rs           # SystemConfig JSON loading
β”œβ”€β”€ protocol.rs         # BinaryTick, ProtocolNormalizer, CRC32 validation
β”œβ”€β”€ circuit_breakers.rs # DataCircuitBreaker and MaxSlippageGuard
β”œβ”€β”€ clock_sync.rs       # TripleClock and ClockSyncPacket
β”œβ”€β”€ logger.rs           # JSON structured logging
β”œβ”€β”€ shared_memory.rs    # CXX bridge to Iceoryx C++ APIs
β”œβ”€β”€ pb/                 # Generated Protobuf types
β”œβ”€β”€ titan_iceoryx.cpp   # C++ Iceoryx wrapper implementation
└── titan_iceoryx.hpp   # C++ Iceoryx wrapper header

Documentation

Documentation regarding the agnostic architectures can be referenced directly in:

License

This project is licensed under a Modified Personal Use License.

  • βœ… Personal Use: Free for personal, educational, and non-commercial use
  • βœ… Open Source: Source code is available and modifiable for personal use
  • ⚠️ Commercial Use: Requires explicit permission. Contact me for commercial licensing

See LICENSE for full terms.


πŸ’– Support This Project

If you find this project useful, please consider supporting its development!

Buy Me A Coffee

Why Support?

  • πŸš€ Helps fund ongoing development and new features
  • πŸ› Enables faster bug fixes and improvements
  • πŸ“– Supports documentation and tutorial creation
  • πŸ’‘ Your contribution directly impacts the project's future

β˜• Buy Me a Coffee


Contact

Created with ❀️ by Shiv

For commercial licensing inquiries, bug reports, or feature requests, please reach out!


If you use this project in your research or trading system, please consider buying me a coffee to show your support!

About

Ultra-Low Latency DMA Gateway for MetaTrader 5 - Zero-Copy tick streaming via Iceoryx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors