This repo implements ORDER (Optimal Routing with path inDexing in Exchange gRaphs), a high-efficiency routing solution for real-time decision-making in financial exchange networks.
We study the problem of optimal routing on financial exchange graphs. Given a directed graph where vertices represent assets and edges encode tradable pairs with exchange rates and capacities, the goal is to find a sequence of routes that maximizes the delivered output.
ORDER introduces a hierarchical bucket path index with lazy computation and adaptive controller. It demonstrates robustness across different market regimes and exchange pairs, enabling timely, high-quality routing under fragmented liquidity and tight capacity constraints.
-
Create a Build Directory:
cd code mkdir build -
Navigate to the Build Directory:
cd build -
Run CMake:
cmake ..
-
Compile the Project:
make
After compilation, the executable files will be available in the build directory.
This algorithm uses two buckets with adaptive k value adjustment.
Usage:
build/rerank_two_bucket_adaptive_k <edge_group_dir> <total_amount> <output_dir>Example:
build/rerank_two_bucket_adaptive_k cpp_graph/1_3 100 output_resultsParameters:
edge_group_dir: Directory containing edge group files and paths.txttotal_amount: Total amount/capacity to routeoutput_dir: Directory where results will be saved
This algorithm uses multiple buckets with a fixed k value that you specify.
Usage:
build/rerank_multi_bucket_fixed_k <edge_group_dir> <total_amount> <output_dir> <initial_k>Example:
build/rerank_multi_bucket_fixed_k cpp_graph/1_3 1000 output_results 10Parameters:
edge_group_dir: Directory containing edge group files and paths.txttotal_amount: Total amount/capacity to routeoutput_dir: Directory where results will be savedinitial_k: K value for the algorithm
This algorithm uses multiple buckets with adaptive k value adjustment.
Usage:
build/rerank_multi_bucket_adaptive_k <edge_group_dir> <total_amount> <output_dir>Example:
build/rerank_multi_bucket_adaptive_k cpp_graph/1_3 100 output_resultsParameters:
edge_group_dir: Directory containing edge group files and paths.txttotal_amount: Total amount/capacity to routeoutput_dir: Directory where results will be saved
Each algorithm generates the following output files in the specified output directory:
summary.txt: Contains algorithm statistics, performance metrics, and k value historydetails.txt: Contains detailed path selection information for each round
ORDER is provided for academic research only. It must not be used in live trading without thorough risk, compliance, and security review. Real-world deployment carries significant hazards—including slippage, MEV, adverse selection, chain reorgs, and confirmation delays—that require robust controls and governance.