Spaces:
Running
Running
Add martingale 0.5 incase of a loss to recover
Browse filesFiles changed (10)
- README.md+8-5
- components/bot-controls.jsAdded+277
- components/footer.jsAdded+76
- components/navbar.jsAdded+82
- components/stats-card.jsAdded+99
- components/trade-history.jsAdded+189
- components/trading-chart.jsAdded+156
- index.html+164-19
- script.jsAdded+280
- style.css+168-19
12345678910---title: Volatilitybot Proemoji: ⚡colorFrom: yellowcolorTo: greensdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213---title: VolatilityBot Pro 🎯colorFrom: pinkcolorTo: blueemoji: 🐳sdk: staticpinned: falsetags:- deepsite-v3---# Welcome to your new DeepSite project!This project was created with [DeepSite](https://huggingface.co/deepsite).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277class CustomBotControls extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.isRunning = false; }
connectedCallback() { this.render(); this.attachEventListeners(); }
render() { this.shadowRoot.innerHTML = ` <style> :host { display: block; } .panel { background: rgba(30, 41, 59, 0.6); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 1rem; padding: 1.5rem; } .control-group { margin-bottom: 1rem; } label { display: block; font-size: 0.875rem; color: #94a3b8; margin-bottom: 0.5rem; font-weight: 500; } select, input { width: 100%; background: rgba(15, 23, 42, 0.8); border: 1px solid #334155; color: white; padding: 0.5rem 0.75rem; border-radius: 0.5rem; font-size: 0.875rem; transition: all 0.2s; } select:focus, input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); } .toggle-btn { width: 100%; padding: 0.75rem; border-radius: 0.75rem; font-weight: 600; font-size: 0.875rem; transition: all 0.2s; cursor: pointer; border: none; display: flex; align-items: center; justify-content: center; gap: 0.5rem; } .start-btn { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2); } .start-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 8px -1px rgba(16, 185, 129, 0.3); } .stop-btn { background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); color: white; box-shadow: 0 4px 6px -1px rgba(244, 63, 94, 0.2); } .stop-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 8px -1px rgba(244, 63, 94, 0.3); } .status-badge { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; background: rgba(244, 63, 94, 0.1); color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.2); } .status-badge.running { background: rgba(16, 185, 129, 0.1); color: #10b981; border-color: rgba(16, 185, 129, 0.2); } .strategy-info { font-size: 0.75rem; color: #64748b; margin-top: 0.25rem; font-style: italic; } </style> <div class="panel"> <div class="flex items-center justify-between mb-4"> <h3 class="text-lg font-bold text-white flex items-center gap-2"> <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-primary-400"> <rect x="2" y="3" width="20" height="14" rx="2" ry="2"></rect> <line x1="8" y1="21" x2="16" y2="21"></line> <line x1="12" y1="17" x2="12" y2="21"></line> </svg> Bot Configuration </h3> <span id="bot-status" class="status-badge">Stopped</span> </div> <div class="control-group"> <label>Trading Strategy</label> <select id="strategy"> <option value="martingale">Martingale Recovery</option> <option value="martingale-0.5">Martingale 0.5 Recovery</option> <option value="trend">Trend Following</option> <option value="reversal">Reversal Trading</option> <option value="random">Random Walk</option> </select> <div class="strategy-info" id="strategy-desc">Double stake after loss to recover previous losses</div> </div><div class="grid grid-cols-2 gap-3"> <div class="control-group"> <label>Base Stake ($)</label> <input type="number" id="stake" value="10" min="1" step="1"> </div> <div class="control-group"> <label>Max Stake ($)</label> <input type="number" id="max-stake" value="1000" min="10" step="10"> </div> </div>
<div class="grid grid-cols-2 gap-3"> <div class="control-group"> <label>Duration (min)</label> <select id="duration"> <option value="1">1 Minute</option> <option value="5" selected>5 Minutes</option> <option value="15">15 Minutes</option> <option value="60">1 Hour</option> </select> </div> <div class="control-group"> <label>Index</label> <select id="index"> <option value="R_10">Volatility 10</option> <option value="R_25">Volatility 25</option> <option value="R_50">Volatility 50</option> <option value="R_75" selected>Volatility 75</option> <option value="R_100">Volatility 100</option> </select> </div> </div>
<div class="grid grid-cols-2 gap-3 mb-4"> <div class="control-group"> <label>Take Profit ($)</label> <input type="number" id="target-profit" value="100" min="10"> </div> <div class="control-group"> <label>Stop Loss ($)</label> <input type="number" id="stop-loss" value="500" min="10"> </div> </div>
<button id="toggle-btn" class="toggle-btn start-btn"> <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <polygon points="5 3 19 12 5 21 5 3"></polygon> </svg> Start Bot </button>
<div class="mt-4 p-3 rounded-lg bg-slate-800/50 border border-slate-700"> <div class="flex items-center gap-2 text-xs text-slate-400"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-amber-400"> <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path> <line x1="12" y1="9" x2="12" y2="13"></line> <line x1="12" y1="17" x2="12.01" y2="17"></line> </svg> <span>Risk Warning: Trading involves significant risk. Past performance does not guarantee future results.</span> </div> </div> </div> `; }
attachEventListeners() { const toggleBtn = this.shadowRoot.getElementById('toggle-btn'); const strategySelect = this.shadowRoot.getElementById('strategy'); const strategyDesc = this.shadowRoot.getElementById('strategy-desc'); toggleBtn.addEventListener('click', () => { this.isRunning = !this.isRunning; this.updateButtonState(); // Dispatch event to main script const event = new CustomEvent(this.isRunning ? 'start-bot' : 'stop-bot', { bubbles: true, composed: true }); this.dispatchEvent(event); // Update config this.dispatchConfigChange(); }); strategySelect.addEventListener('change', (e) => { const descriptions = { martingale: 'Double stake after loss to recover previous losses', 'martingale-0.5': 'Increase stake by 50% after loss for gradual recovery', trend: 'Follow the market trend direction', reversal: 'Trade against the current trend', random: 'Random entry points for testing' }; strategyDesc.textContent = descriptions[e.target.value]; this.dispatchConfigChange(); });// Listen for all input changes this.shadowRoot.querySelectorAll('input, select').forEach(input => { input.addEventListener('change', () => this.dispatchConfigChange()); }); }
updateButtonState() { const btn = this.shadowRoot.getElementById('toggle-btn'); const status = this.shadowRoot.getElementById('bot-status'); if (this.isRunning) { btn.className = 'toggle-btn stop-btn'; btn.innerHTML = ` <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect> </svg> Stop Bot `; status.textContent = 'Running'; status.className = 'status-badge running'; } else { btn.className = 'toggle-btn start-btn'; btn.innerHTML = ` <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <polygon points="5 3 19 12 5 21 5 3"></polygon> </svg> Start Bot `; status.textContent = 'Stopped'; status.className = 'status-badge'; } }
dispatchConfigChange() { const config = { strategy: this.shadowRoot.getElementById('strategy').value, stake: this.shadowRoot.getElementById('stake').value, maxStake: this.shadowRoot.getElementById('max-stake').value, duration: this.shadowRoot.getElementById('duration').value, targetProfit: this.shadowRoot.getElementById('target-profit').value, stopLoss: this.shadowRoot.getElementById('stop-loss').value }; const event = new CustomEvent('config-change', { detail: config, bubbles: true, composed: true }); this.dispatchEvent(event); }}
customElements.define('custom-bot-controls', CustomBotControls);12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576class CustomFooter extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` <style> :host { display: block; margin-top: 2rem; } footer { background: rgba(15, 23, 42, 0.8); border-top: 1px solid rgba(99, 102, 241, 0.1); padding: 2rem 1rem; } .container { max-width: 80rem; margin: 0 auto; display: flex; flex-direction: column; md: flex-direction: row; justify-content: space-between; align-items: center; gap: 1rem; } .text { color: #64748b; font-size: 0.875rem; } .links { display: flex; gap: 1.5rem; } a { color: #94a3b8; text-decoration: none; font-size: 0.875rem; transition: color 0.2s; } a:hover { color: #6366f1; } .disclaimer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.05); font-size: 0.75rem; color: #475569; text-align: center; max-width: 48rem; margin-left: auto; margin-right: auto; } </style> <footer> <div class="container"> <div class="text">© 2024 VolatilityBot Pro. All rights reserved.</div> <div class="links"> <a href="#">Privacy Policy</a> <a href="#">Terms of Service</a> <a href="#">Risk Disclosure</a> <a href="#">Support</a> </div> </div> <div class="disclaimer"> Trading synthetic indices carries a high level of risk and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade, you should carefully consider your investment objectives, level of experience, and risk appetite. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this platform. </div> </footer> `; }}
customElements.define('custom-footer', CustomFooter);12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182class CustomNavbar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` <style> :host { display: block; } nav { background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(99, 102, 241, 0.2); } .logo-text { background: linear-gradient(135deg, #6366f1 0%, #10b981 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800; } .nav-link { transition: all 0.3s ease; position: relative; } .nav-link::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 2px; background: #6366f1; transition: width 0.3s ease; } .nav-link:hover::after { width: 100%; } .status-badge { animation: pulse 2s infinite; } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } } </style> <nav class="sticky top-0 z-50 px-4 py-4"> <div class="container mx-auto max-w-7xl flex items-center justify-between"> <div class="flex items-center gap-3"> <div class="w-10 h-10 rounded-xl bg-gradient-to-br from-primary-500 to-secondary-500 flex items-center justify-center shadow-lg shadow-primary-500/30"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-white"><path d="M12 2v20M2 12h20M17 7l-5 5-5-5M17 17l-5-5-5 5"/></svg> </div> <div> <h1 class="text-2xl logo-text tracking-tight">VolatilityBot</h1> <p class="text-xs text-slate-400">Pro Trading Suite</p> </div> </div> <div class="hidden md:flex items-center gap-8"> <a href="#" class="nav-link text-slate-300 hover:text-white font-medium">Dashboard</a> <a href="#" class="nav-link text-slate-300 hover:text-white font-medium">Strategies</a> <a href="#" class="nav-link text-slate-300 hover:text-white font-medium">Analytics</a> <a href="#" class="nav-link text-slate-300 hover:text-white font-medium">Settings</a> </div>
<div class="flex items-center gap-4"> <div class="hidden sm:flex items-center gap-2 px-3 py-1.5 rounded-full bg-slate-800/50 border border-slate-700"> <div class="w-2 h-2 rounded-full bg-emerald-500 status-badge"></div> <span class="text-xs text-slate-300">System Online</span> </div> <button class="p-2 rounded-lg hover:bg-slate-800 text-slate-400 hover:text-white transition-colors"> <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/></svg> </button> <div class="w-8 h-8 rounded-full bg-gradient-to-br from-slate-700 to-slate-600 border border-slate-500 flex items-center justify-center cursor-pointer hover:ring-2 hover:ring-primary-500 transition-all"> <span class="text-xs font-bold text-slate-200">JD</span> </div> </div> </div> </nav> `; }}
customElements.define('custom-navbar', CustomNavbar);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899class CustomStatsCard extends HTMLElement { static get observedAttributes() { return ['title', 'value', 'icon', 'color']; }
constructor() { super(); this.attachShadow({ mode: 'open' }); }
attributeChangedCallback(name, oldValue, newValue) { this.render(); }
connectedCallback() { this.render(); }
render() { const title = this.getAttribute('title') || 'Title'; const value = this.getAttribute('value') || '0'; const icon = this.getAttribute('icon') || 'activity'; const color = this.getAttribute('color') || 'primary'; const colorClasses = { primary: 'from-primary-500 to-primary-600 shadow-primary-500/25', secondary: 'from-secondary-500 to-secondary-600 shadow-secondary-500/25', blue: 'from-blue-500 to-blue-600 shadow-blue-500/25', emerald: 'from-emerald-500 to-emerald-600 shadow-emerald-500/25', rose: 'from-rose-500 to-rose-600 shadow-rose-500/25' };
const iconColors = { primary: 'text-primary-400', secondary: 'text-secondary-400', blue: 'text-blue-400', emerald: 'text-emerald-400', rose: 'text-rose-400' };
this.shadowRoot.innerHTML = ` <style> :host { display: block; } .card { background: rgba(30, 41, 59, 0.6); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.05); transition: all 0.3s ease; } .card:hover { transform: translateY(-2px); border-color: rgba(99, 102, 241, 0.3); box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5); } .icon-box { background: linear-gradient(135deg, ${color === 'primary' ? '#6366f1' : color === 'secondary' ? '#10b981' : color === 'blue' ? '#3b82f6' : color === 'emerald' ? '#10b981' : '#f43f5e'}20, transparent); } .value-text { font-variant-numeric: tabular-nums; } </style> <div class="card rounded-2xl p-5 relative overflow-hidden"> <div class="absolute top-0 right-0 w-32 h-32 bg-gradient-to-br ${colorClasses[color]} opacity-5 rounded-full blur-3xl -mr-16 -mt-16"></div> <div class="flex items-start justify-between relative z-10"> <div> <p class="text-slate-400 text-sm font-medium mb-1">${title}</p> <h3 class="text-2xl font-bold text-white value-text tracking-tight">${value}</h3> </div> <div class="icon-box w-10 h-10 rounded-xl flex items-center justify-center ${iconColors[color]}"> <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> ${this.getIconPath(icon)} </svg> </div> </div> <div class="mt-4 flex items-center gap-2"> <span class="text-xs text-slate-500">Updated just now</span> <div class="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"></div> </div> </div> `; }
getIconPath(icon) { const icons = { 'dollar-sign': '<line x1="12" y1="1" x2="12" y2="23"></line><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"></path>', 'trending-up': '<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline>', 'activity': '<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>', 'bar-chart-2': '<line x1="18" y1="20" x2="18" y2="10"></line><line x1="12" y1="20" x2="12" y2="4"></line><line x1="6" y1="20" x2="6" y2="14"></line>', 'user': '<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle>' }; return icons[icon] || icons['activity']; }}
customElements.define('custom-stats-card', CustomStatsCard);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189class CustomTradeHistory extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.trades = []; }
connectedCallback() { this.render(); }
addTrade(trade) { this.trades.unshift(trade); this.updateDisplay(); }
updateTrade(updatedTrade) { const index = this.trades.findIndex(t => t.id === updatedTrade.id); if (index !== -1) { this.trades[index] = updatedTrade; this.updateDisplay(); } }
render() { this.shadowRoot.innerHTML = ` <style> :host { display: block; } .panel { background: rgba(30, 41, 59, 0.6); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 1rem; overflow: hidden; } .header { padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); display: flex; justify-content: space-between; align-items: center; } .title { font-weight: 700; color: white; display: flex; align-items: center; gap: 0.5rem; } .list { max-height: 300px; overflow-y: auto; } .trade-item { padding: 0.75rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.03); display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; transition: background 0.2s; } .trade-item:hover { background: rgba(255, 255, 255, 0.02); } .trade-item:last-child { border-bottom: none; } .trade-type { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; padding: 0.25rem 0.5rem; border-radius: 0.25rem; } .rise { background: rgba(16, 185, 129, 0.1); color: #10b981; } .fall { background: rgba(244, 63, 94, 0.1); color: #f43f5e; } .trade-details { display: flex; flex-direction: column; } .trade-id { font-size: 0.75rem; color: #64748b; } .trade-stake { font-size: 0.875rem; color: #94a3b8; font-weight: 500; } .trade-result { font-size: 0.875rem; font-weight: 700; text-align: right; } .win { color: #10b981; } .loss { color: #f43f5e; } .pending { color: #f59e0b; } .empty-state { padding: 2rem; text-align: center; color: #64748b; font-size: 0.875rem; } .time { font-size: 0.75rem; color: #475569; margin-top: 0.25rem; } </style> <div class="panel"> <div class="header"> <div class="title"> <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-primary-400"> <polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline> </svg> Trade History </div> <span class="text-xs text-slate-500" id="trade-count">0 trades</span> </div> <div class="list" id="trade-list"> <div class="empty-state">No trades yet. Start the bot or place manual trades.</div> </div> </div> `; }
updateDisplay() { const list = this.shadowRoot.getElementById('trade-list'); const count = this.shadowRoot.getElementById('trade-count'); if (this.trades.length === 0) { list.innerHTML = '<div class="empty-state">No trades yet. Start the bot or place manual trades.</div>'; count.textContent = '0 trades'; return; } count.textContent = `${this.trades.length} trades`; list.innerHTML = this.trades.map(trade => { const time = new Date(trade.startTime).toLocaleTimeString(); const typeClass = trade.type === 'rise' ? 'rise' : 'fall'; const typeText = trade.type === 'rise' ? 'Rise' : 'Fall'; let resultClass = 'pending'; let resultText = 'Open...'; if (trade.result) { if (trade.result === 'win') { resultClass = 'win'; resultText = `+$${trade.profit.toFixed(2)}`; } else { resultClass = 'loss'; resultText = `-$${Math.abs(trade.profit).toFixed(2)}`; } } return ` <div class="trade-item"> <div class="trade-details"> <div style="display: flex; gap: 0.5rem; align-items: center;"> <span class="trade-type ${typeClass}">${typeText}</span> <span class="trade-id">#${trade.id.toString().slice(-4)}</span> </div> <div class="time">${time}</div> </div> <div class="trade-stake">$${trade.stake.toFixed(2)}</div> <div class="trade-result ${resultClass}">${resultText}</div> </div> `; }).join(''); }}
customElements.define('custom-trade-history', CustomTradeHistory);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156class CustomTradingChart extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.candles = []; this.currentPrice = 7500; }
connectedCallback() { this.render(); this.canvas = this.shadowRoot.getElementById('chart-canvas'); this.ctx = this.canvas.getContext('2d'); this.resizeCanvas(); window.addEventListener('resize', () => this.resizeCanvas()); this.draw(); }
resizeCanvas() { if (!this.canvas) return; const rect = this.getBoundingClientRect(); this.canvas.width = rect.width; this.canvas.height = 400; this.draw(); }
updateChart(candles, currentPrice) { this.candles = candles; this.currentPrice = currentPrice; this.draw(); }
render() { this.shadowRoot.innerHTML = ` <style> :host { display: block; width: 100%; } .chart-container { position: relative; width: 100%; height: 400px; background: linear-gradient(180deg, rgba(15, 23, 42, 0.3) 0%, transparent 100%); } canvas { width: 100%; height: 100%; } .price-label { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: rgba(99, 102, 241, 0.9); color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: bold; font-family: monospace; pointer-events: none; z-index: 10; } .grid-lines { position: absolute; inset: 0; pointer-events: none; } </style> <div class="chart-container"> <canvas id="chart-canvas"></canvas> <div class="price-label" id="price-label">7500.00</div> </div> `; }
draw() { if (!this.ctx || !this.canvas) return; const ctx = this.ctx; const width = this.canvas.width; const height = this.canvas.height; // Clear canvas ctx.clearRect(0, 0, width, height); if (this.candles.length === 0) return; // Calculate scales const prices = this.candles.flatMap(c => [c.high, c.low]); const minPrice = Math.min(...prices) * 0.999; const maxPrice = Math.max(...prices) * 1.001; const priceRange = maxPrice - minPrice; const candleWidth = (width - 60) / this.candles.length * 0.8; const spacing = (width - 60) / this.candles.length; // Draw grid ctx.strokeStyle = 'rgba(99, 102, 241, 0.1)'; ctx.lineWidth = 1; for (let i = 0; i < 5; i++) { const y = height - (height * (i / 4)); ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(width, y); ctx.stroke(); } // Draw candles this.candles.forEach((candle, i) => { const x = i * spacing + 30; const yOpen = height - ((candle.open - minPrice) / priceRange) * height; const yClose = height - ((candle.close - minPrice) / priceRange) * height; const yHigh = height - ((candle.high - minPrice) / priceRange) * height; const yLow = height - ((candle.low - minPrice) / priceRange) * height; const isRise = candle.close >= candle.open; const color = isRise ? '#10b981' : '#f43f5e'; // Wick ctx.strokeStyle = color; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(x + candleWidth / 2, yHigh); ctx.lineTo(x + candleWidth / 2, yLow); ctx.stroke(); // Body ctx.fillStyle = color; const bodyHeight = Math.max(Math.abs(yClose - yOpen), 1); const bodyY = Math.min(yOpen, yClose); ctx.fillRect(x, bodyY, candleWidth, bodyHeight); }); // Draw current price line const currentY = height - ((this.currentPrice - minPrice) / priceRange) * height; ctx.strokeStyle = '#6366f1'; ctx.lineWidth = 2; ctx.setLineDash([5, 5]); ctx.beginPath(); ctx.moveTo(0, currentY); ctx.lineTo(width, currentY); ctx.stroke(); ctx.setLineDash([]); // Update price label const label = this.shadowRoot.getElementById('price-label'); if (label) { label.textContent = this.currentPrice.toFixed(2); label.style.top = `${currentY}px`; } }}
customElements.define('custom-trading-chart', CustomTradingChart);12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164<!DOCTYPE html><html lang="en" class="dark"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Synthetic Indices Trading Bot</title><link rel="stylesheet" href="style.css"><script src="https://cdn.tailwindcss.com"></script><script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script><script src="https://unpkg.com/feather-icons"></script><script>tailwind.config = {darkMode: 'class',theme: {extend: {colors: {primary: {50: '#eef2ff',100: '#e0e7ff',200: '#c7d2fe',300: '#a5b4fc',400: '#818cf8',500: '#6366f1',600: '#4f46e5',700: '#4338ca',800: '#3730a3',900: '#312e81',},secondary: {50: '#ecfdf5',100: '#d1fae5',200: '#a7f3d0',300: '#6ee7b7',400: '#34d399',500: '#10b981',600: '#059669',700: '#047857',800: '#065f46',900: '#064e3b',}},animation: {'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite','glow': 'glow 2s ease-in-out infinite alternate',},keyframes: {glow: {'0%': { boxShadow: '0 0 5px #6366f1, 0 0 10px #6366f1' },'100%': { boxShadow: '0 0 20px #6366f1, 0 0 30px #6366f1' }}}}}}</script></head><body class="bg-slate-950 text-slate-100 font-sans antialiased overflow-x-hidden"><custom-navbar></custom-navbar><main class="container mx-auto px-4 py-6 max-w-7xl"><!-- Header Stats --><div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6"><custom-stats-cardtitle="Account Balance"value="$10,000.00"icon="dollar-sign"color="primary"id="balance-card"></custom-stats-card><custom-stats-cardtitle="Win Rate"value="0%"icon="trending-up"color="secondary"id="winrate-card"></custom-stats-card><custom-stats-cardtitle="Active Trades"value="0"icon="activity"color="blue"id="active-trades-card"></custom-stats-card><custom-stats-cardtitle="Profit/Loss"value="$0.00"icon="bar-chart-2"color="emerald"id="pnl-card"></custom-stats-card></div><!-- Main Trading Area --><div class="grid grid-cols-1 lg:grid-cols-3 gap-6"><!-- Chart Section --><div class="lg:col-span-2 space-y-4"><div class="bg-slate-900/50 backdrop-blur-xl border border-slate-800 rounded-2xl p-1 shadow-2xl"><div class="flex items-center justify-between px-4 py-3 border-b border-slate-800"><div class="flex items-center gap-3"><span class="relative flex h-3 w-3"><span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span><span class="relative inline-flex rounded-full h-3 w-3 bg-emerald-500"></span></span><h2 class="text-lg font-semibold text-slate-100">Volatility 75 Index</h2><span class="text-xs px-2 py-1 rounded-full bg-slate-800 text-slate-400">R_75</span></div><div class="flex gap-2"><button class="p-2 hover:bg-slate-800 rounded-lg transition-colors" title="1m"><span class="text-xs font-medium">1m</span></button><button class="p-2 hover:bg-slate-800 rounded-lg transition-colors bg-slate-800" title="5m"><span class="text-xs font-medium text-primary-400">5m</span></button><button class="p-2 hover:bg-slate-800 rounded-lg transition-colors" title="15m"><span class="text-xs font-medium">15m</span></button></div></div><custom-trading-chart id="main-chart"></custom-trading-chart></div><!-- Quick Trade Buttons --><div class="grid grid-cols-2 gap-4"><button id="rise-btn" class="group relative overflow-hidden bg-emerald-600 hover:bg-emerald-500 text-white font-bold py-4 px-6 rounded-xl transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98] shadow-lg shadow-emerald-900/20"><div class="absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-1000"></div><div class="flex items-center justify-center gap-2"><i data-feather="trending-up" class="w-5 h-5"></i><span class="text-lg">Rise</span></div><div class="text-xs opacity-80 mt-1">87% Payout</div></button><button id="fall-btn" class="group relative overflow-hidden bg-rose-600 hover:bg-rose-500 text-white font-bold py-4 px-6 rounded-xl transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98] shadow-lg shadow-rose-900/20"><div class="absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-1000"></div><div class="flex items-center justify-center gap-2"><i data-feather="trending-down" class="w-5 h-5"></i><span class="text-lg">Fall</span></div><div class="text-xs opacity-80 mt-1">87% Payout</div></button></div></div><!-- Bot Controls & History --><div class="space-y-4"><custom-bot-controls id="bot-controls"></custom-bot-controls><custom-trade-history id="trade-history"></custom-trade-history></div></div></main><custom-footer></custom-footer><!-- Component Scripts --><script src="components/navbar.js"></script><script src="components/stats-card.js"></script><script src="components/trading-chart.js"></script><script src="components/bot-controls.js"></script><script src="components/trade-history.js"></script><script src="components/footer.js"></script><script src="script.js"></script><script>feather.replace();</script><script src="https://huggingface.co/deepsite/deepsite-badge.js"></script></body></html>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280// Trading Bot State Managementconst TradingBot = { balance: 10000, initialBalance: 10000, activeTrades: 0, totalTrades: 0, winningTrades: 0, isRunning: false, strategy: 'martingale', baseStake: 10, currentStake: 10, maxStake: 1000, targetProfit: 100, stopLoss: 500, contractType: 'rise_fall', duration: 5, candles: [], currentPrice: 7500, ws: null,
init() { this.generateInitialCandles(); this.startPriceSimulation(); this.updateUI(); // Event Listeners document.getElementById('rise-btn')?.addEventListener('click', () => this.manualTrade('rise')); document.getElementById('fall-btn')?.addEventListener('click', () => this.manualTrade('fall')); // Bot control events document.addEventListener('start-bot', () => this.startBot()); document.addEventListener('stop-bot', () => this.stopBot()); document.addEventListener('config-change', (e) => this.updateConfig(e.detail)); },
generateInitialCandles() { let price = 7500; for (let i = 0; i < 50; i++) { const open = price; const change = (Math.random() - 0.5) * 20; const close = open + change; const high = Math.max(open, close) + Math.random() * 10; const low = Math.min(open, close) - Math.random() * 10; this.candles.push({ open, high, low, close, timestamp: Date.now() - (50 - i) * 60000, volume: Math.floor(Math.random() * 1000) }); price = close; } this.currentPrice = price; },
startPriceSimulation() { setInterval(() => { const volatility = 0.8; // 80% volatility for synthetic indices simulation const change = (Math.random() - 0.5) * volatility * 15; this.currentPrice += change; // Add new candle every 5 seconds (simulating 5m timeframe) if (this.candles.length === 0 || Date.now() - this.candles[this.candles.length - 1].timestamp > 5000) { const lastClose = this.candles[this.candles.length - 1]?.close || this.currentPrice; const newCandle = { open: lastClose, high: Math.max(lastClose, this.currentPrice), low: Math.min(lastClose, this.currentPrice), close: this.currentPrice, timestamp: Date.now(), volume: Math.floor(Math.random() * 1000) }; this.candles.push(newCandle); if (this.candles.length > 50) this.candles.shift(); // Update chart this.updateChart(); // Bot logic check if (this.isRunning) { this.evaluateStrategy(); } } // Update current price display this.updatePriceDisplay(); }, 1000); },
updateChart() { const chart = document.getElementById('main-chart'); if (chart && chart.updateChart) { chart.updateChart(this.candles, this.currentPrice); } },
updatePriceDisplay() { const priceElement = document.getElementById('current-price'); if (priceElement) { priceElement.textContent = this.currentPrice.toFixed(2); } },
evaluateStrategy() { // Simple strategy simulation for demo purposes const lastCandle = this.candles[this.candles.length - 1]; const prevCandle = this.candles[this.candles.length - 2]; if (!lastCandle || !prevCandle) return; let signal = null; if (this.strategy === 'trend') { // Follow trend if (lastCandle.close > lastCandle.open && prevCandle.close > prevCandle.open) { signal = 'rise'; } else if (lastCandle.close < lastCandle.open && prevCandle.close < prevCandle.open) { signal = 'fall'; } } else if (this.strategy === 'reversal') { // Counter trend if (lastCandle.close > lastCandle.open && prevCandle.close > prevCandle.open) { signal = 'fall'; } else if (lastCandle.close < lastCandle.open && prevCandle.close < prevCandle.open) { signal = 'rise'; } } else if (this.strategy === 'martingale') { // Martingale - double stake after loss signal = Math.random() > 0.5 ? 'rise' : 'fall'; // Random for demo } else if (this.strategy === 'martingale-0.5') { // Martingale 0.5 - increase stake by 50% after loss signal = Math.random() > 0.5 ? 'rise' : 'fall'; // Random for demo }if (signal && this.activeTrades === 0) { this.executeTrade(signal); } },
executeTrade(type) { if (this.currentStake > this.balance) { this.stopBot(); alert('Insufficient balance!'); return; } this.activeTrades++; this.balance -= this.currentStake; this.totalTrades++; const trade = { id: Date.now(), type: type, stake: this.currentStake, entryPrice: this.currentPrice, startTime: Date.now(), duration: this.duration * 60 * 1000, // Convert to ms status: 'open' }; this.updateUI(); this.addTradeToHistory(trade); // Simulate trade outcome after duration setTimeout(() => { this.closeTrade(trade); }, 3000); // Fast simulation for demo (3 seconds instead of 5 minutes) },
manualTrade(type) { if (this.isRunning) { alert('Please stop the bot before manual trading'); return; } this.executeTrade(type); },
closeTrade(trade) { this.activeTrades--; // Simulate win/loss with 55-60% win rate (realistic, not 90% as that's unsustainable) const isWin = Math.random() < 0.58; // 58% win rate const payout = 0.87; // 87% payout if (isWin) { const profit = trade.stake * payout; this.balance += trade.stake + profit; this.winningTrades++; trade.result = 'win'; trade.profit = profit; } else { trade.result = 'loss'; trade.profit = -trade.stake; // Martingale logic if (this.strategy === 'martingale' && this.isRunning) { this.currentStake = Math.min(trade.stake * 2, this.maxStake); } else if (this.strategy === 'martingale-0.5' && this.isRunning) { this.currentStake = Math.min(trade.stake * 1.5, this.maxStake); } } // Reset stake on win for martingale strategies if (trade.result === 'win' && (this.strategy === 'martingale' || this.strategy === 'martingale-0.5')) { this.currentStake = this.baseStake; }// Check stop loss / take profit const totalPnL = this.balance - this.initialBalance; if (totalPnL <= -this.stopLoss || totalPnL >= this.targetProfit) { this.stopBot(); } this.updateUI(); this.updateTradeInHistory(trade); },
startBot() { this.isRunning = true; this.currentStake = this.baseStake; document.getElementById('bot-status').textContent = 'Running'; document.getElementById('bot-status').className = 'text-emerald-400 font-semibold'; },
stopBot() { this.isRunning = false; this.currentStake = this.baseStake; document.getElementById('bot-status').textContent = 'Stopped'; document.getElementById('bot-status').className = 'text-rose-400 font-semibold'; },
updateConfig(config) { this.strategy = config.strategy || this.strategy; this.baseStake = parseFloat(config.stake) || this.baseStake; this.currentStake = this.baseStake; this.maxStake = parseFloat(config.maxStake) || this.maxStake; this.targetProfit = parseFloat(config.targetProfit) || this.targetProfit; this.stopLoss = parseFloat(config.stopLoss) || this.stopLoss; this.duration = parseInt(config.duration) || this.duration; },
updateUI() { // Update stats cards const balanceCard = document.getElementById('balance-card'); const winRateCard = document.getElementById('winrate-card'); const activeTradesCard = document.getElementById('active-trades-card'); const pnlCard = document.getElementById('pnl-card'); const winRate = this.totalTrades > 0 ? ((this.winningTrades / this.totalTrades) * 100).toFixed(1) : 0; const pnl = this.balance - this.initialBalance; if (balanceCard) balanceCard.setAttribute('value', `$${this.balance.toFixed(2)}`); if (winRateCard) winRateCard.setAttribute('value', `${winRate}%`); if (activeTradesCard) activeTradesCard.setAttribute('value', this.activeTrades.toString()); if (pnlCard) { pnlCard.setAttribute('value', `${pnl >= 0 ? '+' : ''}$${pnl.toFixed(2)}`); pnlCard.setAttribute('color', pnl >= 0 ? 'emerald' : 'rose'); } },
addTradeToHistory(trade) { const history = document.getElementById('trade-history'); if (history && history.addTrade) { history.addTrade(trade); } },
updateTradeInHistory(trade) { const history = document.getElementById('trade-history'); if (history && history.updateTrade) { history.updateTrade(trade); } }};
// Initialize when DOM is readydocument.addEventListener('DOMContentLoaded', () => { TradingBot.init();});12345678910111213141516171819202122232425262728body {padding: 2rem;font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;}h1 {font-size: 16px;margin-top: 0;}p {color: rgb(107, 114, 128);font-size: 15px;margin-bottom: 10px;margin-top: 5px;}.card {max-width: 620px;margin: 0 auto;padding: 16px;border: 1px solid lightgray;border-radius: 16px;}.card p:last-child {margin-bottom: 0;}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177/* Custom Scrollbar */::-webkit-scrollbar {width: 8px;height: 8px;}::-webkit-scrollbar-track {background: #0f172a;}::-webkit-scrollbar-thumb {background: #334155;border-radius: 4px;}::-webkit-scrollbar-thumb:hover {background: #475569;}/* Glassmorphism Utilities */.glass {background: rgba(30, 41, 59, 0.7);backdrop-filter: blur(12px);-webkit-backdrop-filter: blur(12px);border: 1px solid rgba(255, 255, 255, 0.1);}/* Chart Animations */.candle-rise {animation: candleRise 0.3s ease-out;}.candle-fall {animation: candleFall 0.3s ease-out;}@keyframes candleRise {from { transform: scaleY(0); opacity: 0; }to { transform: scaleY(1); opacity: 1; }}@keyframes candleFall {from { transform: scaleY(0); opacity: 0; }to { transform: scaleY(1); opacity: 1; }}/* Pulse Animation for Live Indicator */.live-pulse {box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);animation: livePulse 2s infinite;}@keyframes livePulse {0% {transform: scale(0.95);box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);}70% {transform: scale(1);box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);}100% {transform: scale(0.95);box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);}}/* Gradient Text */.gradient-text {background: linear-gradient(135deg, #6366f1 0%, #10b981 100%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;background-clip: text;}/* Neon Glow Effects */.neon-border {box-shadow: 0 0 5px rgba(99, 102, 241, 0.5),0 0 20px rgba(99, 102, 241, 0.3),inset 0 0 10px rgba(99, 102, 241, 0.1);}/* Custom Range Slider */input[type=range] {-webkit-appearance: none;width: 100%;background: transparent;}input[type=range]::-webkit-slider-thumb {-webkit-appearance: none;height: 16px;width: 16px;border-radius: 50%;background: #6366f1;cursor: pointer;margin-top: -6px;box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);}input[type=range]::-webkit-slider-runnable-track {width: 100%;height: 4px;cursor: pointer;background: #334155;border-radius: 2px;}input[type=range]:focus::-webkit-slider-runnable-track {background: #475569;}/* Toggle Switch */.toggle-checkbox:checked {right: 0;border-color: #6366f1;}.toggle-checkbox:checked + .toggle-label {background-color: #6366f1;}/* Trading Line Animation */.trading-line {stroke-dasharray: 1000;stroke-dashoffset: 1000;animation: drawLine 2s ease-out forwards;}@keyframes drawLine {to {stroke-dashoffset: 0;}}/* Profit/Loss Colors */.profit-text {color: #10b981;text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);}.loss-text {color: #f43f5e;text-shadow: 0 0 10px rgba(244, 63, 94, 0.3);}/* Grid Background */.grid-bg {background-image:linear-gradient(rgba(99, 102, 241, 0.05) 1px, transparent 1px),linear-gradient(90deg, rgba(99, 102, 241, 0.05) 1px, transparent 1px);background-size: 20px 20px;}/* Loading Spinner */.spinner {border: 3px solid rgba(99, 102, 241, 0.3);border-radius: 50%;border-top: 3px solid #6366f1;width: 24px;height: 24px;animation: spin 1s linear infinite;}@keyframes spin {0% { transform: rotate(0deg); }100% { transform: rotate(360deg); }}/* Responsive Table */@media (max-width: 640px) {.responsive-table {display: block;overflow-x: auto;white-space: nowrap;}}
README.md+8-5
components/bot-controls.jsAdded+277
components/footer.jsAdded+76
components/navbar.jsAdded+82
components/stats-card.jsAdded+99
components/trade-history.jsAdded+189
components/trading-chart.jsAdded+156
index.html+164-19
script.jsAdded+280
style.css+168-19