Skip to content

Commit 04ea3f3

Browse files
authored
Merge pull request #25 from pbeets/release/v0.6.2
Release v0.6.2
2 parents f133dcf + 73d00f3 commit 04ea3f3

File tree

3 files changed

+126
-29
lines changed

3 files changed

+126
-29
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.6.2] - 2025-12-20
11+
1012
### Added
1113

1214
#### New Sender API Methods
@@ -463,13 +465,19 @@ Previous stable release. See git history for earlier changes.
463465

464466
## Version History Summary
465467

468+
- **0.6.2** (2025-12-20): Expanded plant handle APIs, additional message types, OCO order support, and new sender methods
469+
- **0.6.1** (2025-11-24): Environment-specific configuration variables
470+
- **0.6.0** (2025-11-23): Major breaking changes - Removed deprecated code, simplified heartbeat handling, updated to dotenvy
466471
- **0.5.3** (2025-11-22): API expansion - Order history, RMS info, symbol search, trade routes, cancel all orders
467472
- **0.5.2** (2025-11-20): Heartbeat improvements - Optional heartbeat response handling, heartbeat timeout detection, internal refactoring
468473
- **0.5.1** (2025-11-18): Connection error handling improvements - ConnectionError variant, comprehensive WebSocket error detection, automatic error notifications
469474
- **0.5.0** (2025-11-16): Major stability and API improvements - Connection strategies, unified config, panic fixes, connection health monitoring
470475
- **0.4.2** (2025-11-15): Previous stable release
471476

472-
[Unreleased]: https://github.com/pbeets/rithmic-rs/compare/v0.5.3...HEAD
477+
[Unreleased]: https://github.com/pbeets/rithmic-rs/compare/v0.6.2...HEAD
478+
[0.6.2]: https://github.com/pbeets/rithmic-rs/compare/v0.6.1...v0.6.2
479+
[0.6.1]: https://github.com/pbeets/rithmic-rs/compare/v0.6.0...v0.6.1
480+
[0.6.0]: https://github.com/pbeets/rithmic-rs/compare/v0.5.3...v0.6.0
473481
[0.5.3]: https://github.com/pbeets/rithmic-rs/compare/v0.5.2...v0.5.3
474482
[0.5.2]: https://github.com/pbeets/rithmic-rs/compare/v0.5.1...v0.5.2
475483
[0.5.1]: https://github.com/pbeets/rithmic-rs/compare/v0.5.0...v0.5.1

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rithmic-rs"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
description = "Rust client for the Rithmic R | Protocol API to build algo trading systems"
55
license = "MIT OR Apache-2.0"
66
edition = "2024"

README.md

Lines changed: 116 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
# Rust Rithmic R | Protocol API client
22

