ff_rithmic_api
This rithmic api was written for Fund Forge, an algorithmic trading platform written in rust. (fund-forge available once live testing is underway).
available to import from crates.io as 'ff_rithmic_api'
The crate manages signing in and out of the various rithmic plants.
It contains all the rithmic proto api objects.
It is a base implementation for building a full api.
Be aware! Tests will fail when the market is closed.
You will need a servers.toml file for your API, you can use this template, you only need an address for the specific RithmicServers that you intend to use.
Servers
[]
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
= "wss://{ASK_RITHMIC_FOR_DEV_KIT}"
Complete
This Api allows complete dynamic functionality for all Infrastructure Plants, Requests and Response types.
All possible proto responses and request are already compiled into rust code and they should be visible in your IDE by starting to type Response or Request.
See tests.rs for copy-paste function templates of all response message types for each rithmic plant connection variable.
Hint: some Response types don't start with the word Response as shown in the Rithmic Docs, try typing the actual name of the response object or task eg: instead of "ReponseOrderBook" try typing "OrderBook".
Not Included
No rate limiting.
No Auto reconnect.
No Heart Beat.
This crate just handles the connection and returns the stream
Not ensuring SSL, we are using a MaybeTlsStream, since the domain name is "wss://" I assume this is properly completing the handshake.
Not thoroughly tested, if you experience a locking behaviour, try applying a lock to the fn `api_client.update_heartbeat():' or simply don't use it, I am not sure how this fn will keep up in async contexts if misused.
Note: If the Proto version is ever updated we will need to uncomment the build.rs code and rerun the build.
Login and connect
Step 1a: Enter the server urls for each Server in server.toml, if you are only using Test you will only need to enter the url for Test, just leave the others as they are, I am not allowed to share them, you must apply for dev kit.
Step 1b: Enter your api details provided by rithmic into the rithmic_credentials.toml, if the toml does not exist, then you can create new credentials and save them to a file.
Step 2: Load credentials and create an instance of a RithmicApiClient:
async
Step 3: Connect to a plant and the receiving half of the WebSocket for the specific plant will be returned See examples.rs for a full copy paste handler for each plant type.
async
Parsing and Reading Messages
You receive a tokio_tungstenite::tungstenite::protocol::Message containing a prost::Message, referred to as ProstMessage. If you attempt to treat the original message directly as a ProstMessage, you will encounter the following compile-time error:
error[E0782]: trait objects must include the dyn keyword
–> rithmic_api/handle_tick_plant.rs:xx:xx
|
24 | ProstMessage::Text(text) => {
| ^^^^^^^^^^^^
|
help: add `dyn` keyword before this trait
|
24 | ::Text(text) => {
| ++++
This is how it should be
use Message;
use ;