-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathconnect.rs
More file actions
28 lines (18 loc) · 803 Bytes
/
connect.rs
File metadata and controls
28 lines (18 loc) · 803 Bytes
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
//! Example: Connect to the RithmicTickerPlant
use tracing::info;
use rithmic_rs::{ConnectStrategy, RithmicConfig, RithmicEnv, RithmicTickerPlant};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenvy::dotenv().ok();
// Create configuration from environment variables
let config = RithmicConfig::from_env(RithmicEnv::Demo)?;
tracing_subscriber::fmt().init();
let ticker_plant = RithmicTickerPlant::connect(&config, ConnectStrategy::Retry).await?;
let ticker_plant_handle = ticker_plant.get_handle();
let resp = ticker_plant_handle.login().await;
info!("Login response: {:#?}", resp);
ticker_plant_handle.disconnect().await?;
info!("Disconnected from Rithmic");
Ok(())
}