3-
Unofficial rust client for connecting to Rithmic's R | Protocol API.
4-
53
[![Crates.io](https://img.shields.io/crates/v/rithmic-rs.svg)](https://crates.io/crates/rithmic-rs)
64
[![Documentation](https://docs.rs/rithmic-rs/badge.svg)](https://docs.rs/rithmic-rs)
75

8-
[Documentation](https://docs.rs/rithmic-rs/latest/rithmic_rs/) | [Rithmic APIs](https://www.rithmic.com/apis)
9-
10-
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.
6+
[Official Rithmic API](https://www.rithmic.com/apis)
137

14-
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.
159

16-
## Installation
10+
## Setup
1711

1812
You can install it from crates.io
1913

@@ -25,7 +19,7 @@ Or manually add it to your `Cargo.toml` file.
2519

2620
```
2721
[dependencies]
28-
rithmic-rs = "0.6.1"
22+
rithmic-rs = "0.6.2"
2923
```
3024

3125
## Usage
@@ -34,26 +28,17 @@ rithmic-rs = "0.6.1"
3428

3529
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.
3630

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:
3834

3935
```rust
4036
use rithmic_rs::{RithmicConfig, RithmicEnv};
4137

42-
let config = 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()`:
51-
52-
```rust
5338
let config = RithmicConfig::from_env(RithmicEnv::Demo)?;
5439
```
5540

56-
Required environment variables for `from_env()`:
41+
Required environment variables:
5742
```sh
5843
# For Demo environment
5944
RITHMIC_DEMO_ACCOUNT_ID=your_account_id
@@ -85,13 +70,70 @@ RITHMIC_TEST_ALT_URL=<provided_by_rithmic>
8570

8671
See `examples/.env.blank` for a template with all required variables and connection URLs.
8772

73+
Alternatively, configure using the builder pattern:
74+
75+
```rust
76+
use rithmic_rs::{RithmicConfig, RithmicEnv};
77+
78+
let config = 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+
8886
### Connection Strategies
8987

90-
The library provides three connection strategies:
88+
The library provides three connection strategies for **initial connection**:
9189
- **`Simple`**: Single connection attempt (recommended default, fast-fail)
9290
- **`Retry`**: Indefinite retries with exponential backoff capped at 60 seconds
9391
- **`AlternateWithRetry`**: Alternates between primary and beta URLs with retries
9492

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:
94+
95+
```rust
96+
use rithmic_rs::{RithmicMessage, RithmicConfig, RithmicEnv, ConnectStrategy, RithmicTickerPlant};
97+
98+
async fn maintain_connection() -> Result<(), Box<dyn std::error::Error>> {
99+
let config = RithmicConfig::from_env(RithmicEnv::Demo)?;
100+
101+
loop {
102+
// Connect and get handle
103+
let ticker_plant = RithmicTickerPlant::connect(&config, ConnectStrategy::Retry).await?;
104+
let handle = ticker_plant.get_handle();
105+
106+
handle.login().await?;
107+
handle.subscribe("ESU5", "CME").await?;
108+
109+
// Process messages until disconnection
110+
loop {
111+
match handle.subscription_receiver.recv().await {
112+
Ok(update) => {
113+
// Check for disconnection events
114+
match update.message {
115+
RithmicMessage::HeartbeatTimeout |
116+
RithmicMessage::ForcedLogout(_) |
117+
RithmicMessage::ConnectionError => {
118+
eprintln!("Connection lost, reconnecting...");
119+
break; // Exit inner loop to reconnect
120+
}
121+
RithmicMessage::LastTrade(trade) => {
122+
println!("Trade: {} @ {}", trade.trade_size.unwrap(), trade.trade_price.unwrap());
123+
}
124+
_ => {}
125+
}
126+
}
127+
Err(_) => break, // Channel closed, reconnect
128+
}
129+
}
130+
131+
// Brief delay before reconnecting
132+
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
133+
}
134+
}
135+
```
136+
95137
### Quick Start
96138

97139
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.
@@ -121,17 +163,18 @@ async fn stream_live_ticks() -> Result<(), Box<dyn std::error::Error>> {
121163
}
122164

123165
// Handle connection health issues
166+
// See Connection Strategies section for reconnection example
124167
match update.message {
125168
RithmicMessage::HeartbeatTimeout => {
126-
eprintln!("Connection timeout - must reconnect");
169+
eprintln!("Connection timeout detected");
127170
break;
128171
}
129172
RithmicMessage::ForcedLogout(_) => {
130-
eprintln!("Forced logout - must reconnect");
173+
eprintln!("Forced logout detected");
131174
break;
132175
}
133176
RithmicMessage::ConnectionError => {
134-
eprintln!("Connection error - must reconnect");
177+
eprintln!("Connection error detected");
135178
break;
136179
}
137180
_ => {}
@@ -161,6 +204,52 @@ async fn stream_live_ticks() -> Result<(), Box<dyn std::error::Error>> {
161204
}
162205
```
163206

207+
## Plants
208+
209+
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
228+
229+
### Order Plant
230+
231+
Order management and execution:
232+
- **Order types**: Market, limit, bracket orders, OCO (one-cancels-other) orders
233+
- **Order operations**: Place, modify, cancel orders, exit positions
234+
- **Order tracking**: Subscribe to order updates, show active orders, order history
235+
- **Risk management**: Account/product RMS info, trade routes, easy-to-borrow lists
236+
- **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+
164253
## Examples
165254

166255
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

Comments
 (0)