tradestation-api 0.1.0

Complete TradeStation REST API v3 wrapper for Rust
Documentation
//! Quickstart: authenticate and fetch a quote.
//!
//! Run with:
//! ```sh
//! TRADESTATION_CLIENT_ID=xxx TRADESTATION_CLIENT_SECRET=yyy cargo run --example quickstart
//! ```

use tradestation_api::{Client, Credentials, Scope};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client_id =
        std::env::var("TRADESTATION_CLIENT_ID").unwrap_or_else(|_| "YOUR_CLIENT_ID".to_string());
    let client_secret = std::env::var("TRADESTATION_CLIENT_SECRET")
        .unwrap_or_else(|_| "YOUR_CLIENT_SECRET".to_string());

    let creds = Credentials::new(client_id, client_secret);

    // Step 1: Generate the authorization URL
    println!("Authorization URL:");
    println!("{}", creds.authorization_url(&Scope::defaults()));
    println!();
    println!("Visit the URL above, authorize the app, then paste the code from the callback URL.");

    // Step 2: Read the authorization code (in a real app, capture from OAuth callback)
    // let mut code = String::new();
    // std::io::stdin().read_line(&mut code)?;

    // Step 3: Exchange the code for tokens
    // let mut client = Client::new(creds);
    // client.authenticate(code.trim()).await?;

    // Step 4: Fetch quotes
    // let quotes = client.get_quotes(&["AAPL", "MSFT"]).await?;
    // for q in &quotes {
    //     println!("{}: last={} bid={} ask={}", q.symbol, q.last, q.bid, q.ask);
    // }

    // For simulation API, use:
    let _client = Client::new(creds).with_sim();

    println!("(See README for full OAuth2 flow)");
    Ok(())
}