AI Trading Dashboard

Automated trading powered by machine learning on the Sui blockchain

Portfolio Value
$24,857.42
+12.4% (7d)
Active Bots
3
All running
24h Trades
47
+18.2% from yesterday
Success Rate
85.7%
AI Score: 92/100
SUI/USDT
$1.2467 +2.34%
AI Analysis: Bullish Momentum
Detected positive sentiment (72%) with increasing volume. Recommended action: BUY with 0.3% stop-loss.

Trading Configuration

Balanced
(3/5)

Recent Blockchain Transactions

Transaction ID Action Amount Status
0x4a2...c3e1 AI Trade: Sell SUI 150 SUI Confirmed
0x8b3...d5f7 AI Trade: Buy SUI 200 SUI Confirmed
0x1e9...7a2d Funds Deposit 1000 USDT Pending
0x6f2...9e10 AI Trade: Buy BTC 0.02 BTC Confirmed

Portfolio

SUI
5,342.21 SUI
$6,658.09
+4.2%
ETH
2.43 ETH
$4,187.52
-1.7%
BTC
0.042 BTC
$1,258.11
+8.3%
USDT
12,753.42 USDT
$12,753.42
0.0%

Active Trading Bots

ML Trend Follower
SUI/USDT
Running
24h Trades
12
Win Rate
83%
Profit
+$324.21
Arbitrage Scanner
Multi-pair
Running
24h Trades
24
Win Rate
92%
Profit
+$187.43
News Sentiment
Top 10 Coins
Running
24h Trades
11
Win Rate
73%
Profit
+$143.75

System Architecture


User Interface

AI Engine

Trading Logic

Data Feed

Sui Blockchain

Technical Implementation

Sui Move Smart Contract

module ai_trader::trading_contract {
    use sui::tx_context::TxContext;
    use sui::coin::{Coin, TreasuryCap};
    use sui::balance::{Self, Balance};
    use sui::transfer;

    /// Global trading configuration shared by all users
    struct GlobalConfig has key {
        id: UID,
        fee_percentage: u64,
        treasury_cap: TreasuryCap<SUI>
    }

    /// User-specific trading account
    struct TradingAccount has key {
        id: UID,
        owner: address,
        balance: Balance<SUI>,
        open_positions: vector<Position>,
        trading_stats: TradingStats
    }

    /// Represents an open trading position
    struct Position has store {
        pair: String,
        amount: u64,
        entry_price: u64,
        direction: bool, // true = long, false = short
        timestamp: u64
    }

    /// Initialize the trading contract
    public entry fun init(ctx: &mut TxContext) {
        let treasury_cap = treasury_policy::create_supply_limited(
            1000000000, // max supply
            18, // decimals
            ctx
        );
        
        let config = GlobalConfig {
            id: object::new(ctx),
            fee_percentage: 10, // 0.1%
            treasury_cap
        };
        
        transfer::share_object(config);
    }

    /// Execute a trade through the AI agent
    public entry fun execute_ai_trade(
        config: &GlobalConfig,
        account: &mut TradingAccount,
        pair: String,
        amount: u64,
        is_buy: bool,
        ctx: &mut TxContext
    ) {
        // AI trading logic would be implemented here
        // including price checking, risk management, etc.
        
        // Charge trading fee
        let fee = (amount * config.fee_percentage) / 10000;
        let trade_amount = amount - fee;
        
        // Update account balance
        let coin = balance::withdraw(&mut account.balance, trade_amount);
        
        // Execute trade (simplified for example)
        if (is_buy) {
            // Buy logic
        } else {
            // Sell logic
        }
        
        // Update trading stats
        event::emit(AITradeEvent {
            trader: tx_context::sender(ctx),
            pair: pair,
            amount: trade_amount,
            is_buy: is_buy,
            timestamp: tx_context::epoch(ctx)
        });
    }
}

Python AI Trading Logic

import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sui_sdk import SuiClient

class AITradingAgent:
    def __init__(self, sui_client: SuiClient):
        self.sui = sui_client
        self.model = self._train_model()
        
    def _train_model(self):
        """Train the AI model with historical data"""
        # Load historical price data
        data = pd.read_csv('historical_prices.csv')
        data['returns'] = data['close'].pct_change()
        
        # Create features
        data['sma_50'] = data['close'].rolling(50).mean()
        data['sma_200'] = data['close'].rolling(200).mean()
        data['rsi'] = self._calculate_rsi(data['close'])
        data = data.dropna()
        
        # Create target (1 if next return is positive, 0 otherwise)
        data['target'] = (data['returns'].shift(-1) > 0).astype(int)
        
        # Train Random Forest classifier
        features = ['sma_50', 'sma_200', 'rsi']
        X = data[features]
        y = data['target']
        
        model = RandomForestClassifier(n_estimators=100)
        model.fit(X, y)
        
        return model
    
    def analyze_market(self, pair: str):
        """Analyze market conditions and make a trading decision"""
        # Fetch current market data
        candles = self.sui.get_candles(pair, '1h', limit=300)
        df = pd.DataFrame(candles)
        
        # Calculate features for prediction
        df['sma_50'] = df['close'].rolling(50).mean()
        df['sma_200'] = df['close'].rolling(200).mean()
        df['rsi'] = self._calculate_rsi(df['close'])
        latest = df.iloc[-1]
        
        # Make prediction
        features = latest[['sma_50', 'sma_200', 'rsi']].values.reshape(1, -1)
        proba = self.model.predict_proba(features)[0]
        
        # Calculate confidence score
        confidence = max(proba) * 100
        signal = 'BUY' if np.argmax(proba) == 1 else 'SELL'
        
        return {
            'pair': pair,
            'signal': signal,
            'confidence': confidence,
            'current_price': latest['close'],
            'recommended_size': self._calculate_position_size(confidence)
        }
    
    def execute_trade(self, decision):
        """Execute trade through Sui blockchain"""
        # Prepare transaction
        tx = {
            'function': 'ai_trader::trading_contract::execute_ai_trade',
            'arguments': [
                decision['pair'],
                decision['recommended_size'],
                decision['signal'] == 'BUY'
            ],
            'gas_budget': 10000
        }
        
        # Sign and execute transaction
        result = self.sui.execute_transaction(tx)
        return result

    def _calculate_rsi(self, prices, window=14):
        deltas = np.diff(prices)
        seed = deltas[:window+1]
        up = seed[seed >= 0].sum()/window
        down = -seed[seed < 0].sum()/window
        rs = up/down
        rsi = np.zeros_like(prices)
        rsi[:window] = 100. - 100./(1.+rs)
        
        for i in range(window, len(prices)):
            delta = deltas[i-1]
            if delta > 0:
                upval = delta
                downval = 0.
            else:
                upval = 0.
                downval = -delta
            
            up = (up*(window-1) + upval)/window
            down = (down*(window-1) + downval)/window
            rs = up/down
            rsi[i] = 100. - 100./(1.+rs)
        
        return rsi
    
    def _calculate_position_size(self, confidence):
        """Calculate position size based on confidence and risk management"""
        base_size = 100  # Base size in SUI
        risk_multiplier = confidence / 50  # Scale with confidence
        return int(base_size * risk_multiplier)

Made with DeepSite LogoDeepSite - 🧬 Remix