-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding library to the omni-executor for the binance api (Convert) #3279
Open
silva-fj
wants to merge
32
commits into
dev
Choose a base branch
from
p-1355-create-a-client-library-for-binance-api
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+830
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a new crate for interaction with the Binance API, including: - Project setup with necessary dependencies
Create BinanceApi struct with API credentials and URL configuration for interacting with Binance REST API endpoints. The client can be initialized with custom base URL or defaults to the standard Binance API endpoint.
Add method to fetch available token pairs and their trading limits from the Binance convert API. The implementation includes proper error handling and allows filtering by source and destination assets.
Add a reqwest Client instance to the BinanceApi struct to enable connection pooling and reuse, replacing the static reqwest::get method with client-based requests for improved performance.
Extract "/sapi/v1/convert" into a CONVERT_API constant to improve code maintainability and reduce string duplication when constructing Binance API endpoints.
Implement HMAC SHA256 signing for authenticated Binance API requests, including helper method for making signed requests and corresponding test. This enables secure interaction with protected Binance API endpoints.
Implement get_asset_info method to retrieve precision information for all supported assets from Binance Convert API. This enhances the API client's capabilities by allowing access to critical asset metadata.
Added proper handling of request parameters in the API client, allowing for passing parameters as key-value pairs. This enables methods like GET and POST to correctly format and send parameters according to the Binance API requirements. Improved request signing logic to properly handle all parameters and updated request building to support different HTTP methods correctly.
as well as RequestQuoteParams to handle building and validating quote request parameters. This includes handling different wallet types and proper amount serialization.
Simplify error naming by changing BinanceApiError to Error, improving code consistency and readability. Also rename specific error variants to be more concise (e.g., RequestError to RequestFailed).
Add optional recv_window parameter to get_asset_info method to allow customizing request timeout settings when calling Binance API endpoints. This improves flexibility for different network conditions.
Add get_quote method to the BinanceApi client to request quotes for token pairs. This includes support for the RequestQuoteParams type and proper parameter conversion and validation, with appropriate error handling.
Add maximum recv_window validation to prevent API errors, changing parameter type from u64 to u32, and adding MaxRecvWindowExceeded error variant. This ensures requests stay within Binance API limits of 60000ms.
Add documentation comments to from_amount and to_amount fields in RequestQuoteParams struct to clarify their purpose in the quote request process, improving API usability and developer understanding.
Implement accept_quote method in BinanceApi to allow accepting quotes by their ID. Also add ConvertOrder and ConvertOrderStatus types to handle API responses for quote acceptance operations, supporting the order processing workflow.
Add functionality to retrieve convert trade history from the Binance API with appropriate parameter validation, including: - New ConvertTradeHistory and ConvertTrade types for response data - Add LimitExceeded error for handling invalid limit parameters - Validate time range (max 30 days) and limit (max 1000) parameters
Implement functionality to query the status of convert orders by either order ID or quote ID with: - New ConvertOrderStatus struct to represent API response - Rename ConvertOrderStatus enum to OrderStatus for consistency - Add validation to ensure at least one ID parameter is provided
Implement functionality for placing limit orders on Binance Convert API: - Add new PlaceLimitOrderParams struct with validation - Create OrderSide and ExpiredType enums for request parameters - Add LimitOrder response type for decoded API responses - Implement place_limit_order method in BinanceApi client - Add comprehensive test coverage for parameter validation
Implement functionality to cancel limit orders on Binance Convert API: - Add CancelOrderLimit struct to represent API response - Implement cancel_limit_order method in BinanceApi client - Export the new type through the public API - Document usage with API endpoint details
Implement functionality to retrieve all open limit orders: - Add OpenOrders and OpenOrder response types - Create get_open_orders method in BinanceApi client - Support passing optional recv_window parameter - Export the new types through public API
Move Binance Convert API methods to a dedicated module: - Create new convert_api.rs module with ConvertApi class - Update lib.rs to expose API through a facade method - Extract all Convert-specific endpoints to the new module - Make internal methods public for cross-module usage - Add helper for making public GET requests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new library to be able to interact with the Binance API (Convert).
Note: We need to setup a test account to properly test the library. I have not looked into it yet.