tradestation_api/lib.rs
1//! # tradestation-api
2//!
3//! A complete, typed wrapper for the [TradeStation REST API v3](https://api.tradestation.com/docs/).
4//!
5//! This crate provides async access to all 38 TradeStation v3 endpoints with:
6//!
7//! - **OAuth2 Authorization Code** flow with automatic token refresh
8//! - **Market Data**: Historical bars (OHLCV), quotes, symbol info, crypto pairs, options
9//! - **Brokerage**: Accounts, balances, positions, orders, wallets
10//! - **Execution**: Place, replace, cancel orders; OCO/bracket groups; activation triggers; routes
11//! - **Streaming**: HTTP chunked-transfer for live quotes, bars, market depth, options, orders, positions
12//! - **Simulation**: Built-in support for TradeStation's sim API
13//!
14//! # Quickstart
15//!
16//! ```no_run
17//! use tradestation_api::{Client, Credentials, Scope};
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
21//! let creds = Credentials::new("CLIENT_ID", "CLIENT_SECRET");
22//!
23//! // 1. Direct user to authorization URL
24//! let url = creds.authorization_url(&Scope::defaults());
25//! println!("Visit: {url}");
26//!
27//! // 2. Exchange the callback code for tokens
28//! let mut client = Client::new(creds);
29//! client.authenticate("AUTH_CODE").await?;
30//!
31//! // 3. Fetch data
32//! let quotes = client.get_quotes(&["AAPL", "MSFT"]).await?;
33//! for q in "es {
34//! println!("{}: last={}", q.symbol, q.last);
35//! }
36//! Ok(())
37//! }
38//! ```
39//!
40//! # Standalone crate
41//!
42//! This is a standalone library with zero Cannopy dependencies. It can be used
43//! independently in any Rust project that needs TradeStation API access.
44
45pub mod auth;
46pub mod brokerage;
47pub mod client;
48pub mod execution;
49pub mod market_data;
50pub mod streaming;
51
52mod error;
53
54pub use auth::{Credentials, Scope, Token};
55pub use brokerage::{Account, Balance, BodBalance, Order, Position, Wallet};
56pub use client::Client;
57pub use error::Error;
58pub use execution::{
59 ActivationTrigger, OrderGroupRequest, OrderRequest, OrderResponse, Route, TimeInForce,
60};
61pub use market_data::{
62 Bar, BarChartQuery, CryptoPair, OptionExpiration, OptionStrike, ParseNumeric, Quote,
63 RiskRewardRequest, RiskRewardResponse, SpreadType, SymbolInfo,
64};
65pub use streaming::{
66 BoxStream, StreamBar, StreamMarketDepthAggregate, StreamMarketDepthQuote, StreamOptionChain,
67 StreamOptionQuote, StreamOrder, StreamPosition, StreamQuote,
68};