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
//! Async implementation of Kite Connect's WebSocket Steaming API
//!
//! This crate provides types to subscribe and receive live quotes for instruments during market hours via WebSockets.
//! The response is parsed and converted into Rust types.
//! The WebSocket connection is managed by the library and reconnected automatically.
//!
//! # Usage
//! ```
//!
//! use kiteticker_async::{KiteTickerAsync, Mode, TickerMessage};
//!
//! #[tokio::main]
//! pub async fn main() -> Result<(), String> {
//! let api_key = std::env::var("KITE_API_KEY").unwrap_or_default();
//! let access_token = std::env::var("KITE_ACCESS_TOKEN").unwrap_or_default();
//! let ticker = KiteTickerAsync::connect(&api_key, &access_token).await?;
//!
//! let token = 408065;
//! // subscribe to an instrument
//! let mut subscriber = ticker
//! .subscribe(&[token], Some(Mode::Full))
//! .await?;
//!
//! // await quotes
//! loop {
//! if let Some(msg) = subscriber.next_message().await? {
//! match msg {
//! TickerMessage::Ticks(ticks) => {
//! let tick = ticks.first().unwrap();
//! println!("Received tick for instrument_token {}, {:?}", tick.instrument_token, tick);
//! break;
//! },
//! _ => continue,
//! }
//! }
//! }
//!
//! Ok(())
//! }
//! ```
pub use ;
pub use ;