Skip to content

Commit e9c7be3

Browse files
committed
fix: add missing event_type field, re-exports, target_size_fp, and update docs
- Add event_type: Option<UserOrderEventType> to UserOrderData (was defined but unused, matching OrderGroupUpdateData pattern) - Re-export UserOrderData and UserOrderEventType from ws module - Add missing target_size_fp field on IncentiveProgram (per official SDK) - Add UserOrders and OrderGroupUpdates to stream_user_channels example - Update ws module docs with complete channel listing - Update order_groups example with new subaccount method
1 parent 1f8eb05 commit e9c7be3

File tree

6 files changed

+47
-12
lines changed

6 files changed

+47
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8989
- `subaccount` filter on `ListRfqsParams` for per-subaccount RFQ queries.
9090
- `subaccount` filter on `GetOrderGroupsParams` for per-subaccount order group
9191
queries. New `get_order_group_for_subaccount()` method on `KalshiClient`.
92-
- `market_id` field on `IncentiveProgram`.
92+
- `market_id` and `target_size_fp` fields on `IncentiveProgram`.
9393

9494
### Fixed
9595

examples/order_groups.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
160160

161161
// Available API Methods
162162
println!("=== Available Order Group Methods ===");
163-
println!(" create_order_group() - Create new order group");
164-
println!(" get_order_group(id) - Get order group details");
165-
println!(" list_order_groups() - List all order groups");
166-
println!(" list_order_groups_with_params() - List with pagination");
167-
println!(" update_order_group_limit(id, r) - Update contracts limit");
168-
println!(" reset_order_group(id) - Reset matched contracts counter");
169-
println!(" trigger_order_group(id) - Trigger auto-cancel manually");
170-
println!(" delete_order_group(id) - Delete group and cancel orders");
163+
println!(" create_order_group() - Create new order group");
164+
println!(" get_order_group(id) - Get order group details");
165+
println!(" get_order_group_for_subaccount(id, sub) - Get for specific subaccount");
166+
println!(" list_order_groups() - List all order groups");
167+
println!(" list_order_groups_with_params() - List with pagination/subaccount");
168+
println!(" update_order_group_limit(id, r) - Update contracts limit");
169+
println!(" reset_order_group(id) - Reset matched contracts counter");
170+
println!(" trigger_order_group(id) - Trigger auto-cancel manually");
171+
println!(" delete_order_group(id) - Delete group and cancel orders");
171172
println!();
172173

173174
println!("=== Done ===");

examples/stream_user_channels.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Example: Stream user-scoped channels (Fill, MarketPositions, Communications).
1+
//! Example: Stream user-scoped channels.
22
//!
33
//! This example demonstrates subscribing to authenticated channels that track
44
//! user-specific activity. These channels don't require market tickers - they
@@ -9,6 +9,8 @@
99
//! - `Fill`: Notifications when your orders are filled
1010
//! - `MarketPositions`: Real-time position updates
1111
//! - `Communications`: RFQ and quote notifications
12+
//! - `OrderGroupUpdates`: Order group lifecycle events
13+
//! - `UserOrders`: Real-time order updates (created, updated, canceled, executed)
1214
//!
1315
//! # Usage
1416
//!
@@ -65,6 +67,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6567
handle.subscribe(Channel::Communications, &[]).await?;
6668
println!(" Communications -> subscribed");
6769

70+
handle.subscribe(Channel::OrderGroupUpdates, &[]).await?;
71+
println!(" OrderGroupUpdates -> subscribed");
72+
73+
handle.subscribe(Channel::UserOrders, &[]).await?;
74+
println!(" UserOrders -> subscribed");
75+
6876
println!("\nWaiting for updates (60 seconds)...");
6977
println!("Tip: Create/fill orders in another terminal to see Fill updates\n");
7078

@@ -111,6 +119,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
111119
StreamMessage::Communication(comm) => {
112120
println!("[COMMUNICATION] {:?}", comm);
113121
}
122+
StreamMessage::OrderGroupUpdate(og) => {
123+
println!(
124+
"[ORDER GROUP] {} | event={:?}",
125+
og.order_group_id, og.event_type
126+
);
127+
}
128+
StreamMessage::UserOrder(order) => {
129+
println!(
130+
"[USER ORDER] {} | event={:?} | ticker={} | status={:?}",
131+
order.order_id,
132+
order.event_type,
133+
order.ticker.as_deref().unwrap_or("?"),
134+
order.status
135+
);
136+
}
114137
StreamMessage::Unsubscribed => {
115138
println!("[UNSUBSCRIBED] sid={}", update.sid);
116139
}
@@ -135,6 +158,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
135158
handle.unsubscribe_all(Channel::Fill).await?;
136159
handle.unsubscribe_all(Channel::MarketPositions).await?;
137160
handle.unsubscribe_all(Channel::Communications).await?;
161+
handle.unsubscribe_all(Channel::OrderGroupUpdates).await?;
162+
handle.unsubscribe_all(Channel::UserOrders).await?;
138163

139164
println!("Shutting down...");
140165
client.shutdown().await?;

src/models/incentive_program.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub struct IncentiveProgram {
3636
/// Target size for the program.
3737
#[serde(default)]
3838
pub target_size: Option<i64>,
39+
/// Target size (fixed-point decimal string).
40+
#[serde(default)]
41+
pub target_size_fp: Option<String>,
3942
/// The market ID associated with this incentive program.
4043
#[serde(default)]
4144
pub market_id: Option<String>,

src/ws.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@
129129
//! - [`Channel::OrderbookDelta`] - Orderbook changes
130130
//! - [`Channel::MarketLifecycle`] - Market status changes
131131
//!
132-
//! User channels (no market tickers needed):
132+
//! User channels (require authentication, no market tickers needed):
133133
//! - [`Channel::Fill`] - Your executed fills
134134
//! - [`Channel::MarketPositions`] - Position changes
135135
//! - [`Channel::Communications`] - RFQ/quote updates
136+
//! - [`Channel::OrderGroupUpdates`] - Order group lifecycle events
137+
//! - [`Channel::UserOrders`] - Real-time order updates (created, updated, canceled, executed)
136138
//! - [`Channel::Multivariate`] - Multivariate event updates
137139
//!
138140
//! # Subscription Management
@@ -175,7 +177,8 @@ pub use message::{
175177
Action, CommunicationData, FillData, MarketLifecycleData, MarketLifecycleEventType,
176178
MarketPositionData, MultivariateLookupData, MveLeg, OrderGroupEventType, OrderGroupUpdateData,
177179
OrderbookDeltaData, OrderbookSnapshotData, PriceLevel, QuoteAcceptedData, QuoteData, RfqData,
178-
RfqDeletedData, Side, StreamMessage, StreamUpdate, TickerData, TradeData,
180+
RfqDeletedData, Side, StreamMessage, StreamUpdate, TickerData, TradeData, UserOrderData,
181+
UserOrderEventType,
179182
};
180183

181184
/// Connection strategy for the WebSocket client.

src/ws/message.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ pub enum UserOrderEventType {
5252
pub struct UserOrderData {
5353
/// The order identifier.
5454
pub order_id: String,
55+
/// The type of event (created, updated, canceled, executed).
56+
#[serde(default)]
57+
pub event_type: Option<UserOrderEventType>,
5558
/// Market ticker identifier.
5659
#[serde(default)]
5760
pub ticker: Option<String>,

0 commit comments

Comments
 (0)