trading-interface / index.html
0xLaszlo's picture
undefined - Initial Deployment
56a925c verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sui AI Trading Agent Prototype</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Custom styles for trading chart and animations */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.trading-chart {
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border-radius: 0.75rem;
position: relative;
overflow: hidden;
}
.chart-line {
position: absolute;
height: 2px;
background: #3b82f6;
width: 100%;
top: 50%;
transform-origin: left center;
}
.price-marker {
position: absolute;
width: 6px;
height: 6px;
background: #ec4899;
border-radius: 50%;
transform: translate(-50%, -50%);
}
.ai-thinking {
animation: pulse 1.5s infinite;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #1e293b;
}
::-webkit-scrollbar-thumb {
background: #3b82f6;
border-radius: 4px;
}
</style>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen">
<!-- Top Navigation -->
<nav class="bg-gray-800 py-4 px-6 flex justify-between items-center sticky top-0 z-50">
<div class="flex items-center space-x-4">
<div class="text-2xl font-bold text-blue-400 flex items-center">
<i class="fas fa-robot mr-2"></i>
<span>SuiAI Trader</span>
</div>
<div class="hidden md:flex space-x-6">
<a href="#" class="hover:text-blue-400 transition">Dashboard</a>
<a href="#" class="hover:text-blue-400 transition">Strategies</a>
<a href="#" class="hover:text-blue-400 transition">History</a>
<a href="#" class="hover:text-blue-400 transition">Analytics</a>
</div>
</div>
<div class="flex items-center space-x-4">
<div class="hidden md:block px-4 py-2 bg-gray-700 rounded-full text-sm">
<span class="text-green-400"><i class="fas fa-circle text-xs mr-1"></i> Connected</span>
<span class="text-gray-300 ml-2">Sui Testnet</span>
</div>
<button class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-full text-sm font-medium transition">
<i class="fas fa-wallet mr-1"></i> 0x3f...4a2b
</button>
<button class="md:hidden text-gray-300 hover:text-white">
<i class="fas fa-bars text-xl"></i>
</button>
</div>
</nav>
<div class="container mx-auto px-4 py-8">
<!-- Header and Stats -->
<div class="mb-8">
<h1 class="text-3xl font-bold mb-2">AI Trading Dashboard</h1>
<p class="text-gray-400 mb-6">Automated trading powered by machine learning on the Sui blockchain</p>
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<div class="bg-gray-800 p-4 rounded-lg border-l-4 border-blue-500">
<div class="text-gray-400 text-sm mb-1">Portfolio Value</div>
<div class="text-2xl font-bold">$24,857.42</div>
<div class="text-green-400 text-sm mt-1"><i class="fas fa-arrow-up mr-1"></i>+12.4% (7d)</div>
</div>
<div class="bg-gray-800 p-4 rounded-lg border-l-4 border-purple-500">
<div class="text-gray-400 text-sm mb-1">Active Bots</div>
<div class="text-2xl font-bold">3</div>
<div class="text-green-400 text-sm mt-1"><i class="fas fa-circle text-xs mr-1"></i> All running</div>
</div>
<div class="bg-gray-800 p-4 rounded-lg border-l-4 border-green-500">
<div class="text-gray-400 text-sm mb-1">24h Trades</div>
<div class="text-2xl font-bold">47</div>
<div class="text-blue-400 text-sm mt-1">+18.2% from yesterday</div>
</div>
<div class="bg-gray-800 p-4 rounded-lg border-l-4 border-yellow-500">
<div class="text-gray-400 text-sm mb-1">Success Rate</div>
<div class="text-2xl font-bold">85.7%</div>
<div class="text-green-400 text-sm mt-1">AI Score: 92/100</div>
</div>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Main Trading Interface -->
<div class="lg:col-span-2">
<!-- Trading Chart -->
<div class="trading-chart h-80 mb-6 p-4 relative">
<div class="absolute top-4 left-4 z-10">
<div class="text-white font-bold">SUI/USDT</div>
<div class="text-green-400 text-2xl">$1.2467 <span class="text-sm ml-1">+2.34%</span></div>
</div>
<div class="absolute top-4 right-4 z-10 flex space-x-2">
<button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-xs">1H</button>
<button class="bg-blue-600 px-3 py-1 rounded text-xs">6H</button>
<button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-xs">1D</button>
<button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded text-xs">1W</button>
</div>
<!-- Simulated chart line with dynamic points -->
<div class="chart-line" style="transform: rotate(-5deg);"></div>
<div class="absolute w-full h-full" id="chartPoints"></div>
<!-- AI Analysis Overlay -->
<div class="absolute bottom-4 left-4 right-4 bg-black bg-opacity-50 p-3 rounded-lg flex items-center">
<div class="bg-blue-600 p-2 rounded-full mr-3 ai-thinking">
<i class="fas fa-brain text-white"></i>
</div>
<div class="text-sm">
<div class="font-medium">AI Analysis: Bullish Momentum</div>
<div class="text-gray-300 text-xs">Detected positive sentiment (72%) with increasing volume. Recommended action: BUY with 0.3% stop-loss.</div>
</div>
</div>
</div>
<!-- Trading Controls -->
<div class="bg-gray-800 rounded-lg p-6 mb-6">
<h2 class="text-xl font-semibold mb-4 flex items-center">
<i class="fas fa-sliders-h mr-2 text-blue-400"></i>
Trading Configuration
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Strategy Selection -->
<div>
<label class="block text-gray-400 text-sm mb-2">Trading Strategy</label>
<div class="relative">
<select class="bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 w-full appearance-none focus:outline-none focus:ring-2 focus:ring-blue-500 pr-8">
<option>Machine Learning Trend</option>
<option>Mean Reversion</option>
<option>Arbitrage Bot</option>
<option>News Sentiment</option>
<option>Custom Strategy</option>
</select>
<div class="absolute right-3 top-3 text-gray-400">
<i class="fas fa-chevron-down"></i>
</div>
</div>
</div>
<!-- Risk Level -->
<div>
<label class="block text-gray-400 text-sm mb-2">Risk Tolerance</label>
<div class="flex items-center">
<input type="range" min="1" max="5" value="3" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
<div class="ml-3 text-xs text-gray-300">
<span class="font-medium text-blue-400">Balanced</span>
<div>(3/5)</div>
</div>
</div>
</div>
<!-- Trading Pairs -->
<div>
<label class="block text-gray-400 text-sm mb-2">Trading Pairs</label>
<div class="flex flex-wrap gap-2">
<button class="bg-blue-600 px-3 py-1 rounded-full text-xs">SUI/USDT</button>
<button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-full text-xs">BTC/USDT</button>
<button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-full text-xs">ETH/USDT</button>
<button class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-full text-xs">+ Add</button>
</div>
</div>
<!-- Trading Mode -->
<div>
<label class="block text-gray-400 text-sm mb-2">Trading Mode</label>
<div class="flex space-x-2">
<button id="autoMode" class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded-lg font-medium text-sm">
<i class="fas fa-robot mr-1"></i> Auto Trade
</button>
<button id="manualMode" class="bg-gray-700 hover:bg-gray-600 px-4 py-2 rounded-lg font-medium text-sm">
<i class="fas fa-hand-paper mr-1"></i> Manual
</button>
</div>
</div>
</div>
<!-- Manual Trade Panel (hidden by default) -->
<div id="manualPanel" class="hidden mt-6 border-t border-gray-700 pt-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label class="block text-gray-400 text-sm mb-2">Amount (SUI)</label>
<input type="text" value="100" class="bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="flex items-end space-x-2">
<button class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded-lg font-medium flex-1">
<i class="fas fa-arrow-up mr-1"></i> Buy
</button>
<button class="bg-red-600 hover:bg-red-700 px-4 py-2 rounded-lg font-medium flex-1">
<i class="fas fa-arrow-down mr-1"></i> Sell
</button>
</div>
<div>
<label class="block text-gray-400 text-sm mb-2">Slippage</label>
<div class="flex">
<input type="text" value="0.5" class="bg-gray-700 border border-gray-600 rounded-l-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500">
<span class="bg-gray-600 px-3 py-2 rounded-r-lg text-sm">%</span>
</div>
</div>
</div>
</div>
</div>
<!-- Recent Transactions (Blockchain Explorer) -->
<div class="bg-gray-800 rounded-lg p-6">
<h2 class="text-xl font-semibold mb-4 flex items-center">
<i class="fas fa-link mr-2 text-purple-400"></i>
Recent Blockchain Transactions
</h2>
<div class="overflow-x-auto">
<table class="w-full">
<thead>
<tr class="text-gray-400 text-sm border-b border-gray-700">
<th class="pb-2 text-left">Transaction ID</th>
<th class="pb-2 text-left">Action</th>
<th class="pb-2 text-right">Amount</th>
<th class="pb-2 text-right">Status</th>
</tr>
</thead>
<tbody>
<tr class="text-sm border-b border-gray-700 hover:bg-gray-700">
<td class="py-3 text-blue-400">0x4a2...c3e1</td>
<td class="py-3">AI Trade: Sell SUI</td>
<td class="py-3 text-right">150 SUI</td>
<td class="py-3 text-right"><span class="bg-green-900 text-green-400 px-2 py-1 rounded-full text-xs">Confirmed</span></td>
</tr>
<tr class="text-sm border-b border-gray-700 hover:bg-gray-700">
<td class="py-3 text-blue-400">0x8b3...d5f7</td>
<td class="py-3">AI Trade: Buy SUI</td>
<td class="py-3 text-right">200 SUI</td>
<td class="py-3 text-right"><span class="bg-green-900 text-green-400 px-2 py-1 rounded-full text-xs">Confirmed</span></td>
</tr>
<tr class="text-sm border-b border-gray-700 hover:bg-gray-700">
<td class="py-3 text-blue-400">0x1e9...7a2d</td>
<td class="py-3">Funds Deposit</td>
<td class="py-3 text-right">1000 USDT</td>
<td class="py-3 text-right"><span class="bg-yellow-900 text-yellow-400 px-2 py-1 rounded-full text-xs">Pending</span></td>
</tr>
<tr class="text-sm hover:bg-gray-700">
<td class="py-3 text-blue-400">0x6f2...9e10</td>
<td class="py-3">AI Trade: Buy BTC</td>
<td class="py-3 text-right">0.02 BTC</td>
<td class="py-3 text-right"><span class="bg-green-900 text-green-400 px-2 py-1 rounded-full text-xs">Confirmed</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Right Sidebar -->
<div>
<!-- Portfolio Summary -->
<div class="bg-gray-800 rounded-lg p-6 mb-6">
<h2 class="text-xl font-semibold mb-4 flex items-center">
<i class="fas fa-wallet mr-2 text-yellow-400"></i>
Portfolio
</h2>
<div class="space-y-4">
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="bg-blue-600 p-2 rounded-full mr-3">
<i class="fas fa-coins text-white"></i>
</div>
<div>
<div class="font-medium">SUI</div>
<div class="text-gray-400 text-sm">5,342.21 SUI</div>
</div>
</div>
<div class="text-right">
<div class="font-medium">$6,658.09</div>
<div class="text-green-400 text-sm">+4.2%</div>
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="bg-green-600 p-2 rounded-full mr-3">
<i class="fab fa-ethereum text-white"></i>
</div>
<div>
<div class="font-medium">ETH</div>
<div class="text-gray-400 text-sm">2.43 ETH</div>
</div>
</div>
<div class="text-right">
<div class="font-medium">$4,187.52</div>
<div class="text-red-400 text-sm">-1.7%</div>
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="bg-orange-500 p-2 rounded-full mr-3">
<i class="fab fa-bitcoin text-white"></i>
</div>
<div>
<div class="font-medium">BTC</div>
<div class="text-gray-400 text-sm">0.042 BTC</div>
</div>
</div>
<div class="text-right">
<div class="font-medium">$1,258.11</div>
<div class="text-green-400 text-sm">+8.3%</div>
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="bg-gray-500 p-2 rounded-full mr-3">
<i class="fas fa-dollar-sign text-white"></i>
</div>
<div>
<div class="font-medium">USDT</div>
<div class="text-gray-400 text-sm">12,753.42 USDT</div>
</div>
</div>
<div class="text-right">
<div class="font-medium">$12,753.42</div>
<div class="text-gray-400 text-sm">0.0%</div>
</div>
</div>
</div>
<div class="mt-6 pt-4 border-t border-gray-700">
<button class="w-full bg-blue-600 hover:bg-blue-700 py-2 rounded-lg font-medium">
<i class="fas fa-plus mr-1"></i> Deposit Funds
</button>
<button class="w-full bg-gray-700 hover:bg-gray-600 py-2 rounded-lg font-medium mt-2">
<i class="fas fa-external-link-alt mr-1"></i> Withdraw
</button>
</div>
</div>
<!-- Active Bots -->
<div class="bg-gray-800 rounded-lg p-6 mb-6">
<h2 class="text-xl font-semibold mb-4 flex items-center">
<i class="fas fa-robot mr-2 text-red-400"></i>
Active Trading Bots
</h2>
<div class="space-y-4">
<div class="bg-gray-700 p-4 rounded-lg">
<div class="flex justify-between items-start mb-2">
<div>
<div class="font-medium">ML Trend Follower</div>
<div class="text-gray-400 text-sm">SUI/USDT</div>
</div>
<div class="bg-green-600 px-2 py-1 rounded-full text-xs">Running</div>
</div>
<div class="flex justify-between text-sm mt-3">
<div>
<div class="text-gray-400">24h Trades</div>
<div class="font-medium">12</div>
</div>
<div>
<div class="text-gray-400">Win Rate</div>
<div class="font-medium text-green-400">83%</div>
</div>
<div>
<div class="text-gray-400">Profit</div>
<div class="font-medium">+$324.21</div>
</div>
</div>
</div>
<div class="bg-gray-700 p-4 rounded-lg">
<div class="flex justify-between items-start mb-2">
<div>
<div class="font-medium">Arbitrage Scanner</div>
<div class="text-gray-400 text-sm">Multi-pair</div>
</div>
<div class="bg-green-600 px-2 py-1 rounded-full text-xs">Running</div>
</div>
<div class="flex justify-between text-sm mt-3">
<div>
<div class="text-gray-400">24h Trades</div>
<div class="font-medium">24</div>
</div>
<div>
<div class="text-gray-400">Win Rate</div>
<div class="font-medium text-green-400">92%</div>
</div>
<div>
<div class="text-gray-400">Profit</div>
<div class="font-medium">+$187.43</div>
</div>
</div>
</div>
<div class="bg-gray-700 p-4 rounded-lg">
<div class="flex justify-between items-start mb-2">
<div>
<div class="font-medium">News Sentiment</div>
<div class="text-gray-400 text-sm">Top 10 Coins</div>
</div>
<div class="bg-green-600 px-2 py-1 rounded-full text-xs">Running</div>
</div>
<div class="flex justify-between text-sm mt-3">
<div>
<div class="text-gray-400">24h Trades</div>
<div class="font-medium">11</div>
</div>
<div>
<div class="text-gray-400">Win Rate</div>
<div class="font-medium text-green-400">73%</div>
</div>
<div>
<div class="text-gray-400">Profit</div>
<div class="font-medium">+$143.75</div>
</div>
</div>
</div>
</div>
<button class="w-full bg-gray-700 hover:bg-gray-600 py-2 rounded-lg font-medium mt-4">
<i class="fas fa-plus mr-1"></i> Create New Bot
</button>
</div>
<!-- System Architecture Diagram -->
<div class="bg-gray-800 rounded-lg p-6">
<h2 class="text-xl font-semibold mb-4 flex items-center">
<i class="fas fa-project-diagram mr-2 text-purple-400"></i>
System Architecture
</h2>
<div class="bg-gray-900 p-4 rounded-lg text-xs">
<div class="flex justify-center mb-4">
<div class="bg-blue-600 text-white px-3 py-2 rounded-lg text-center max-w-xs">
<i class="fas fa-user"></i><br>
User Interface
</div>
</div>
<div class="flex justify-center mb-4">
<div class="border-l-2 border-gray-600 h-6"></div>
</div>
<div class="grid grid-cols-3 gap-2 mb-4">
<div class="bg-purple-600 text-white px-2 py-1 rounded-lg text-center">
<i class="fas fa-brain"></i><br>
AI Engine
</div>
<div class="bg-green-600 text-white px-2 py-1 rounded-lg text-center">
<i class="fas fa-exchange-alt"></i><br>
Trading Logic
</div>
<div class="bg-yellow-600 text-white px-2 py-1 rounded-lg text-center">
<i class="fas fa-database"></i><br>
Data Feed
</div>
</div>
<div class="flex justify-center mb-4">
<div class="border-l-2 border-gray-600 h-6"></div>
</div>
<div class="flex justify-center">
<div class="bg-red-600 text-white px-3 py-2 rounded-lg text-center max-w-xs">
<i class="fas fa-cube"></i><br>
Sui Blockchain
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Code Samples Section -->
<div class="mt-12 bg-gray-800 rounded-lg p-6">
<h2 class="text-2xl font-bold mb-6">Technical Implementation</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<!-- Move Smart Contract Sample -->
<div>
<div class="flex items-center mb-4">
<div class="bg-green-600 p-2 rounded-full mr-3">
<i class="fas fa-file-contract text-white"></i>
</div>
<h3 class="text-xl font-semibold">Sui Move Smart Contract</h3>
</div>
<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto">
<pre class="text-green-400 text-sm"><code>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&lt;SUI&gt;
}
/// User-specific trading account
struct TradingAccount has key {
id: UID,
owner: address,
balance: Balance&lt;SUI&gt;,
open_positions: vector&lt;Position&gt;,
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)
});
}
}</code></pre>
</div>
</div>
<!-- Python AI Logic Sample -->
<div>
<div class="flex items-center mb-4">
<div class="bg-blue-600 p-2 rounded-full mr-3">
<i class="fab fa-python text-white"></i>
</div>
<h3 class="text-xl font-semibold">Python AI Trading Logic</h3>
</div>
<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto">
<pre class="text-blue-400 text-sm"><code>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)</code></pre>
</div>
</div>
</div>
</div>
</div>
<script>
// Generate random chart points
function generateChartPoints() {
const chartContainer = document.getElementById('chartPoints');
chartContainer.innerHTML = '';
const width = chartContainer.parentElement.clientWidth;
const height = chartContainer.parentElement.clientHeight;
// Generate a realistic price path
let x = 0;
let y = height / 2;
let angle = -0.2;
for (let i = 0; i < 40; i++) {
const point = document.createElement('div');
point.className = 'price-marker';
// Random angle change to simulate market movements
angle += (Math.random() - 0.5) * 0.3;
x += width / 30;
y += Math.sin(angle) * 10;
point.style.left = `${x}px`;
point.style.top = `${y}px`;
chartContainer.appendChild(point);
// Connect points with lines
if (i > 0) {
const line = document.createElement('div');
line.className = 'absolute bg-blue-500 h-0.5';
line.style.left = `${prevX}px`;
line.style.top = `${prevY}px`;
line.style.width = `${Math.sqrt(Math.pow(x - prevX, 2) + Math.pow(y - prevY, 2))}px`;
line.style.transform = `rotate(${Math.atan2(y - prevY, x - prevX)}rad)`;
line.style.transformOrigin = '0 0';
chartContainer.appendChild(line);
}
prevX = x;
prevY = y;
}
}
// Toggle manual trading panel
document.getElementById('manualMode').addEventListener('click', function() {
this.classList.remove('bg-gray-700', 'hover:bg-gray-600');
this.classList.add('bg-blue-600', 'hover:bg-blue-700');
document.getElementById('autoMode').classList.remove('bg-blue-600', 'hover:bg-blue-700');
document.getElementById('autoMode').classList.add('bg-gray-700', 'hover:bg-gray-600');
document.getElementById('manualPanel').classList.remove('hidden');
});
document.getElementById('autoMode').addEventListener('click', function() {
this.classList.remove('bg-gray-700', 'hover:bg-gray-600');
this.classList.add('bg-green-600', 'hover:bg-green-700');
document.getElementById('manualMode').classList.remove('bg-blue-600', 'hover:bg-blue-700');
document.getElementById('manualMode').classList.add('bg-gray-700', 'hover:bg-gray-600');
document.getElementById('manualPanel').classList.add('hidden');
});
// Initialize the chart
window.addEventListener('load', generateChartPoints);
window.addEventListener('resize', generateChartPoints);
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=0xLaszlo/trading-interface" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>