tradestation/lib.rs
1//! <h1 align="center">TradeStation Rust Client</h1>
2//!
3//! <p align="center">
4//! <img src="https://img.shields.io/github/actions/workflow/status/antonio-hickey/tradestation-rs/pre-commit.yml" />
5//! <img alt="Crates.io Total Downloads" src="https://img.shields.io/crates/d/tradestation">
6//! <img src="https://img.shields.io/crates/l/tradestation" />
7//! <img alt="docs.rs" src="https://img.shields.io/docsrs/tradestation">
8//! <img src="https://img.shields.io/github/commit-activity/m/antonio-hickey/tradestation-rs" />
9//! </p>
10//!
11//! An ergonomic Rust client for the [TradeStation API](https://www.tradestation.com/platforms-and-tools/trading-api/) empowering you to build fast, scalable, and production ready trading systems and applications.
12//!
13//! * [Crates.io Homepage](https://crates.io/crates/tradestation)
14//! * [Documentation](https://docs.rs/tradestation/latest/tradestation)
15//! * [GitHub Repository](https://github.com/antonio-hickey/tradestation-rs)
16//! * [Examples](https://github.com/antonio-hickey/tradestation-rs/tree/v0.0.9/examples)
17//!
18//! Features
19//! ---
20//! - 🧮 [Accounting](https://docs.rs/tradestation/latest/tradestation/accounting/index.html): Monitor your risk, positions, balances, order history, and more across multiple accounts.
21//! - 📈 [Market Data](https://docs.rs/tradestation/latest/tradestation/market_data/index.html): Easily fetch and stream real time and historic market data on thousands of assets and derivatives.
22//! - âš¡ [Execution](https://docs.rs/tradestation/latest/tradestation/execution/index.html): Lightning fast trade execution allowing you to place, update, and cancel orders with all kinds of custom configuration.
23//! - 🧪 [Testing](https://github.com/antonio-hickey/tradestation-rs/blob/master/examples/mocking.rs): Supports mocking so you can seamlessly build out environments to test your trading systems and applications.
24//!
25//! Install
26//! ---
27//! Use cargo CLI:
28//! ```sh
29//! cargo add tradestation
30//! ```
31//!
32//! Or manually add it into your `Cargo.toml`:
33//! ```toml
34//! [dependencies]
35//! tradestation = "0.0.9"
36//! ```
37//!
38//! Usage
39//! ---
40//!
41//! For more thorough information, read the [docs](https://docs.rs/tradestation/latest/tradestation/).
42//!
43//! NOTE: See initial auth example on how to get your token (if not already done): https://github.com/antonio-hickey/tradestation-rs/blob/master/examples/initial_auth.rs
44//!
45//! Simple example for streaming bars of trading activity:
46//! ```rust,no_run
47//! use tradestation::{
48//! responses::market_data::StreamBarsResp,
49//! market_data::{BarUnit, StreamBarsQueryBuilder},
50//! token::{Token, Scope},
51//! ClientBuilder, Error,
52//! };
53//!
54//! #[tokio::main]
55//! async fn main() -> Result<(), Error> {
56//! // Build the TradeStation Client
57//! //
58//! // NOTE: If you don't have your token yet, see the inital auth example.
59//! let mut client = ClientBuilder::new()
60//! .credentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY")
61//! .with_token(Token {
62//! access_token: "YOUR_ACCESS_TOKEN".into(),
63//! refresh_token: "YOUR_REFRESH_TOKEN".into(),
64//! id_token: "YOUR_ID_TOKEN".into(),
65//! token_type: String::from("Bearer"),
66//! scope: vec![Scope::MarketData],
67//! expires_in: 1200,
68//! })
69//! .build()
70//! .await?;
71//!
72//! // Build a query to stream Crude Oil Futures
73//! let stream_bars_query = StreamBarsQueryBuilder::new()
74//! .symbol("CLX30")
75//! .unit(BarUnit::Minute)
76//! .interval(240)
77//! .build()?;
78//!
79//! // Stream the bars based on the query built above into
80//! // a custom function to process each bar streamed in.
81//! client
82//! .stream_bars_into(&stream_bars_query, |stream_event| {
83//! println!("Stream Bar Event: {stream_event:?}");
84//! Ok(())
85//! })
86//! .await?;
87//!
88//! Ok(())
89//! }
90//! ```
91//!
92//! Contributing
93//! ---
94//!
95//! There are many ways to contribute like reporting issues, writing documentation, building
96//! out new features and abstractions, refactoring to improve on current abstractions, or
97//! fixing bugs.
98//!
99//! Keep an eye out on open issues :)
100
101/// Functions, structs, and primitives related to accounting.
102pub mod accounting;
103
104/// Structs for all TradeStation API responses.
105pub mod responses;
106
107/// Functions, structs, and primitives related to the tradestation-rs `Client`.
108pub mod client;
109pub use client::{Client, ClientBuilder};
110
111/// The tradestation-rs error definitions.
112mod error;
113/// The tradestation-rs error type.
114pub use error::Error;
115
116/// Functions, Structs, and primitives related to market data.
117pub mod market_data;
118
119/// Functions, structs, and primitives related to auth tokens.
120pub mod token;
121pub use token::{Scope, Token};
122
123/// Functions, Structs, and primitives related to market data.
124pub mod execution;
125
126/// Abstractions, functions, and primitives related to orders.
127pub mod orders {
128 pub use crate::{
129 accounting::orders::{
130 ConditionalOrder, LogicOp, OptionType, Order, OrderAction, OrderLeg, OrderRelationship,
131 OrderStage, OrderStatus, OrderType,
132 },
133 execution::{
134 confirm::OrderConfirmation,
135 orders::{
136 AdvancedOrderOptions, BPWarningStatus, Duration, OrderRequestLeg, OrderTimeInForce,
137 Oso, PegValue, TradeAction,
138 },
139 request::{
140 OrderRequest, OrderRequestBuilder, OrderRequestGroup, OrderRequestGroupBuilder,
141 },
142 route::Route,
143 ticket::OrderTicket,
144 trigger::{ActivationTrigger, ActivationTriggerKey},
145 update::OrderUpdate,
146 },
147 };
148}