weex_rust_sdk 0.6.1

Professional Rust SDK for WEEX Exchange - AI Wars ready with full API coverage, AI Log upload, Futures trading
Documentation
use weex_rust_sdk::{WeexClient, Strategy, Exchange, OrderManager, Context};
use weex_rust_sdk::spot::market::Ticker;
use async_trait::async_trait;

// 1. Define your AI Agent Strategy
struct MarketMakerBot {
    spread: f64,
    manager: OrderManager,
}

#[async_trait]
impl Strategy for MarketMakerBot {
    async fn on_tick(&mut self, ticker: Ticker, _ctx: &mut Context) {
        println!("AI Analysis: BTC Price {}, Spread {}", ticker.last, self.spread);
        
        // Mock AI Decision Logic (V4 Professional):
        use rust_decimal::prelude::*;
        let threshold = Decimal::from_str("90000.0").unwrap();
        
        if ticker.last > threshold {
            println!("Signal: SELL (Overbought)");
            // ctx.exchange.place_order(...)
        } else {
             println!("Signal: HOLD");
        }
    }
}

// 2. Run the Agent
#[tokio::main]
async fn main() {
    println!("Starting AI Market Maker Agent...");
    
    let mut bot = MarketMakerBot {
        spread: 0.01,
        manager: OrderManager::new(),
    };
    
    // In a real scenario, this loop receives WS events
    // For demo, we manually feed it one tick
    use rust_decimal::Decimal;
    use std::str::FromStr;
    
    let data = Ticker {
        symbol: "BTCUSDT".to_string(),
        last: Decimal::from_str("90500.0").unwrap(),
        best_ask: Decimal::from_str("90501.0").unwrap(),
        best_bid: Decimal::from_str("90499.0").unwrap(),
    };
    
    let mut ctx = Context { exchange_name: "WEEX".to_string() };
    bot.on_tick(data, &mut ctx).await;
}