Welcome to the High-Frequency Trading Server! This project is designed to simulate a high-frequency trading environment, providing support for various types of orders, including limit and market orders. The platform leverages Rust for high-performance server-side operations and Solidity for smart contract integration.
- Place limit orders to buy or sell shares at a specified price.
- Orders are matched when the buy price is greater than or equal to the sell price.
- Place market orders to buy or sell shares at the best available price.
- Market orders prioritize immediate execution over price.
- Python scripts for testing the functionality of limit and market orders.
- Includes scenarios for both filled and unfilled orders to ensure reliability.
-
Clone the Repository
git clone https://github.com/your-repo/hft_trading_server.git cd hft_trading_server
-
Install Dependencies
- For Rust:
rustup update cargo build
- For Python:
pip install -r requirements.txt
- For Rust:
-
Set Up Environment Variables
- Create a
.env
file with the necessary environment variables:WS_URL=<your_web3_provider_url> CONTRACT_ADDRESS=<your_contract_address> ACCOUNT=<your_account_address> REDIS_CLIENT_URL=<your_redis_url> SECRET_KEY=<your_secret_key>
- Create a
-
Compile the Smart Contract
- Navigate to the
contracts
directory and compile the Solidity contract:solc --optimize --bin --abi OrderBook.sol -o build/
- Navigate to the
-
Deploy the Contract
- Use a script or tool like Remix, Truffle, or Hardhat to deploy the compiled contract to your preferred Ethereum network.
- Start the Rust server:
cargo run
- Execute the Python test scripts:
python test_limit_orders.py python test_market_orders.py
- Place Buy Order:
/buy
- Place Sell Order:
/sell
- Get Portfolio:
/portfolio/user/{user_id}
- Limit Order: Executes at a specified price or better.
- Market Order: Executes immediately at the best available price.
- Stop Order: Can be added later for more complex trading strategies.
- Manages buy and sell orders with different types.
- Emits events for order placements and matches.
- Matches orders based on specified rules for limit and market orders.
- Rust: For high-performance server-side logic.
- Actix-Web: Web framework for handling HTTP requests.
- Redis: For state management and order book storage.
- Solidity: For Ethereum-based smart contract logic.
- Events: Emit logs for order placements and matches.
- Implement Stop Orders: Add functionality for stop orders.
- Enhance Matching Logic: Improve the order matching algorithm.
- Real-Time Data: Integrate with real-time market data for dynamic trading.
- User Interface: Develop a frontend for better user interaction.
For any questions or suggestions, feel free to open an issue or contact us at isanjit3@gmail.com.
Made with β€οΈ by Sanjit Thangarasu