Spaces:
Running
Running
Add volatilities to the bot
Browse filesFiles changed (4)
- components/volatility-comparison.jsAdded+226
- components/volatility-indicator.jsAdded+402
- index.html+6-4
- script.js+79-23
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226class CustomVolatilityComparison extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.indices = [ { name: 'V10', value: 12.5, change: 2.3, volume: 45200 }, { name: 'V25', value: 28.3, change: -1.5, volume: 38700 }, { name: 'V50', value: 52.1, change: 5.7, volume: 52300 }, { name: 'V75', value: 75.8, change: 8.2, volume: 61200 }, { name: 'V100', value: 98.4, change: -3.1, volume: 48900 } ]; }
connectedCallback() { this.render(); this.startSimulation(); }
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.25rem; } .header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; } .title { font-weight: 700; color: white; display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; } .index-list { display: flex; flex-direction: column; gap: 0.5rem; } .index-item { display: grid; grid-template-columns: 50px 1fr auto auto; align-items: center; gap: 1rem; padding: 0.75rem; background: rgba(15, 23, 42, 0.5); border-radius: 0.5rem; transition: all 0.2s; cursor: pointer; } .index-item:hover { background: rgba(99, 102, 241, 0.1); transform: translateX(4px); } .index-name { font-weight: 600; color: white; font-size: 0.875rem; } .volatility-bar-container { position: relative; height: 6px; background: rgba(255, 255, 255, 0.05); border-radius: 3px; overflow: hidden; } .volatility-bar { height: 100%; border-radius: 3px; transition: width 0.5s ease; } .volatility-bar.v10 { background: linear-gradient(90deg, #10b981, #34d399); } .volatility-bar.v25 { background: linear-gradient(90deg, #3b82f6, #60a5fa); } .volatility-bar.v50 { background: linear-gradient(90deg, #f59e0b, #fbbf24); } .volatility-bar.v75 { background: linear-gradient(90deg, #f43f5e, #fb7185); } .volatility-bar.v100 { background: linear-gradient(90deg, #8b5cf6, #a78bfa); } .index-value { font-weight: 700; color: white; font-size: 0.875rem; font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; } .index-change { font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.5rem; border-radius: 0.25rem; min-width: 60px; text-align: center; } .change-positive { background: rgba(16, 185, 129, 0.15); color: #10b981; } .change-negative { background: rgba(244, 63, 94, 0.15); color: #f43f5e; } .sparkline { width: 60px; height: 24px; } .volume-indicator { display: flex; align-items: center; gap: 0.25rem; font-size: 0.65rem; color: #64748b; margin-top: 0.25rem; } .recommendation { margin-top: 1rem; padding: 0.75rem; background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); border-radius: 0.5rem; } .recommendation-title { font-size: 0.75rem; font-weight: 600; color: #10b981; margin-bottom: 0.25rem; } .recommendation-text { font-size: 0.75rem; color: #94a3b8; } </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"> <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> </svg> Index Comparison </div> <span style="font-size: 0.75rem; color: #64748b;">Live</span> </div> <div class="index-list" id="index-list"> ${this.indices.map(idx => this.renderIndexItem(idx)).join('')} </div> <div class="recommendation"> <div class="recommendation-title">Trading Recommendation</div> <div class="recommendation-text" id="recommendation-text"> V75 shows strong momentum with rising volatility. Consider trend-following strategies. </div> </div> </div> `; } renderIndexItem(idx) { const changeClass = idx.change >= 0 ? 'change-positive' : 'change-negative'; const changeSign = idx.change >= 0 ? '+' : ''; const barClass = idx.name.toLowerCase(); const barWidth = Math.min(100, (idx.value / 120) * 100); return ` <div class="index-item" data-index="${idx.name}"> <span class="index-name">${idx.name}</span> <div> <div class="volatility-bar-container"> <div class="volatility-bar ${barClass}" style="width: ${barWidth}%;"></div> </div> <div class="volume-indicator"> <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline> </svg> Vol: ${(idx.volume / 1000).toFixed(1)}K </div> </div> <span class="index-value">${idx.value.toFixed(1)}</span> <span class="index-change ${changeClass}">${changeSign}${idx.change.toFixed(1)}%</span> </div> `; } startSimulation() { setInterval(() => { this.indices.forEach(idx => { // Simulate small changes const change = (Math.random() - 0.5) * 2; idx.value = Math.max(5, idx.value + change); idx.change += (Math.random() - 0.5) * 0.5; idx.volume += Math.floor((Math.random() - 0.5) * 1000); }); this.updateDisplay(); }, 3000); } updateDisplay() { const list = this.shadowRoot.getElementById('index-list'); if (list) { list.innerHTML = this.indices.map(idx => this.renderIndexItem(idx)).join(''); } // Update recommendation based on highest volatility change const hottest = this.indices.reduce((a, b) => Math.abs(a.change) > Math.abs(b.change) ? a : b); const recText = this.shadowRoot.getElementById('recommendation-text'); if (recText) { const direction = hottest.change > 0 ? 'rising' : 'falling'; recText.textContent = `${hottest.name} shows ${direction} volatility momentum. ${hottest.change > 5 ? 'Consider momentum strategies.' : 'Suitable for range trading.'}`; } }}
customElements.define('custom-volatility-comparison', CustomVolatilityComparison);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402class CustomVolatilityIndicator extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.volatilityData = { current: 75, average: 68, high: 89, low: 45, trend: 'rising' }; }
connectedCallback() { this.render(); this.startSimulation(); }
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.25rem; } .header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; } .title { font-weight: 700; color: white; display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; } .volatility-value { font-size: 2rem; font-weight: 800; color: white; font-variant-numeric: tabular-nums; } .volatility-label { font-size: 0.75rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; } .gauge-container { position: relative; height: 8px; background: rgba(15, 23, 42, 0.8); border-radius: 4px; overflow: hidden; margin: 1rem 0; } .gauge-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease, background-color 0.3s ease; } .gauge-fill.low { background: linear-gradient(90deg, #10b981, #34d399); } .gauge-fill.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); } .gauge-fill.high { background: linear-gradient(90deg, #f43f5e, #fb7185); } .gauge-fill.extreme { background: linear-gradient(90deg, #8b5cf6, #a78bfa); } .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-top: 1rem; } .stat-item { text-align: center; padding: 0.5rem; background: rgba(15, 23, 42, 0.5); border-radius: 0.5rem; } .stat-value { font-size: 0.875rem; font-weight: 600; color: white; font-variant-numeric: tabular-nums; } .stat-label { font-size: 0.65rem; color: #64748b; text-transform: uppercase; margin-top: 0.25rem; } .trend-indicator { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-weight: 500; } .trend-rising { background: rgba(16, 185, 129, 0.15); color: #10b981; } .trend-falling { background: rgba(244, 63, 94, 0.15); color: #f43f5e; } .trend-stable { background: rgba(99, 102, 241, 0.15); color: #6366f1; } .index-selector { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; } .index-btn { padding: 0.375rem 0.75rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 500; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(15, 23, 42, 0.5); color: #94a3b8; cursor: pointer; transition: all 0.2s; } .index-btn:hover { background: rgba(99, 102, 241, 0.2); color: white; } .index-btn.active { background: rgba(99, 102, 241, 0.3); border-color: rgba(99, 102, 241, 0.5); color: white; } .volatility-history { display: flex; gap: 2px; height: 40px; align-items: flex-end; margin-top: 0.75rem; padding: 0.5rem; background: rgba(15, 23, 42, 0.5); border-radius: 0.5rem; } .history-bar { flex: 1; border-radius: 1px; transition: all 0.3s; } .alert-badge { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.7rem; padding: 0.25rem 0.5rem; border-radius: 0.25rem; margin-top: 0.5rem; } .alert-high { background: rgba(244, 63, 94, 0.15); color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.2); } .alert-low { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); } </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"> <path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path> </svg> Volatility Monitor </div> <span class="trend-indicator trend-${this.volatilityData.trend}"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> ${this.getTrendIcon()} </svg> ${this.volatilityData.trend} </span> </div> <div class="index-selector"> <button class="index-btn" data-index="10">V10</button> <button class="index-btn" data-index="25">V25</button> <button class="index-btn" data-index="50">V50</button> <button class="index-btn active" data-index="75">V75</button> <button class="index-btn" data-index="100">V100</button> </div> <div style="display: flex; align-items: baseline; gap: 0.5rem;"> <span class="volatility-value" id="current-vol">75.0</span> <span class="volatility-label">Index</span> </div> <div class="gauge-container"> <div class="gauge-fill high" id="volatility-gauge" style="width: 75%;"></div> </div> <div class="volatility-history" id="vol-history"> ${this.generateHistoryBars()} </div> <div class="stats-grid"> <div class="stat-item"> <div class="stat-value" id="avg-vol">68.2</div> <div class="stat-label">24h Avg</div> </div> <div class="stat-item"> <div class="stat-value" id="high-vol">89.4</div> <div class="stat-label">24h High</div> </div> <div class="stat-item"> <div class="stat-value" id="low-vol">45.1</div> <div class="stat-label">24h Low</div> </div> </div> <div id="volatility-alert"></div> </div> `; this.attachEventListeners(); } getTrendIcon() { const icons = { rising: '<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline>', falling: '<polyline points="23 18 13.5 8.5 8.5 13.5 1 6"></polyline><polyline points="17 18 23 18 23 12"></polyline>', stable: '<line x1="5" y1="12" x2="19" y2="12"></line>' }; return icons[this.volatilityData.trend] || icons.stable; } generateHistoryBars() { let bars = ''; for (let i = 0; i < 30; i++) { const height = 20 + Math.random() * 80; const color = height > 70 ? '#f43f5e' : height > 50 ? '#f59e0b' : '#10b981'; bars += `<div class="history-bar" style="height: ${height}%; background: ${color}; opacity: ${0.3 + (i / 30) * 0.7};"></div>`; } return bars; } attachEventListeners() { const buttons = this.shadowRoot.querySelectorAll('.index-btn'); buttons.forEach(btn => { btn.addEventListener('click', (e) => { buttons.forEach(b => b.classList.remove('active')); e.target.classList.add('active'); this.switchIndex(parseInt(e.target.dataset.index)); }); }); } switchIndex(index) { // Simulate different volatility levels for different indices const baseVolatilities = { 10: { current: 12, average: 10, high: 18, low: 6 }, 25: { current: 28, average: 25, high: 38, low: 15 }, 50: { current: 52, average: 48, high: 65, low: 35 }, 75: { current: 75, average: 68, high: 89, low: 45 }, 100: { current: 98, average: 95, high: 120, low: 75 } }; const data = baseVolatilities[index]; this.volatilityData = { ...this.volatilityData, ...data }; this.updateDisplay(); // Dispatch event for chart update const event = new CustomEvent('index-change', { detail: { index: `R_${index}`, volatility: data.current }, bubbles: true, composed: true }); this.dispatchEvent(event); } startSimulation() { setInterval(() => { // Simulate volatility changes const change = (Math.random() - 0.5) * 4; this.volatilityData.current = Math.max(10, Math.min(150, this.volatilityData.current + change)); // Update trend if (change > 1) this.volatilityData.trend = 'rising'; else if (change < -1) this.volatilityData.trend = 'falling'; else this.volatilityData.trend = 'stable'; // Update high/low this.volatilityData.high = Math.max(this.volatilityData.high, this.volatilityData.current); this.volatilityData.low = Math.min(this.volatilityData.low, this.volatilityData.current); this.updateDisplay(); this.updateHistory(); }, 2000); } updateDisplay() { const currentEl = this.shadowRoot.getElementById('current-vol'); const gaugeEl = this.shadowRoot.getElementById('volatility-gauge'); const avgEl = this.shadowRoot.getElementById('avg-vol'); const highEl = this.shadowRoot.getElementById('high-vol'); const lowEl = this.shadowRoot.getElementById('low-vol'); const trendEl = this.shadowRoot.querySelector('.trend-indicator'); const alertEl = this.shadowRoot.getElementById('volatility-alert'); if (currentEl) currentEl.textContent = this.volatilityData.current.toFixed(1); if (avgEl) avgEl.textContent = this.volatilityData.average.toFixed(1); if (highEl) highEl.textContent = this.volatilityData.high.toFixed(1); if (lowEl) lowEl.textContent = this.volatilityData.low.toFixed(1); if (gaugeEl) { const percentage = Math.min(100, (this.volatilityData.current / 150) * 100); gaugeEl.style.width = `${percentage}%`; // Update color based on level gaugeEl.className = 'gauge-fill'; if (this.volatilityData.current < 30) gaugeEl.classList.add('low'); else if (this.volatilityData.current < 60) gaugeEl.classList.add('medium'); else if (this.volatilityData.current < 90) gaugeEl.classList.add('high'); else gaugeEl.classList.add('extreme'); } if (trendEl) { trendEl.className = `trend-indicator trend-${this.volatilityData.trend}`; trendEl.innerHTML = ` <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> ${this.getTrendIcon()} </svg> ${this.volatilityData.trend} `; } // Show alerts for extreme volatility if (alertEl) { if (this.volatilityData.current > 100) { alertEl.innerHTML = ` <div class="alert-badge alert-high"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <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> Extreme Volatility - High Risk </div> `; } else if (this.volatilityData.current < 20) { alertEl.innerHTML = ` <div class="alert-badge alert-low"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <circle cx="12" cy="12" r="10"></circle> <line x1="12" y1="8" x2="12" y2="12"></line> <line x1="12" y1="16" x2="12.01" y2="16"></line> </svg> Low Volatility - Reduced Opportunity </div> `; } else { alertEl.innerHTML = ''; } } } updateHistory() { const historyEl = this.shadowRoot.getElementById('vol-history'); if (!historyEl) return; const bars = historyEl.querySelectorAll('.history-bar'); const newHeight = 20 + (this.volatilityData.current / 150) * 80; const newColor = this.volatilityData.current > 70 ? '#f43f5e' : this.volatilityData.current > 50 ? '#f59e0b' : '#10b981'; // Shift bars and add new one for (let i = 0; i < bars.length - 1; i++) { bars[i].style.height = bars[i + 1].style.height; bars[i].style.background = bars[i + 1].style.background; } bars[bars.length - 1].style.height = `${newHeight}%`; bars[bars.length - 1].style.background = newColor; }}
customElements.define('custom-volatility-indicator', CustomVolatilityIndicator);138 unmodified lines139140141142143144145146147148149150151152153154155156157158159160161162163138 unmodified lines</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>138 unmodified lines139140141142143144145146147148149150151152153154155156157158159160161162163164165138 unmodified lines</button></div></div><!-- Bot Controls & History --><div class="space-y-4"><custom-bot-controls id="bot-controls"></custom-bot-controls><custom-volatility-indicator id="volatility-indicator"></custom-volatility-indicator><custom-volatility-comparison id="volatility-comparison"></custom-volatility-comparison><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/volatility-indicator.js"></script><script src="components/volatility-comparison.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>
16 unmodified lines171819202122237 unmodified lines31323334353637383914 unmodified lines545556575859606162636465666737 unmodified lines10510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813989 unmodified lines2292302312322332342354 unmodified lines24024124224324424524616 unmodified linescandles: [],currentPrice: 7500,ws: null,init() {this.generateInitialCandles();this.startPriceSimulation();7 unmodified linesdocument.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;14 unmodified lines}this.currentPrice = price;},startPriceSimulation() {setInterval(() => {const volatility = 0.8; // 80% volatility for synthetic indices simulationconst 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 = {37 unmodified lines},evaluateStrategy() {// Simple strategy simulation for demo purposesconst 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 trendif (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 trendif (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 losssignal = Math.random() > 0.5 ? 'rise' : 'fall'; // Random for demo} else if (this.strategy === 'martingale-0.5') {// Martingale 0.5 - increase stake by 50% after losssignal = Math.random() > 0.5 ? 'rise' : 'fall'; // Random for demo}if (signal && this.activeTrades === 0) {this.executeTrade(signal);}89 unmodified linesdocument.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;4 unmodified linesthis.duration = parseInt(config.duration) || this.duration;},updateUI() {// Update stats cardsconst balanceCard = document.getElementById('balance-card');const winRateCard = document.getElementById('winrate-card');16 unmodified lines1718192021222324257 unmodified lines33343536373839404142434445464748495051525354555657585960616263646566676814 unmodified lines8384858687888990919293949537 unmodified lines13313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919089 unmodified lines2802812822832842854 unmodified lines29029129229329429529629729829930030130216 unmodified linescandles: [],currentPrice: 7500,ws: null,currentVolatility: 75,volatilityMultiplier: 1,init() {this.generateInitialCandles();this.startPriceSimulation();7 unmodified linesdocument.addEventListener('start-bot', () => this.startBot());document.addEventListener('stop-bot', () => this.stopBot());document.addEventListener('config-change', (e) => this.updateConfig(e.detail));// Volatility indicator eventsdocument.addEventListener('index-change', (e) => this.handleIndexChange(e.detail));},handleIndexChange(detail) {this.currentVolatility = detail.volatility;// Adjust price simulation based on volatilitythis.volatilityMultiplier = detail.volatility / 75;// Update chart titleconst chartTitle = document.querySelector('h2');if (chartTitle) {const indexNames = {'R_10': 'Volatility 10 Index','R_25': 'Volatility 25 Index','R_50': 'Volatility 50 Index','R_75': 'Volatility 75 Index','R_100': 'Volatility 100 Index'};chartTitle.textContent = indexNames[detail.index] || 'Volatility Index';}// Update badgeconst badge = document.querySelector('.bg-slate-800.text-slate-400');if (badge) {badge.textContent = detail.index;}},generateInitialCandles() {let price = 7500;for (let i = 0; i < 50; i++) {const open = price;14 unmodified lines}this.currentPrice = price;},startPriceSimulation() {setInterval(() => {const baseVolatility = 0.8; // 80% base volatilityconst adjustedVolatility = baseVolatility * this.volatilityMultiplier;const change = (Math.random() - 0.5) * adjustedVolatility * 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 = {37 unmodified lines},evaluateStrategy() {// Simple strategy simulation with volatility considerationconst lastCandle = this.candles[this.candles.length - 1];const prevCandle = this.candles[this.candles.length - 2];if (!lastCandle || !prevCandle) return;// Adjust strategy based on volatilityconst volLevel = this.getVolatilityLevel();let signal = null;let confidence = 0.5;// Volatility-based strategy adjustmentsif (this.strategy === 'trend') {// Stronger trend confirmation in high volatilityconst confirmationNeeded = volLevel === 'high' || volLevel === 'extreme' ? 3 : 2;const recentCandles = this.candles.slice(-confirmationNeeded);const allRising = recentCandles.every(c => c.close > c.open);const allFalling = recentCandles.every(c => c.close < c.open);if (allRising) {signal = 'rise';confidence = volLevel === 'high' ? 0.7 : 0.6;} else if (allFalling) {signal = 'fall';confidence = volLevel === 'high' ? 0.7 : 0.6;}} else if (this.strategy === 'reversal') {// Look for reversal patterns, more effective in extreme volatilityconst bodySize = Math.abs(lastCandle.close - lastCandle.open);const avgBodySize = this.candles.slice(-5).reduce((sum, c) =>sum + Math.abs(c.close - c.open), 0) / 5;if (bodySize > avgBodySize * 1.5) {// Large move detected, potential reversalsignal = lastCandle.close > lastCandle.open ? 'fall' : 'rise';confidence = volLevel === 'extreme' ? 0.65 : 0.55;}} else if (this.strategy === 'martingale') {// Adjust stake based on volatilitysignal = Math.random() > 0.5 ? 'rise' : 'fall';// Reduce stake in extreme volatilityif (volLevel === 'extreme') {this.currentStake = Math.max(this.baseStake, this.currentStake * 0.5);}} else if (this.strategy === 'martingale-0.5') {signal = Math.random() > 0.5 ? 'rise' : 'fall';if (volLevel === 'extreme') {this.currentStake = Math.max(this.baseStake, this.currentStake * 0.7);}}// Apply confidence filterif (confidence < 0.55) signal = null;if (signal && this.activeTrades === 0) {this.executeTrade(signal);}89 unmodified linesdocument.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;4 unmodified linesthis.duration = parseInt(config.duration) || this.duration;},getVolatilityLevel() {if (this.currentVolatility < 20) return 'low';if (this.currentVolatility < 50) return 'medium';if (this.currentVolatility < 80) return 'high';return 'extreme';},updateUI() {// Update stats cardsconst balanceCard = document.getElementById('balance-card');const winRateCard = document.getElementById('winrate-card');
components/volatility-comparison.jsAdded+226
components/volatility-indicator.jsAdded+402
index.html+6-4
script.js+79-23