Python Rithmic Trading Bot Development
Budget: $30 – $250 USD
Specification for Developing a Rithmic Trading Bot in Python with gRPC
1. Project Objective
Develop a Python trading bot to execute automated trading operations on the Rithmic platform via API, using gRPC for efficient inter-service communication. The bot should include features for portfolio management, price tracking, and order handling with fault tolerance mechanisms.
2. Technologies and Environment
Language: Python
Communication Framework: gRPC for efficient inter-service communication, using Protocol Buffers (Protobuf) for service definitions.
Python Modules: grpcio, requests, hmac, hashlib, json, time
Application Server: gRPC-based server for bot interactions.
3. Required Configurations
Credentials: Implement secure handling of username, password, and automated region retrieval for connection.
Environment Variables: Configure the API endpoint (APIURL) securely through an environment file.
4. gRPC Service Definitions
The gRPC services should include the following key functionalities:
GetWalletBalance: gRPC service to obtain the current wallet balance.
GetSymbolPrice: gRPC service to retrieve the current price of a trading symbol.
PlaceMarketOrder: gRPC service to execute a market order (buy/sell).
CloseOrder: gRPC service to close an open position.
5. Bot Features
Request Signing: Generate a unique HMAC-SHA256 signature for each request sent to the Rithmic API for secure authentication.
Balance Retrieval: Implement a function to call the GetWalletBalance service through gRPC to obtain the wallet balance, with fault tolerance.
Price Tracking: Implement GetSymbolPrice to retrieve the current price of a symbol with retry logic in case of incomplete responses.
Position Management: Verify the size of open LONG and SHORT positions for each trading symbol.
Quantity Calculation: Include functionality to calculate the quantity of a symbol based on the wallet balance and current price, with symbol-specific rounding.
Order Placement: Use PlaceMarketOrder to place buy and sell market orders. The function should include retry logic in case of transaction errors.
Order Closing: Integrate the CloseOrder service to close open positions, verifying transaction success and wallet balance before and after the transaction.
6. Fault Tolerance
Retry and Repeat Attempts: Ensure bot resilience by defining a number of retry attempts for critical API calls (for example, 100 for balance and price requests, and 3 for market orders).
Error Logging: Log errors and failed attempts to facilitate debugging and tracking.
7. Security and Credential Management
Secure Credential Storage: Store credentials (username, password) in environment variables, not in the codebase.
Authentication: Create a unique signature for each request using hmac and sha256 to maintain credential security.
8. Deliverables
Documented Source Code: Provide complete source code with comments for each main function.
User Guide: A README file detailing installation, configuration, and bot usage.
Environment Configuration Example: .env.example file for environment setup, including secure handling of credentials and the API endpoint.
9. Testing and Validation
Unit Tests: For each function, including balance retrieval, price tracking, and order placement.
Performance Tests: Check response time for each gRPC service.
Resilience Tests: Simulate API failures and verify fault tolerance.
The developer should be capable of creating a Rithmic account with AMP for testing purposes. This specification ensures clarity on expectations for developing a Python trading bot using gRPC for the Rithmic platform.
1. Project Objective
Develop a Python trading bot to execute automated trading operations on the Rithmic platform via API, using gRPC for efficient inter-service communication. The bot should include features for portfolio management, price tracking, and order handling with fault tolerance mechanisms.
2. Technologies and Environment
Language: Python
Communication Framework: gRPC for efficient inter-service communication, using Protocol Buffers (Protobuf) for service definitions.
Python Modules: grpcio, requests, hmac, hashlib, json, time
Application Server: gRPC-based server for bot interactions.
3. Required Configurations
Credentials: Implement secure handling of username, password, and automated region retrieval for connection.
Environment Variables: Configure the API endpoint (APIURL) securely through an environment file.
4. gRPC Service Definitions
The gRPC services should include the following key functionalities:
GetWalletBalance: gRPC service to obtain the current wallet balance.
GetSymbolPrice: gRPC service to retrieve the current price of a trading symbol.
PlaceMarketOrder: gRPC service to execute a market order (buy/sell).
CloseOrder: gRPC service to close an open position.
5. Bot Features
Request Signing: Generate a unique HMAC-SHA256 signature for each request sent to the Rithmic API for secure authentication.
Balance Retrieval: Implement a function to call the GetWalletBalance service through gRPC to obtain the wallet balance, with fault tolerance.
Price Tracking: Implement GetSymbolPrice to retrieve the current price of a symbol with retry logic in case of incomplete responses.
Position Management: Verify the size of open LONG and SHORT positions for each trading symbol.
Quantity Calculation: Include functionality to calculate the quantity of a symbol based on the wallet balance and current price, with symbol-specific rounding.
Order Placement: Use PlaceMarketOrder to place buy and sell market orders. The function should include retry logic in case of transaction errors.
Order Closing: Integrate the CloseOrder service to close open positions, verifying transaction success and wallet balance before and after the transaction.
6. Fault Tolerance
Retry and Repeat Attempts: Ensure bot resilience by defining a number of retry attempts for critical API calls (for example, 100 for balance and price requests, and 3 for market orders).
Error Logging: Log errors and failed attempts to facilitate debugging and tracking.
7. Security and Credential Management
Secure Credential Storage: Store credentials (username, password) in environment variables, not in the codebase.
Authentication: Create a unique signature for each request using hmac and sha256 to maintain credential security.
8. Deliverables
Documented Source Code: Provide complete source code with comments for each main function.
User Guide: A README file detailing installation, configuration, and bot usage.
Environment Configuration Example: .env.example file for environment setup, including secure handling of credentials and the API endpoint.
9. Testing and Validation
Unit Tests: For each function, including balance retrieval, price tracking, and order placement.
Performance Tests: Check response time for each gRPC service.
Resilience Tests: Simulate API failures and verify fault tolerance.
The developer should be capable of creating a Rithmic account with AMP for testing purposes. This specification ensures clarity on expectations for developing a Python trading bot using gRPC for the Rithmic platform.