You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not all functionality has been implemented, but this is currently being used to trade live capital through Rithmic.
11
-
12
-
Only `order_plant`, `ticker_plant`, `pnl_plant`, `history_plant` are provided. Each plant uses the actor pattern so you'll want to start a plant, and communicate / call commands with it using it's handle. The crate is setup to be used with tokio channels.
The `history_plant` supports loading both historical tick data and time bar data (1-second, 1-minute, 5-minute, daily, and weekly bars).
8
+
Unofficial rust client for connecting to Rithmic's R | Protocol API.
15
9
16
-
## Installation
10
+
## Setup
17
11
18
12
You can install it from crates.io
19
13
@@ -25,7 +19,7 @@ Or manually add it to your `Cargo.toml` file.
25
19
26
20
```
27
21
[dependencies]
28
-
rithmic-rs = "0.6.1"
22
+
rithmic-rs = "0.6.2"
29
23
```
30
24
31
25
## Usage
@@ -34,26 +28,17 @@ rithmic-rs = "0.6.1"
34
28
35
29
Rithmic supports three types of account environments: `RithmicEnv::Demo` for paper trading, `RithmicEnv::Live` for funded accounts, and `RithmicEnv::Test` for the test environment before app approval.
36
30
37
-
Configure your connection using the builder pattern:
31
+
There are two ways to configure your connection: loading from environment variables (recommended) or using the builder pattern programmatically.
32
+
33
+
Load configuration from environment variables:
38
34
39
35
```rust
40
36
userithmic_rs::{RithmicConfig, RithmicEnv};
41
37
42
-
letconfig=RithmicConfig::builder()
43
-
.user("your_username".to_string())
44
-
.password("your_password".to_string())
45
-
.system_name("Rithmic Paper Trading".to_string())
46
-
.env(RithmicEnv::Demo)
47
-
.build()?;
48
-
```
49
-
50
-
Alternatively, you can load from environment variables using `from_env()`:
See `examples/.env.blank` for a template with all required variables and connection URLs.
87
72
73
+
Alternatively, configure using the builder pattern:
74
+
75
+
```rust
76
+
userithmic_rs::{RithmicConfig, RithmicEnv};
77
+
78
+
letconfig=RithmicConfig::builder()
79
+
.user("your_username".to_string())
80
+
.password("your_password".to_string())
81
+
.system_name("Rithmic Paper Trading".to_string())
82
+
.env(RithmicEnv::Demo)
83
+
.build()?;
84
+
```
85
+
88
86
### Connection Strategies
89
87
90
-
The library provides three connection strategies:
88
+
The library provides three connection strategies for **initial connection**:
91
89
-**`Simple`**: Single connection attempt (recommended default, fast-fail)
92
90
-**`Retry`**: Indefinite retries with exponential backoff capped at 60 seconds
93
91
-**`AlternateWithRetry`**: Alternates between primary and beta URLs with retries
94
92
93
+
**Note**: These strategies are for establishing the initial connection only. If you need to reconnect after a connection is lost, you must listen for disconnection events and manually reconnect:
To use this crate, create a configuration and connect to a plant with your chosen strategy. Each plant uses the actor pattern and spawns a task that listens to commands via a handle. Plants like the ticker plant also include a broadcast channel for real-time updates.
Rithmic's API is organized into specialized services called "plants". Each plant uses the actor pattern - you connect to a plant and communicate with it via a handle using tokio channels.
210
+
211
+
### Design Philosophy
212
+
213
+
This library intentionally does **not** provide a single unified client that manages all plants. Instead, each plant is an independent actor that you connect to and manage separately. This design choice prioritizes **flexibility** over convenience:
214
+
215
+
-**Thread/task distribution**: Run different plants on different threads or async tasks based on your performance needs
216
+
-**Selective connectivity**: Connect only to the plants you need (e.g., market data only, no order management)
217
+
-**Independent lifecycle**: Each plant can be started, stopped, and reconnected independently
218
+
-**Resource control**: Fine-grained control over connection pooling and resource allocation
219
+
220
+
The trade-off is **reduced usability** - you must manage multiple connections and handles yourself rather than having a single client object. For most applications, this flexibility is worth the additional setup code.
221
+
222
+
### Ticker Plant
223
+
224
+
Real-time market data streaming:
225
+
-**Market data subscriptions**: Last trades, best bid/offer (BBO), order book depth
226
+
-**Symbol discovery**: Search symbols, list exchanges, get instruments by underlying
227
+
-**Reference data**: Tick size tables, product codes, front month contracts, volume at price
-**Agreements**: List, accept, and manage exchange agreements
237
+
238
+
### PnL Plant
239
+
240
+
Profit and loss monitoring:
241
+
-**Position snapshots**: Current P&L for all positions
242
+
-**Real-time updates**: Subscribe to account and instrument-level P&L changes
243
+
244
+
### History Plant
245
+
246
+
Historical market data:
247
+
-**Tick data**: Load historical tick-by-tick data for any time range
248
+
-**Time bars**: 1-second, 1-minute, 5-minute, daily, and weekly bars
249
+
-**Volume profile**: Minute bars with volume profile data
250
+
-**Bar subscriptions**: Subscribe to real-time time bar and tick bar updates
251
+
252
+
164
253
## Examples
165
254
166
255
The repository includes several examples to help you get started. Examples use environment variables for configuration - set the required variables (listed above) in your environment or use a `.env` file.
0 commit comments