tradier 0.1.1

This project involves the development of a Rust library for managing trades and market data using the Tradier broker API. The main objective is to provide an efficient and secure interface for executing trades, retrieving real-time quotes, managing portfolios, and accessing historical market data. The library focuses on leveraging Rust's performance and concurrency advantages, enabling integration into high-frequency trading applications and data-intensive financial processing.
Documentation
use reqwest::Client;
use std::error::Error;
use tracing::{error, info};
use tradier::config::Config;
use tradier::utils::logger::setup_logger;

async fn verify_authentication(
    access_token: &str,
    api_base_url: &str,
) -> Result<(), Box<dyn Error>> {
    let client = Client::new();

    let response = client
        .get(format!("{}/v1/user/profile", api_base_url))
        .header("Authorization", format!("Bearer {}", access_token))
        .header("Accept", "application/json")
        .send()
        .await?;

    if response.status().is_success() {
        info!(
            "Authentication successful. Response: {:?}",
            response.text().await?
        );
        Ok(())
    } else {
        Err(format!("Authentication failed. Status: {}", response.status()).into())
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    setup_logger();

    let config = Config::new();
    info!("Config: {:?}", config);

    let access_token = config
        .credentials
        .access_token
        .clone()
        .expect("Access token not found in configuration");

    match verify_authentication(&access_token, &config.rest_api.base_url).await {
        Ok(_) => info!("Authentication verified successfully"),
        Err(e) => error!("Failed to verify authentication: {}", e),
    }

    Ok(())
}