HEX
Server: Apache
System: Linux vps-00003980 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64
User: web716 (1018)
PHP: 7.4.25
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/clients/client2/web716/web/stream/index4.php
<html>
    <head>
        <title>BTC/USD stream</title>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="60" >

        <script src="https://code.highcharts.com/stock/highstock.js"></script>
        <script src="https://code.highcharts.com/stock/modules/data.js"></script>
        <script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
        <script src="https://code.highcharts.com/highcharts.js"></script>
        <script src="https://code.highcharts.com/modules/series-label.js"></script>
        <script src="https://code.highcharts.com/modules/exporting.js"></script>
        <script src="https://code.highcharts.com/modules/export-data.js"></script>
        <script src="https://code.highcharts.com/modules/accessibility.js"></script>

 

        <style type="text/css">
        body {font-family:Verdana;font-size:12px;}
        .tg  {border-collapse:collapse;border-color:#9ABAD9;border-spacing:0;}
        .tg td{background-color:#EBF5FF;border-color:#9ABAD9;border-style:solid;border-width:1px;color:#444;
            font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;}
        .tg th{background-color:#409cff;border-color:#9ABAD9;border-style:solid;border-width:1px;color:#fff;
            font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
        .tg .tg-ggkl{font-family:Verdana, Geneva, sans-serif !important;;font-size:12px;text-align:right;vertical-align:top}
        .tg .tg-0lax{text-align:right;vertical-align:top}
        .tg .tg-02ax{text-align:left;vertical-align:top;max-width:500px;}

        </style>
    </head>
    <body>
        <div id="container" style="height: 740px; width: 1400px; position: absolute; top: 0px; left: 500px;"></div>
         <div id="container2" style="height: 740px; width: 1400px; position: absolute; top: 0px; left: 500px; display: none;"></div>
         <div id="button1" style="height: 40px; width: 150px; position: absolute; top: 10px; left: 800px;"><button onclick="document.getElementById('container2').style.display = 'block'">zobrazit OHLC</button></div>
         <div id="button2" style="height: 40px; width: 150px; position: absolute; top: 10px; left: 950px;"><button onclick="document.getElementById('container2').style.display = 'none'">skryt OHLC</button></div>
        <!-- <script type="module" src="script.js"></script>
        

        -->


        <?php
            $servername = "62.141.23.238:306";
            $username = "root";
            $password = "m21519";
            $databaze = "btcbusd";

            // Create connection
            $conn = new mysqli($servername, $username, $password,$databaze);

            // Check connection
            if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
            }

            //graf 5m min pro obchody
            $sql = "SELECT `DATUM_CAS`, `VALUE` FROM `chart` where ID mod 60 = 0 order by ID DESC limit 1000";
            $result = $conn->query($sql);
            $graf = "";            
            
            if ($result->num_rows > 0) {
                while($row = $result->fetch_assoc()) {   
                    $datum_cas = explode(" ", $row["DATUM_CAS"]);
                    $datum = explode("-", $datum_cas[0]);
                    $cas = explode(":", $datum_cas[1]);
                    $mesic = $datum[1]-1;
                    $den = $datum[2];
                    $hodina = $cas[0]+2;
                    $kurz = $row["VALUE"];
                    

                    if ($graf != "") {  
                        $graf = $graf  . ",";                        
                    }
                    
                    $graf = $graf . "[Date.UTC(".$datum[0].", ".$mesic.", ".$den.", ".$hodina.", ".$cas[1].", ".$cas[2]."), ".$kurz."]";
                }
            } else {
                echo "0 results";
            }
           
           //seznam obchdu
            $sql = "SELECT `DATUM_CAS`, `BS`, `REALIZOVANY_KURZ` FROM `obchody` ORDER BY ID DESC LIMIT 30 ";
            $result = $conn->query($sql);
            $obchody = "";
            $obchody2 = "";
            $obchody3 = "";
                        
            if ($result->num_rows > 0) {
                while($row = $result->fetch_assoc()) {   
                    $datum_cas = explode(" ", $row["DATUM_CAS"]);
                    $datum = explode("-", $datum_cas[0]);
                    $cas = explode(":", $datum_cas[1]);
                    $mesic = $datum[1]-1;
                    $den = $datum[2];
                    $hodina = $cas[0]+2;
                    $kurz = $row["REALIZOVANY_KURZ"];
                    
                    if ($obchody != "") {  
                        $obchody = $obchody  . ",";                        
                    }
                    if ($row["BS"] == "BUY") {  
                        if ($obchody2 != "") {  
                            $obchody2 = $obchody2  . ",";                        
                        }
                        $obchody2 = $obchody2 . "[Date.UTC(".$datum[0].", ".$mesic.", ".$den.", ".$hodina.", ".$cas[1].", ".$cas[2]."), ".$kurz."]";                                                
                    } else {
                        if ($obchody3 != "") {  
                            $obchody3 = $obchody3  . ",";                        
                        }
                        $obchody3 = $obchody3 . "[Date.UTC(".$datum[0].", ".$mesic.", ".$den.", ".$hodina.", ".$cas[1].", ".$cas[2]."), ".$kurz."]";                       
                    }                  
                }
            } else {
                echo "0 results";
            }
            
            //pasma
            $sql = "SELECT * FROM `pasmo` WHERE ROZSAH > 20000 AND ROZSAH < 70000 ORDER BY ID DESC";
            $result = $conn->query($sql);
            $color = "red";
            $rowpredchozi = 20000;
            $barvalicha = "rgba(68, 170, 213, 0.1)";

            if ($result->num_rows > 0) {
                while($row = $result->fetch_assoc()) {      
                    if ($plotBands != "") {  
                        $plotBands = $plotBands . ",";
                    }
                    if ($row["SELL"] == "1") {                          
                        $barvalicha = "rgba(253, 208, 209, 1)";
                    }

                    $plotBands = $plotBands . "
                    { 
                        from: ".$rowpredchozi.",
                        to: ".$row["ROZSAH"].",
                        color: '".$barvalicha."',
                        label: {
                            text: '".$row["ID"]." _ ',
                            align: 'right',
                            style: {
                                color: '#606060'                                
                            }
                        }
                    }";
                    $rowpredchozi = $row["ROZSAH"];
                    if ($barvalicha == "rgba(68, 170, 213, 0.1)") { 
                        $barvalicha = "rgba(0, 0, 0, 0)";
                    } else { 
                        $barvalicha = "rgba(68, 170, 213, 0.1)";
                    }                           
                }

            } else {
                echo "0 results";
            }
            
           // echo   $plotBands;
        ?> 


        <script>
        Highcharts.chart('container', {
    chart: {
        zoomType: 'xy',
        scrollablePlotArea: {
            minWidth: 10000,
            scrollPositionX: 1
        }
    },
    title: {
        text: 'Graf obchodů'
    },
    xAxis: {
        type: 'datetime',
        labels: {
            overflow: 'justify'
        }
    },
    yAxis: {        
        minorGridLineWidth: 0,
        gridLineWidth: 0,
        alternateGridColor: null,
        plotBands: [
            <?php echo $plotBands ?>
        ]
    },
    tooltip: {
                formatter: function() {
                    return  '<b>' + this.series.name +'</b><br/>' +
                        Highcharts.dateFormat('%e.%b.%Y %H:%M:%S',
                                              new Date(this.x))
                    + '<br/>' + this.y + ' USD.';
                }                
            },
    plotOptions: {        
        scatter: {
            marker: {
                radius: 2,
                states: {
                    hover: {
                        enabled: true,
                        lineColor: 'rgb(100,100,100)'
                    }
                }
            },
            states: {
                hover: {
                    marker: {
                        enabled: false
                    }
                }
            }            
        }
    },
    series: [{
        name: 'Buy',
        color: 'red',
        type: 'scatter',
        data: [
            <?php echo $obchody2 ?>
        ]
    }, {
        name: 'Sell',
        color: 'blue',
        type: 'scatter',
        data: [
            <?php echo $obchody3 ?>
        ]
    }, {
        name: 'graf',
        color: 'gray',
        type: 'line',       
        marker: {
                enabled: false
            },
        data: [
            <?php echo $graf ?>
        ]
    }   
    

    ],
    navigation: {
        menuItemStyle: {
            fontSize: '10px'
        }
    }
});
        </script>
        


        <script>
        
          const chart = new Highcharts.stockChart('container2', {

    chart: {
      events: {
        load() {
          let chart = this;
          
          (function() {
            fetch('https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&limit=5000')
              .then(res => res.json())
              .then(data => {

                let cdata = data.map(d => {
                  return [d[0], parseFloat(d[1]), parseFloat(d[2]), parseFloat(d[3]), parseFloat(d[4])]
                  //{time:d[0]/1000,open:parseFloat(d[1]),high:parseFloat(d[2]),low:parseFloat(d[3]),close:parseFloat(d[4])}

                });
                console.log(cdata)
                chart.series[0].update({
                  data: cdata
                })

              })
          }())

        }
      }
    },
    title: {
        text: ' '
    },
    time: {
        timezoneOffset: -120
    },
    plotOptions: {
      candlestick: {
        lineColor: "#333",
        color: '#e55600',
        upColor: '#690'
      }
    },
    xAxis: [{
      crosshair: true,
      width: '100%'
    }],
    yAxis: {
      crosshair: true
    },

    navigation: {
      bindings: {
        rect: {
          annotationOptions: {
            ShapeOptions: {
              fill: 'rgba(255,0,0,0.8)'
            }

          }

        }

      },

      annotationOptions: {
        typeOptions: {
          line: {
            stroke: 'rgba(0,255,0,0.8)',
            strokeWidth: 3
          }


        }

      }
    },

    rangeSelector: {
      selected: 1
    },

    series: [{
      type: 'ohlc',
      name: "BTCUSDT",
      id: 'dataseries',
      groupPadding: 0.03,
      pointPadding: 0.03,
      _dataGrouping: {
        units: [
          [
            'week', // unit name
            [0] // allowed multiples
          ]
        ]
      }
    }]
  });

  
  
        </script>

        <?php
            
            
            $sql = "SELECT (ZISK - POPLATKY) AS ZISK FROM `Zisky`";
            $result = $conn->query($sql);

            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
                    echo "<font color='blue'>Celkový výsledek obchodování: " . $row["ZISK"]  . " USD.</font> Databáze: <a href='http://stream.schamann.net/' target='_blank'>stream.schamann.net</a><p>";
                }
            } else {
                echo "0 results";
            }     

            $sql = "SELECT * from GlobalZustaek";
            $result = $conn->query($sql);
            $iCelkemUSD = 0;
            $iCelkemBTC = 0;
            $iFreeUSD = 0;
            $iFreeBTC = 0;
            echo "<font color='blue'>";

            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
                    $iCelkemUSD = $iCelkemUSD + $row["USD_I"];
                    $iCelkemBTC = $iCelkemBTC + $row["BTC_I"];
                    $iFreeUSD = $row["USD_F"];
                    $iFreeBTC = $row["BTC_F"];
                    echo "BUSD: investovano: " . $row["USD_I"] . " volne: " . $row["USD_F"] . "
                    <p>
                    BTC: investovano: " . $row["BTC_I"] . " volne: " . $row["BTC_F"] . "
                    <p></font> <font color='red'>                     
                    ";
                }
            } else {
                echo "x results";
            }     
            $iCelkemUSD = $iCelkemUSD + $iFreeUSD;
            $iCelkemBTC = $iFreeBTC-$iCelkemBTC;
            echo "</font><b>Celkem BUSD: " .$iCelkemUSD ." Celkem BTC: " . $iCelkemBTC . "</b><p>";

            $sql = "SELECT * FROM nastaveni";
            $result = $conn->query($sql);  

        ?>
            <div style="position: absolute; top: 170px; left: 0px;  height: 375px;  width:450px;   padding:3px;     overflow: auto;">

            <table class="tg">
                <thead>
                    <tr>
                        <th class="tg-ggkl">Parametr</th><th class="tg-0lax">Hodnota</th><th class="tg-0lax">Datum čas</th>
                    </tr>
                </thead>
            <tbody>
        <?php

            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
                     if ($row["PARAMETR"] != "LISTEN_KEY") {
        ?>  
                <tr>
                    <td class="tg-0lax"><?php echo $row["PARAMETR"] ?></td><td class="tg-0lax"><?php echo $row["HODNOTA"] ?></td><td class="tg-0lax"><?php echo $row["DATUM_CAS"] ?></td>
                </tr>	
        <?php  
                     }
                }
            } else {
                echo "0 results";
            }
            echo "</tbody></table></div><p>";

            $sql = "SELECT COUNT(ID) AS POCET , DATE(DATUM_CAS) AS DATUM, ROUND(SUM(ZISK),3) AS FINAL, ROUND(SUM(POPLATEK),3) AS POPLATKY, ROUND(SUM(ZISK) / COUNT(ID), 3) AS PRUMER FROM `Vysledek`GROUP BY DATUM order by DATUM DESC";
            $result = $conn->query($sql);
            
        ?>
            <div style="position: absolute; top: 550px; left: 0px;  height: 185px;  width:450px;   padding:3px;     overflow: auto;">
            <table class="tg">
                <thead>
                    <tr>
                        <th class="tg-ggkl">Datum</th><th class="tg-0lax">Počet obchodů</th><th class="tg-0lax">Denní profit</th><th class="tg-0lax">Poplatky</th><th class="tg-0lax">Průměrný obchod</th>
                    </tr>
                </thead>
            <tbody>
            
        <?php
            //echo "ID_CLOSE ID_OPEN DATUM_CAS CLOSE FEE_CLOSE OPEN FEE_OPEN ROZDIL POPLATKY FINAL<br>";
            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
        ?>  
                <tr>
                    <td class="tg-0lax"><?php echo $row["DATUM"] ?></td><td class="tg-0lax"><?php echo $row["POCET"] ?></td><td class="tg-0lax"><?php echo $row["FINAL"] ?></td><td class="tg-0lax"><?php echo $row["POPLATKY"] ?></td><td class="tg-0lax"><?php echo $row["PRUMER"] ?></td>
                </tr>	
        <?php  
                }
            } else {
                echo "0 results";
            }
            echo "</tbody></table></div><p>";

            
   
            $sql = "SELECT * FROM `Vysledek` order by datum_cas desc";
            $result = $conn->query($sql);

        ?>
            <p>
                        <div style="position: absolute; top: 755px; left: 0px;  height: 1000px;  width:100%;   padding:3px;     overflow: auto;">

            <table class="tg" width="100%">
                <tr>
                    <td class="tg-0lax" width="40%"> Seznam uzavřených pozic<p>

                        <table class="tg" width="100%">
                            <thead>
                                <tr>
                                    <th class="tg-ggkl">Datum čas</th><th class="tg-0lax">ID</th><th class="tg-0lax">Otevřeno</th><th class="tg-0lax">Zavřeno</th><th class="tg-0lax">Poplatek</th><th class="tg-0lax">Zisk</th>
                                </tr>
                            </thead>
                        <tbody>
        <?php
            //echo "ID_CLOSE ID_OPEN DATUM_CAS CLOSE FEE_CLOSE OPEN FEE_OPEN ROZDIL POPLATKY FINAL<br>";
            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
        ?>  
                            <tr>
                                <td class="tg-0lax" width="150px"><?php echo $row["datum_cas"] ?></td><td class="tg-0lax" width="150px"><?php echo $row["id"] ?></td><td class="tg-0lax"><?php echo ROUND($row["NAKUP"],5) ?></td><td class="tg-0lax"><?php echo ROUND($row["PRODEJ"],5) ?></td><td class="tg-0lax"><?php echo ROUND($row["POPLATEK"],4) ?></td><td class="tg-0lax"><?php echo ROUND($row["ZISK"],4) ?></td>
                            </tr>	
        <?php  
      
                }
            } else {
                echo "0 results";
            }
            echo "      </tbody></table><p>";
            
            $sql = "SELECT COUNT(ID) AS POCET FROM `SezamOotevrenychPasem`";
            $result = $conn->query($sql);
            while($row = $result->fetch_assoc()) {
                echo "  </td><td class='tg-02ax' width='10%'> Seznam otevřených pásem: " . $row["POCET"];
            }
            
            $sql = "SELECT * FROM `SezamOotevrenychPasem`";
            $result = $conn->query($sql);

        ?>
            <p>
            
            <table class="tg" width="100%">
                <thead>
                    <tr>
                        <th class="tg-ggkl">ID</th><th class="tg-0lax">Rozsah</th><th class="tg-0lax">Množství</th><th class="tg-0lax">Částka</th>
                    </tr>
                </thead>
            <tbody>
        <?php
            //echo "ID_CLOSE ID_OPEN DATUM_CAS CLOSE FEE_CLOSE OPEN FEE_OPEN ROZDIL POPLATKY FINAL<br>";
            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
        ?>  
                    <tr>
                        <td class="tg-0lax"><?php echo $row["ID"] ?></td><td class="tg-0lax"><?php echo $row["ROZSAH"] ?></td><td class="tg-0lax"><?php echo $row["MNOZSTVI"] ?></td><td class="tg-0lax"><?php echo $row["CASTKA"] ?></td>
                    </tr>	
        <?php  
      
                }
            } else {
                echo "0 results";
            }
            echo "      </tbody></table><p> ";
            echo "  </td><td class='tg-02ax' width='50%'> Log: ";

            $sql = "SELECT * FROM `log` order by ID desc limit 200";
            $result = $conn->query($sql);

        ?>
            <p>
            
            <table class="tg" width="100%">
                <thead>
                    <tr>
                        <th class="tg-ggkl">Datum čas</th><th class="tg-0lax">Proces</th><th class="tg-02ax">Text</th>
                    </tr>
                </thead>
            <tbody>
        <?php
            //echo "ID_CLOSE ID_OPEN DATUM_CAS CLOSE FEE_CLOSE OPEN FEE_OPEN ROZDIL POPLATKY FINAL<br>";
            if ($result->num_rows > 0) {
                // output data of each row
                while($row = $result->fetch_assoc()) {
        ?>  
                    <tr>
                        <td class="tg-0lax" width="150px"><?php echo $row["DATUM_CAS"] ?></td><td class="tg-0lax"><?php echo $row["PROCES"] ?></td><td class="tg-02ax"><?php echo $row["TEXT"] ?></td>
                    </tr>	
        <?php  
      
                }
            } else {
                echo "0 results";
            }
            echo "      </tbody></table><p> ";

            echo "  </td><tr></table></div>";

            $conn->close();
        ?>
    </body>
</html>