ctrader-rs 0.1.2

Rust SDK for the cTrader Open API
Documentation
//! Get all broker account IDs linked to your access token.
//!
//! Usage:
//!   cargo run --example version

use std::time::Duration;

use ctrader_rs::{Client, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    dotenvy::dotenv().ok();

    tracing_subscriber::fmt()
        .with_env_filter("version=debug,ctrader_rs=debug")
        .with_line_number(true)
        .init();

    let client_id = std::env::var("CTRADER_CLIENT_ID")?;
    let secret = std::env::var("CTRADER_SECRET")?;

    let config = Config::new(client_id, secret).deadline(Duration::from_secs(5));

    tracing::debug!("Connecting to demo.ctraderapi.com:5035 …");
    let client = Client::start(config).await?;
    tracing::debug!("✓ Connected and application authenticated");

    // Fetch all accounts linked to the token
    let res = client.version().await?;

    tracing::debug!("Version: {}", res.version);

    Ok(())
}