Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
4.9 kB
3
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>DENİZHANBEY TRADE ASSISTANT</title>
  <script src="https://code.highcharts.com/highcharts.js"></script>
  <script src="https://code.highcharts.com/modules/stock.js"></script>
</head>
<body>
  <div class="container">
    <script>
  fetch('https://api.binance.com/api/v3/exchangeInfo')
  .then(response => response.json())
  .then(data => {
    const symbols = data.symbols.filter(item => item.symbol.endsWith('USDT')).map(item => item.symbol);
    const selectElement = document.getElementById('symbol');
    symbols.forEach(symbol => {
      const option = document.createElement('option');
      option.value = symbol;
      option.textContent = symbol;
      selectElement.appendChild(option);
    });
  })
  .catch(error => {
    console.error('Bir hata oluştu:', error);
  });
  </script>
  <div class="container">
    <h1>DENİZHANBEY TRADE ASSISTANT</h1>
    <form method="POST">
      <div class="chart-container">
        <label for="symbol">Symbol Name:</label>
        <select id="symbol" name="symbol">
          {% for symbol in symbols %}
          <option value="{{ symbol }}">{{ symbol }}</option>
          {% endfor %}
        </select>
      </div>
      <p>
        <label for="interval"><strong>TimeFrame:</strong></label>
      </p>
      <select id="interval" name="interval">
        <option value="">Select a timeframe</option>
        <option value="1m"> 1 Dakikalık</option>
        <option value="5m"> 5m Dakikalık</option>
        <option value="15m">15m Dakikalık</option>
        <option value="1h"> 1h Saatlik</option>
        <option value="4h"> 4h Saatlik</option>
        <option value="1d"> 1d Günlük</option>
      </select>
      <div class="chart-container">
        <p><button type="button" onclick="startSocket()">Load WS Graphic</button></p>
        <div class="social-icons">
          <a href="https://www.instagram.com/denizhanbey" target="_blank" rel="noopener noreferrer">
            <img src="https://image.flaticon.com/icons/svg/174/174855.svg" alt="Instagram">
          </a>
          <a href="https://t.me/denizhanbey" target="_blank" rel="noopener noreferrer">
            <img src="https://image.flaticon.com/icons/svg/2111/2111646.svg" alt="Telegram">
          </a>
        </div>
        <div id="chart"></div>
        <div id="time" style="text-align: center; margin-top: 10px;"></div>
        
    </form>
  </div>

  <script>
    function startSocket() {
      var symbol = document.getElementById("symbol").value;
      var interval = document.getElementById("interval").value;

      fetch(`https://api.binance.com/api/v1/klines?symbol=${symbol.toUpperCase()}&interval=${interval}`)
        .then(response => response.json())
        .then(data => {
          var chartData = [];

          for (var i = 0; i < data.length; i++) {
            chartData.push([
              data[i][0],
              parseFloat(data[i][1]),
              parseFloat(data[i][2]),
              parseFloat(data[i][3]),
              parseFloat(data[i][4])
            ]);
          }

          Highcharts.stockChart('chart', {
            rangeSelector: {
              selected: 1
            },
            title: {
              text: `${symbol} Candlestick Chart`
            },
            series: [{
              type: 'candlestick',
              name: 'Candlestick',
              data: chartData
            }]
          });

          var timeDiv = document.getElementById('time');
          var now = new Date();
          var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZone: 'Europe/Istanbul' };
          timeDiv.innerHTML = 'Zaman: ' + now.toLocaleDateString('tr-TR', options);

          // WebSocket bağlantısı
          var socket = new WebSocket(`wss://stream.binance.com:9443/ws/${symbol.toLowerCase()}@trade`);

          socket.onopen = function(event) {
            console.log(`Connected to Binance WebSocket for ${symbol}`);
          };

          socket.onmessage = function(event) {
            var liveData = JSON.parse(event.data);
            console.log(`Received live data for ${symbol}: `, liveData);
            // Grafik üzerinde canlı veriyi güncelleyin
            // Grafikteki son mum çubuğunu canlı veriyle güncellemek için gerekli işlemleri yapın
          };

          socket.onclose = function(event) {
            console.log(`Connection closed for ${symbol}`);
          };
        })
        .catch(error => console.error('Error:', error));
    }
  </script>
</body>
</html>
Leave a Comment