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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! # tastytrade
//!
//! `tastytrade` is a Rust client library for the Tastytrade API, providing programmatic access to
//! trading functionality, market data, and account information.
//!
//! ## Features
//!
//! - Authentication with Tastytrade accounts
//! - Real-time market data streaming via DxFeed
//! - Account and positions information
//! - Order management (placing, modifying, canceling)
//! - Real-time account streaming for balance updates and order status changes
//!
//! ## Usage
//!
//! ```rust,no_run
//! use tastytrade::TastyTrade;
//! use tastytrade::utils::config::TastyTradeConfig;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Login to Tastytrade
//!
//! let config = TastyTradeConfig::from_env();
//! let tasty = TastyTrade::login(&config).await?;
//!
//! // Get account information
//! let accounts = tasty.accounts().await?;
//! for account in accounts {
//! println!("Account: {}", account.number().0);
//!
//! // Get positions
//! let positions = account.positions().await?;
//! println!("Positions: {}", positions.len());
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Real-time Data
//!
//! The library supports real-time data streaming for both market data and account updates using DXLink:
//!
//! ```rust,no_run
//! // Create a quote streamer
//! use tastytrade::{Symbol, TastyTrade};
//! use tastytrade::utils::config::TastyTradeConfig;
//! use tastytrade::dxfeed;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = TastyTradeConfig::from_env();
//! let tasty = TastyTrade::login(&config)
//! .await
//! .unwrap();
//! let mut quote_streamer = tasty.create_quote_streamer().await?;
//! let mut quote_sub = quote_streamer.create_sub(dxfeed::DXF_ET_QUOTE | dxfeed::DXF_ET_GREEKS);
//!
//! // Add symbols to subscribe to
//! quote_sub.add_symbols(&[Symbol("AAPL".to_string())]);
//!
//! // Listen for events
//! if let Ok(dxfeed::Event { sym, data }) = quote_sub.get_event().await {
//! match data {
//! dxfeed::EventData::Quote(quote) => {
//! println!("Quote for {}: {}/{}", sym, quote.bid_price, quote.ask_price);
//! }
//! _ => {}
//! }
//! }
//! Ok(())
//! }
//! ```
//!
//! ## Setup Instructions
//!
//! 1. Clone the repository:
//! ```shell
//! git clone https://github.com/joaquinbejar/tastytrade
//! cd tastytrade
//! ```
//!
//! 2. Build the project:
//! ```shell
//! make build
//! ```
//!
//! 3. Run tests:
//! ```shell
//! make test
//! ```
//!
//! 4. Format the code:
//! ```shell
//! make fmt
//! ```
//!
//! 5. Run linting:
//! ```shell
//! make lint
//! ```
//!
//! 6. Clean the project:
//! ```shell
//! make clean
//! ```
//!
//! 7. Run the project:
//! ```shell
//! make run
//! ```
//!
//! 8. Fix issues:
//! ```shell
//! make fix
//! ```
//!
//! 9. Run pre-push checks:
//! ```shell
//! make pre-push
//! ```
//!
//! 10. Generate documentation:
//! ```shell
//! make doc
//! ```
//!
//! 11. Publish the package:
//! ```shell
//! make publish
//! ```
//!
//! 12. Generate coverage report:
//! ```shell
//! make coverage
//! ```
//!
//!
//! ## CLI Example
//!
//! This crate also includes a sample CLI application in the `tastytrade-cli` directory
//! that demonstrates a portfolio viewer with real-time updates.
//!
//! ## Testing
//!
//! To run unit tests:
//! ```shell
//! make test
//! ```
//!
//! To run tests with coverage:
//! ```shell
//! make coverage
//! ```
//!
//! ## Contribution and Contact
//!
//! We welcome contributions to this project! If you would like to contribute, please follow these steps:
//!
//! 1. Fork the repository.
//! 2. Create a new branch for your feature or bug fix.
//! 3. Make your changes and ensure that the project still builds and all tests pass.
//! 4. Commit your changes and push your branch to your forked repository.
//! 5. Submit a pull request to the main repository.
//!
//! If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:
//!
//! **Joaquín Béjar García**
//! - Email: jb@taunais.com
//! - GitHub: [joaquinbejar](https://github.com/joaquinbejar)
//!
//! We appreciate your interest and look forward to your contributions!
//!
pub use accounts;
pub use TastyResult;
pub use TastyTrade;
pub use ;
pub use dxfeed;
pub use InstrumentType;
pub use ;
pub use ;
pub use ;