ccxt-rust 0.1.5

Cryptocurrency exchange trading library in Rust
Documentation
//! Binance Position Mode Example
//!
//! Note: Position mode methods are not yet migrated to the new modular structure.
//! This is a placeholder example.
//!
//! # Running the Example
//!
//! ```bash
//! cargo run --example binance_position_mode_example
//! ```

use ccxt_core::ExchangeConfig;
use ccxt_exchanges::binance::Binance;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("=================================");
    println!("Binance Position Mode Example");
    println!("=================================\n");

    let config = ExchangeConfig {
        api_key: std::env::var("BINANCE_API_KEY")
            .ok()
            .map(ccxt_core::SecretString::new),
        secret: std::env::var("BINANCE_API_SECRET")
            .ok()
            .map(ccxt_core::SecretString::new),
        ..Default::default()
    };

    let _binance = Binance::new(config)?;

    // Note: Position mode methods are not yet migrated to the new modular structure:
    // - fetch_position_mode
    // - set_position_mode
    // - fetch_positions

    println!("Note: Position mode methods are not yet migrated to the new modular structure.");
    println!("      See rest_old.rs for the original implementations.\n");

    println!("Code examples (not executable until methods are migrated):");
    println!(
        r#"
// Fetch current position mode
let mode = binance.fetch_position_mode(None).await?;
println!("Current mode: dual_side={{}}", mode.dual_side_position);

// Set position mode (hedge mode = true, one-way mode = false)
let result = binance.set_position_mode(true, None).await?;

// Fetch positions
let positions = binance.fetch_positions(None, None).await?;
for position in positions {{
    println!("Symbol: {{}}, Contracts: {{:?}}", position.symbol, position.contracts);
}}
"#
    );

    println!("\n=================================");
    println!("Example completed!");
    println!("=================================");

    Ok(())
}