1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # Schwab Types
//!
//! Type definitions for the Charles Schwab Trading and Market Data APIs.
//!
//! This crate provides strongly-typed Rust structures for all API request and response
//! types used by the Schwab APIs. These types are designed to:
//!
//! - Provide type safety for API interactions
//! - Support serialization/deserialization via serde
//! - Match the official Schwab API documentation
//!
//! ## Modules
//!
//! - [`market_data`] - Quotes, price history, and market data types
//! - [`streaming`] - Real-time streaming WebSocket message types
//! - [`accounts`] - Account information and positions
//! - [`trading`] - Order types, transactions, and trading operations
//! - [`common`] - Shared enums and utility types
//!
//! ## Example
//!
//! Outbound orders use the strict [`trading::OrderRequest`] shape: unknown
//! fields are rejected and prices/quantities are exact decimals. Build one
//! with the constructors or deserialize the JSON Schwab documents.
//!
//! ```
//! use rustyschwab_types::Decimal;
//! use rustyschwab_types::trading::{OrderInstruction, OrderRequest, OrderRequestLeg, OrderType};
//!
//! let order = OrderRequest::limit(
//! OrderRequestLeg::equity(OrderInstruction::Buy, "AAPL", 10),
//! Decimal::new(15025, 2),
//! );
//! assert_eq!(order.order_type, Some(OrderType::Limit));
//! order.validate().unwrap();
//!
//! let same: OrderRequest = serde_json::from_value(serde_json::json!({
//! "orderStrategyType": "SINGLE",
//! "orderType": "LIMIT",
//! "session": "NORMAL",
//! "duration": "DAY",
//! "price": "150.25",
//! "orderLegCollection": [{
//! "instruction": "BUY",
//! "quantity": 10,
//! "instrument": { "symbol": "AAPL", "assetType": "EQUITY" }
//! }]
//! }))
//! .unwrap();
//! assert_eq!(serde_json::to_value(&same).unwrap(), serde_json::to_value(&order).unwrap());
//! ```
/// Market data types including quotes, price history, and market hours.
/// Real-time streaming WebSocket message types and subscription management.
/// Account information, positions, and balances.
/// Trading types including orders, transactions, and execution reports.
/// Common types shared across multiple modules.
/// Typed errors from request validation.
pub use ;
/// The exact-decimal type prices and quantities use, so callers do not need
/// their own `rust_decimal` dependency to build orders.
pub use Decimal;