Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $activepage = 'index';
- include 'header.php';
- echo '<!-- BEGIN MAIN CONTAINER -->' . "\r\n" . '<div class="container pt-4">' . "\r\n" . ' <h1 class="mb-3">Traders dashboard</h1>' . "\r\n" . ' <div class="alert alert-info alert-dismissible d-none" id="intro-alert" role="alert">' . "\r\n" . ' <button type="button" id="dismiss-intro-alert" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' . "\r\n\t\t" . '<strong>Welcome to Cryptoblizz!</strong> <br/>Your personal, configurable and automated cryptocurrency trading tool. ' . "\r\n" . ' <ul class="pl-2 ml-2 mt-2 mb-2">' . "\r\n" . ' <li>Create automated traders with configurable trading strategies.</li>' . "\r\n" . ' <li>Connect to multiple exchanges and view realtime balance information accross exchanges.</li> ' . "\r\n" . ' <li>Automate and optimize traders using safeties, triggers & conditions. </li>' . "\r\n" . ' <li>Receive Telegram and / or e-mail notifications of trigger executions and trades. </li>' . "\r\n" . ' <li>Backtest and simulate your traders prior to live trading.</li>' . "\r\n" . ' <li>Like coding? Write your own trading algorithm or trigger conditions re-using our framework!</li>' . "\r\n" . ' </ul>' . "\r\n" . ' <a class="info-link mr-3" target="_blank" href="';
- echo CRYPTOBLIZZ_SITE;
- echo '/article/get-started-with-cryptoblizz-trading/">Get started with Cryptoblizz trading</a>' . "\r\n" . ' <a class="info-link" target="_blank" href="';
- echo CRYPTOBLIZZ_SITE;
- echo '/article/setup-cryptoblizz-cron-jobs/">Setup required cronjobs</a>' . "\r\n" . ' </div> ' . "\r\n" . ' ' . "\r\n" . ' ' . "\t" . '<button type="button" class="btn btn-primary btn-lg my-2" data-toggle="modal" data-target="#newTraderModal">Add an automated trader</button>' . "\r\n" . ' ' . "\t" . '<button type="button" class="btn btn-primary btn-lg ml-2 my-2" data-toggle="modal" data-target="#importTraderModal">Import a trader</button>' . "\r\n\t\r\n\t";
- $newtrader = new \Src\Trader();
- obf_DTAVKz4FJAYNPRE5EgoaJBMVKzQzMDI('newtrader', ['trader' => $newtrader]);
- echo ' ' . "\r\n" . ' ' . "\r\n" . ' ';
- $importtrader = new \Src\Trader();
- obf_DTAVKz4FJAYNPRE5EgoaJBMVKzQzMDI('importtrader');
- echo ' ' . "\r\n" . ' ' . "\r\n\t" . '<div class="row row_traders"> <!-- start row 1 -->' . "\r\n\t\t";
- $traderIdNamesMap = [];
- if ($traders = obf_DRoBNiYNMTEGHBAwDFwwLSkdOCUIKBE()) {
- foreach ($traders as $trader_resp) {
- $trader = new \Src\Trader($trader_resp['id']);
- $traderIdNamesMap[$trader->getId()] = $trader->label;
- echo ' <div class="col-sm-12 col-md-6 col-lg-3 mt-3" id="trader-con-';
- echo $trader->getId();
- echo '">' . "\r\n" . ' <div class="card traderCard" id="trader-';
- echo $trader->getId();
- echo '">' . "\r\n" . ' <div class="card-header">' . "\r\n" . ' <a href="trader.php?id=';
- echo $trader->getId();
- echo '">';
- echo $trader->label;
- echo '</a>' . "\r\n" . ' <span class="float-right">';
- if ($trader->isBacktesting()) {
- echo '<span class="text-primary">backtest</span>';
- }
- else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::CONCEPT) {
- echo '<span class="text-secondary">concept</span>';
- }
- else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::SIMULATION) {
- echo '<span class="text-primary">simulation</span>';
- }
- else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::INACTIVE) {
- echo '<span class="text-secondary">inactive</span>';
- }
- else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::LIVE) {
- echo '<span class="text-success">live</span>';
- }
- echo '</span> ' . "\r\n" . ' </div>' . "\r\n" . ' <div class="card-block p-3">' . "\r\n" . ' ';
- $platformandpair = $trader->getPlatformAndTradePair();
- $platform = $platformandpair['platform'];
- $tradepair = $platformandpair['tradepair'];
- echo isset($platform['platform']) ? '<span class="badge badge-secondary badge1em mr-2">' . $platform['platform'] . '</span>' : '';
- echo isset($tradepair['disp']) ? '<span class="badge badge-secondary badge1em">' . $tradepair['disp'] . '</span>' : '';
- if ($trader->isPaused()) {
- echo '<span class="badge badge-secondary badge1em ml-2">Paused</span>';
- }
- echo "\t\t\t\t\t\t\t\r\n" . ' <div class="trader_balance_and_profit pt-2">' . "\r\n" . ' <!-- ajax load -->' . "\r\n" . ' ' . "\t\t\t" . '<p style="text-align:center" class="col-md-12 py-4">Loading balances...</p>' . "\r\n" . ' </div>' . "\r\n" . ' ' . "\t\t\r\n" . ' ' . "\t" . '<div class="btn-group">' . "\r\n\t\t\t\t\t\t\t\t" . ' <button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-title="Actions">Actions</button>' . "\r\n\t\t\t\t\t\t\t\t" . ' ' . "\t" . '<div class="dropdown-menu px-2">' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '<a data-indropdown="true" href="trader.php?id=';
- echo $trader->getId();
- echo '" class="btn btn-outline-primary btn-block float-right">Open trader details</a> ' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '<a data-indropdown="true" title="Clone trader as concept" data-trader="';
- echo $trader->getId();
- echo '" href="" class="clone_trader btn btn-outline-primary btn-block float-right">Clone trader</a>' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '<a data-indropdown="true" data-title="Export trader settings" data-trader="';
- echo $trader->getId();
- echo '" href="" class="export_trader btn btn-outline-primary btn-block float-right">Export trader settings</a>' . "\r\n\t\t\t\t\t\t\t\t\t\t";
- if ($trader->getTraderStatus() !== \Src\Enums\TraderStatus::LIVE) {
- echo "\t\t" . ' ' . "\t\t" . '<a data-indropdown="true" title="Remove trader and data" data-toggle="confirmation" data-content="Are you sure you want to DELETE this trader? This will delete the trader, including all settings, trade history and other data associated to the trader!" data-trader="';
- echo $trader->getId();
- echo '" href="" class="remove_trader btn-block btn btn-outline-danger float-right">Delete trader and data</a>' . "\r\n\t\t" . ' ' . "\t";
- }
- echo "\t\t\t\t\t\t\t\t\t" . '</div>' . "\r\n\t\t\t\t\t\t\t\t" . '</div>' . "\r\n" . ' ' . "\t\r\n" . ' ' . "\t\r\n" . ' ' . "\t" . '<!-- messages -->' . "\r\n\t\t\t\t\t" . ' ' . "\t\t\t" . '<div class="mt-4 alert alert-warning d-none" id="trader_error-';
- echo $trader->getId();
- echo '"></div>' . "\r\n\t\t\t\t\t" . ' ' . "\t\t\t" . '<div class="mt-4 alert alert-success d-none" id="trader_success-';
- echo $trader->getId();
- echo '"></div>' . "\t\t\t\r\n" . ' </div>' . "\r\n" . ' <script type="text/javascript">' . "\r\n" . ' //every 50 seconds, refresh trader balance' . "\r\n" . ' setInterval(function(){' . "\r\n" . ' refreshBalancesByTrader(\'';
- echo $trader->getId();
- echo '\',0,true)' . "\r\n" . ' }, ' . "\r\n" . ' 55000)' . "\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t" . '$( document ).ready(function() {' . "\r\n\t\t\t\t\t\t\t\t\t" . 'refreshBalancesByTrader(\'';
- echo $trader->getId();
- echo '\',0,true);' . "\t\r\n\t\t\t\t\t\t\t\t" . '});' . "\r\n" . ' </script>' . "\t" . ' ' . "\r\n" . ' </div> ' . "\r\n" . ' </div> ' . "\r\n" . ' ';
- }
- }
- $traderIdNamesMapJson = json_encode($traderIdNamesMap);
- echo ' ' . "\t" . '</div> <!-- end row 1 -->' . "\r\n" . ' ' . "\r\n" . ' <!-- start trades block -->' . "\r\n" . ' <div class="card mt-4" style="">' . "\r\n" . ' <div class="card-header">' . "\r\n" . ' Last 50 completed orders' . "\r\n" . ' </div>' . "\r\n" . ' <div class="card-block p-3">' . "\r\n" . ' <div class="table_trades row">' . "\r\n\t\t\t" . ' ';
- $trades = obf_DTgMF1sqBiQ5DhQYEwMMFwk4EjkkAwE(50, [\Src\Enums\OrderStatus::STATUS_COMPLETED]);
- $opacity = '';
- if (obf_DSFbDTMOXB0vJgc9JAQCBRs5ChMxWxE($trades) || (count($trades) === 0)) {
- $opacity = 'opacity:0.5';
- }
- $columns = ['completed_datetime' => 'Date filled', 'trade_base_currency' => 'Pair', 'trade_buysell' => 'Buy/Sell', 'amount_exec' => 'Amount', 'rate_exec' => 'Rate', 'costreceive_quote_exec_net' => 'Cost / receive', 'trade_fee' => 'Fee', 'trader_id' => 'Trader'];
- echo '<div class="table-responsive"><table id="trade_table" style="' . $opacity . '" class="display table" cellspacing="0" width="100%"><thead class="">';
- foreach ($columns as $att => $label) {
- echo '<th>' . $label . '</th>';
- }
- echo '</thead>';
- foreach ($trades as $trade) {
- echo '<tr>';
- foreach ($columns as $att => $label) {
- switch ($att) {
- case 'completed_datetime':
- case 'created_datetime':
- case 'updated_datetime':
- echo '<td>' . obf_DS4OPycqHj8nERotMwcOBorB0AbXDI($trade[$att]) . '</td>';
- break;
- case 'rate_exec':
- case 'trade_rate':
- echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade[$att], 8) . '</td>';
- break;
- case 'amount_exec':
- case 'trade_amount':
- echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade[$att], 8) . ' ' . $trade['trade_base_currency'] . '</td>';
- break;
- case 'trade_base_currency':
- echo '<td>' . $trade[$att] . '/' . $trade['trade_quote_currency'] . '</td>';
- break;
- case 'trade_fee':
- echo '<td>';
- if (($trade['trade_fee_quotecurr'] != NULL) && ($trade['trade_fee_quotecurr'] != 0)) {
- echo obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade['trade_fee_quotecurr'], 8) . ' ' . $trade['trade_quote_currency'];
- }
- if (($trade['trade_fee_basecurr'] != NULL) && ($trade['trade_fee_basecurr'] != 0)) {
- echo obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade['trade_fee_basecurr'], 8) . ' ' . $trade['trade_base_currency'];
- }
- echo '</td>';
- break;
- case 'costreceive_quote_exec_net':
- case 'costreceive_quote_estimate':
- echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade[$att], 8) . ' ' . $trade['trade_quote_currency'] . '</td>';
- break;
- default:
- echo '<td>' . $trade[$att] . '</td>';
- break;
- }
- }
- echo '</tr>';
- }
- echo '</table></div>';
- echo ' </div>' . "\r\n" . ' </div>' . "\r\n" . ' </div>' . "\r\n" . ' <!-- end trades block -->' . "\r\n" . ' ' . "\r\n" . ' <!-- start tickers block -->' . "\r\n" . ' <div class="card mt-4" style="">' . "\r\n" . ' <div class="card-header">' . "\r\n" . ' Last 100 tickers' . "\r\n" . ' </div>' . "\r\n" . ' <div class="card-block p-3">' . "\r\n" . ' <div class="table_ticks row">' . "\r\n\t\t\t" . ' ';
- $ticks = obf_DQ4MEA8PzIBNCE9FSE2EgU0JyUzFzI(100);
- $opacity = '';
- if (obf_DSFbDTMOXB0vJgc9JAQCBRs5ChMxWxE($ticks) || (count($ticks) === 0)) {
- $opacity = 'opacity:0.5';
- }
- $columns = ['ticker_price' => 'Price', 'ticker_base' => 'Base', 'ticker_quote' => 'Quote', 'ticktimestamp' => 'Timestamp', 'platform' => 'Exchange'];
- echo '<div class="table-responsive"><table style="' . $opacity . '" id="ticker_table" class="display table" cellspacing="0" width="100%">' . "\r\n\t\t\t\t\t\t" . '<thead class="">';
- foreach ($columns as $att => $label) {
- echo '<th>' . $label . '</th>';
- }
- echo '</thead>';
- foreach ($ticks as $tick) {
- echo '<tr>';
- foreach ($columns as $att => $label) {
- if ($att == 'ticker_price') {
- echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($tick[$att], 8) . '</td>';
- }
- else {
- echo '<td>' . $tick[$att] . '</td>';
- }
- }
- echo '</tr>';
- }
- echo '</table></div>';
- echo ' </div>' . "\r\n" . ' </div>' . "\r\n" . ' </div>' . "\r\n" . ' <!-- end tickers block -->' . "\r\n" . ' ' . "\r\n" . ' <script type="text/javascript">' . "\r\n" . ' //for trades tabel, map id\'s to names' . "\r\n" . ' var traderIdNames = ';
- echo $traderIdNamesMapJson;
- echo ';' . "\r\n" . ' var create_trader_pair = -1;' . "\r\n" . ' ' . "\r\n" . ' //DATATABLE: trades' . "\r\n" . ' $(document).ready(function() {' . "\r\n" . ' $(\'#trade_table\').DataTable({' . "\r\n" . ' ' . "\t" . '"lengthMenu": [[20, 50, 100, 200], [20, 50, 100, 200]],' . "\r\n" . ' "order" : ' . "\t" . '[[ 0, "desc" ]],' . "\r\n" . ' "columnDefs": [{' . "\r\n" . ' "targets": 7,' . "\r\n" . ' "data": "trader_id",' . "\r\n" . ' "render": function ( data, type, row, meta ) {' . "\t\t\t\t\t\t\r\n" . ' return traderIdNames[data];' . "\r\n" . ' }' . "\r\n" . ' }]' . "\t\t\t\r\n" . ' });' . "\r\n" . ' $(\'#ticker_table\').DataTable({' . "\r\n" . ' "order": [[ 3, "desc" ]],' . "\r\n" . ' "lengthMenu": [[10, 25, 50, 100, 200], [10, 25, 50, 100, 200]],' . "\r\n\t\t\r\n" . ' });' . "\r\n" . ' });' . "\r\n\r\n\t" . '//clone a trader button' . "\r\n\t" . '$(".clone_trader").click(function(e) {' . "\r\n\t\t" . ' e.preventDefault();' . "\r\n\t\t" . ' var trader = $(this).data(\'trader\');' . "\r\n\t\t" . ' var $btn = $(this);' . "\r\n\t\t" . ' toggleButtonLoading($btn);' . "\r\n\t\t" . ' ' . "\r\n\t\t" . ' $.post( \'';
- echo __SITE_URL;
- echo 'ct-ajax.php\', { action: "clone_trader", trader: trader } )' . "\r\n\t" . ' .done(function( data ) {' . "\r\n\t" . ' ' . "\t" . 'var response = JSON.parse(data);' . "\r\n\t\t\t\t" . 'if(response.error) {' . "\r\n\t\t\t\t\t" . 'addFadingError("#trader_error-"+trader,response.error,3500);' . "\r\n\t\t\t\t" . '} else {' . "\r\n\t\t\t\t\t" . '//reload page for new trader' . "\r\n\t\t\t\t\t" . ' location.reload();' . "\r\n\t\t\t\t" . '}' . "\t\r\n" . ' ' . "\t\t" . ' });' . "\r\n\t\t" . ' ' . "\r\n\t" . '});' . "\r\n\r\n" . ' //remove a trader button' . "\r\n" . ' $(".remove_trader").on(\'confirmed\',function(e) {' . "\r\n" . ' e.preventDefault();' . "\r\n" . ' //if confirmed, AJAX delete trader' . "\r\n" . ' var trader = $(this).data(\'trader\');' . "\r\n" . ' $.post( \'';
- echo __SITE_URL;
- echo 'ct-ajax.php\', { action: "remove_trader", trader: trader } )' . "\r\n" . ' .done(function( data ) {' . "\r\n" . ' ' . "\t" . 'var response = JSON.parse(data);' . "\r\n\t\t\t\t" . 'if(response.error) {' . "\r\n\t\t\t\t\t" . 'addFadingError("#trader_error-"+trader,response.error,3500);' . "\r\n\t\t\t\t" . '} else {' . "\r\n\t\t\t\t\t" . '//animate removal' . "\r\n\t\t\t\t\t" . ' $("#trader-con-"+trader).fadeOut("slow",function(e) { ' . "\r\n\t\t\t\t\t\t" . ' $(this).remove();' . "\t\r\n\t\t\t\t\t" . '});' . "\r\n\t\t\t\t" . '}' . "\t\r\n" . ' });' . "\r\n" . ' });' . "\r\n" . ' ' . "\r\n" . ' ' . "\r\n" . ' //intro information text, dismissiable' . "\r\n\t" . 'dismissableAlert(\'intro\');' . "\t\r\n" . ' </script>' . "\r\n" . '</div>' . "\r\n";
- include 'footer.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement