Ethereal Rust Sdk
This is the Ethereal Rust SDK, which provides tools and libraries for interacting with the Ethereal platform using the Rust programming language.
Features
- Yawc for real-time, zero-copy communication for all supported WebSocket channels
- JSON serialization and deserialization
- Async HTTP requests with Reqwest
- Fully typed data models generated from the Ethereal OpenAPI specification.
- Support for all Ethereal REST API endpoints
- Support for all Ethereal WebSocket API channels using async callbacks
- Comprehensive error handling
- Example code for common use cases
Getting Started
At present, the Ethereal Rust SDK is under active development. To get started with the SDK, clone the repository and run the example code;`
We have a number of examples included in the examples directory. Here is how to run the simple_order_submission example:
Installation
To use the Ethereal Rust SDK in your project run the following command to add it as a dependency in your Cargo.toml file:
Usage of the SDK
There are two main clients provided by the SDK: an asynchronous HTTP client for interacting with the Ethereal REST API, and a WebSocket client for real-time data via the Ethereal WebSocket API.
Creating Clients
A convenient utility function is provided to create both clients. Here is an example of how to use it:
let env = Testnet;
let private_key = "your_private_key_here";
let = create_client.await?;
HTTP Client
All of the HTTP client functionality is encapsulated in the HttpClient struct. This client can be used to make requests to various endpoints of the Ethereal REST API.
The client has been generated using the OpenAPI specification provided by Ethereal, ensuring that all endpoints and data models are up-to-date with the latest API version.
Submitting Orders
// examples/simple_order_submission.rs
use ;
use dec;
async
Fetching Positions
Positions can be fetched similarly:
// examples/fetch_positions.rs
use ;
async
WebSocket Client
The Websocket client can be used as somewhat illustrated in the example below:
Channels
In order to proces messages from the websocket client, the user must first register a callback, then subscribe to the desired channel.
Market Data Subscription
// examples/market_data.rs
use TickerMessage;
use info;
async
async
As can be seen, the SDK provides both asynchronous HTTP clients and WebSocket clients to interact with the Ethereal platform.
Order Status Updates
The following example demonstrates how to register for order updates.
// examples/order_update.rs
use OrderUpdateMessage;
use info;
async
async
Order Fills
An order fill callback can be registered and subscribed to in a similar manner, this time using the register_order_fill_callback and subscribe_order_fill methods.
Additionally, it should be pointed out that a different data model is used for order fills, namely PageOfOrderFillDtos.
// examples/order_fills.rs
use OrderFillMessage;
use info;
async
async
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your changes. Before submitting a pull request, please ensure that your code adheres to the project's coding standards and passes all tests. Please run the following commands to lint, format, build, and test the project before submitting your changes:
# Or simpler
License
This project is licensed under the MIT License. See the LICENSE file for details.
TODO
- Generate datatypes from Ethereal API spec.
- Set up continuous integration and deployment (CI/CD) pipeline.
- Fully Integrate with Ethereal Websocket API.
- Implement Read HTTP client for Ethereal REST API.
- Create example code for using the SDK.
- Implement Order posting for Ethereal REST API.
- Create async HTTP client for Ethereal REST API.
- Write tests for all modules and functionalities.
- Add more examples and documentation.
- Publish the crate to crates.io.
- Template all other signable apis.
- Create abstraction for signable requests.
- Parse Websocket stringified numbers into appropriate numeric types.
- Parse Api stringified numbers into appropriate numeric types.
- Add Market Order support for order submission.
- Add Stop Order support for order submission.
Acknowledgements
- Ethereal for providing the platform and API.
- Reqwest for HTTP requests in Rust.
- YAWC for WebSocket communication in Rust.
- Serde for serialization and deserialization in Rust.
- Serde JSON for JSON support in Rust.