Advertisement
Guest User

Untitled

a guest
Jan 10th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.26 KB | None | 0 0
  1. <?php
  2.  
  3. $activepage = 'index';
  4. include 'header.php';
  5. 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">&times;</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="';
  6. echo CRYPTOBLIZZ_SITE;
  7. echo '/article/get-started-with-cryptoblizz-trading/">Get started with Cryptoblizz trading</a>' . "\r\n" . ' <a class="info-link" target="_blank" href="';
  8. echo CRYPTOBLIZZ_SITE;
  9. 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";
  10. $newtrader = new \Src\Trader();
  11. obf_DTAVKz4FJAYNPRE5EgoaJBMVKzQzMDI('newtrader', ['trader' => $newtrader]);
  12. echo ' ' . "\r\n" . ' ' . "\r\n" . ' ';
  13. $importtrader = new \Src\Trader();
  14. obf_DTAVKz4FJAYNPRE5EgoaJBMVKzQzMDI('importtrader');
  15. echo ' ' . "\r\n" . ' ' . "\r\n\t" . '<div class="row row_traders"> <!-- start row 1 -->' . "\r\n\t\t";
  16. $traderIdNamesMap = [];
  17.  
  18. if ($traders = obf_DRoBNiYNMTEGHBAwDFwwLSkdOCUIKBE()) {
  19. foreach ($traders as $trader_resp) {
  20. $trader = new \Src\Trader($trader_resp['id']);
  21. $traderIdNamesMap[$trader->getId()] = $trader->label;
  22. echo ' <div class="col-sm-12 col-md-6 col-lg-3 mt-3" id="trader-con-';
  23. echo $trader->getId();
  24. echo '">' . "\r\n" . ' <div class="card traderCard" id="trader-';
  25. echo $trader->getId();
  26. echo '">' . "\r\n" . ' <div class="card-header">' . "\r\n" . ' <a href="trader.php?id=';
  27. echo $trader->getId();
  28. echo '">';
  29. echo $trader->label;
  30. echo '</a>' . "\r\n" . ' <span class="float-right">';
  31.  
  32. if ($trader->isBacktesting()) {
  33. echo '<span class="text-primary">backtest</span>';
  34. }
  35. else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::CONCEPT) {
  36. echo '<span class="text-secondary">concept</span>';
  37. }
  38. else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::SIMULATION) {
  39. echo '<span class="text-primary">simulation</span>';
  40. }
  41. else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::INACTIVE) {
  42. echo '<span class="text-secondary">inactive</span>';
  43. }
  44. else if ($trader->getTraderStatus() == \Src\Enums\TraderStatus::LIVE) {
  45. echo '<span class="text-success">live</span>';
  46. }
  47.  
  48. echo '</span> ' . "\r\n" . ' </div>' . "\r\n" . ' <div class="card-block p-3">' . "\r\n" . ' ';
  49. $platformandpair = $trader->getPlatformAndTradePair();
  50. $platform = $platformandpair['platform'];
  51. $tradepair = $platformandpair['tradepair'];
  52. echo isset($platform['platform']) ? '<span class="badge badge-secondary badge1em mr-2">' . $platform['platform'] . '</span>' : '';
  53. echo isset($tradepair['disp']) ? '<span class="badge badge-secondary badge1em">' . $tradepair['disp'] . '</span>' : '';
  54.  
  55. if ($trader->isPaused()) {
  56. echo '<span class="badge badge-secondary badge1em ml-2">Paused</span>';
  57. }
  58.  
  59. 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=';
  60. echo $trader->getId();
  61. 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="';
  62. echo $trader->getId();
  63. 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="';
  64. echo $trader->getId();
  65. 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";
  66.  
  67. if ($trader->getTraderStatus() !== \Src\Enums\TraderStatus::LIVE) {
  68. 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="';
  69. echo $trader->getId();
  70. echo '" href="" class="remove_trader btn-block btn btn-outline-danger float-right">Delete trader and data</a>' . "\r\n\t\t" . ' ' . "\t";
  71. }
  72.  
  73. 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-';
  74. echo $trader->getId();
  75. echo '"></div>' . "\r\n\t\t\t\t\t" . ' ' . "\t\t\t" . '<div class="mt-4 alert alert-success d-none" id="trader_success-';
  76. echo $trader->getId();
  77. 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(\'';
  78. echo $trader->getId();
  79. 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(\'';
  80. echo $trader->getId();
  81. 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" . ' ';
  82. }
  83. }
  84.  
  85. $traderIdNamesMapJson = json_encode($traderIdNamesMap);
  86. 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" . ' ';
  87. $trades = obf_DTgMF1sqBiQ5DhQYEwMMFwk4EjkkAwE(50, [\Src\Enums\OrderStatus::STATUS_COMPLETED]);
  88. $opacity = '';
  89. if (obf_DSFbDTMOXB0vJgc9JAQCBRs5ChMxWxE($trades) || (count($trades) === 0)) {
  90. $opacity = 'opacity:0.5';
  91. }
  92.  
  93. $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'];
  94. echo '<div class="table-responsive"><table id="trade_table" style="' . $opacity . '" class="display table" cellspacing="0" width="100%"><thead class="">';
  95.  
  96. foreach ($columns as $att => $label) {
  97. echo '<th>' . $label . '</th>';
  98. }
  99.  
  100. echo '</thead>';
  101.  
  102. foreach ($trades as $trade) {
  103. echo '<tr>';
  104.  
  105. foreach ($columns as $att => $label) {
  106. switch ($att) {
  107. case 'completed_datetime':
  108. case 'created_datetime':
  109. case 'updated_datetime':
  110. echo '<td>' . obf_DS4OPycqHj8nERotMwcOBorB0AbXDI($trade[$att]) . '</td>';
  111. break;
  112. case 'rate_exec':
  113. case 'trade_rate':
  114. echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade[$att], 8) . '</td>';
  115. break;
  116. case 'amount_exec':
  117. case 'trade_amount':
  118. echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade[$att], 8) . ' ' . $trade['trade_base_currency'] . '</td>';
  119. break;
  120. case 'trade_base_currency':
  121. echo '<td>' . $trade[$att] . '/' . $trade['trade_quote_currency'] . '</td>';
  122. break;
  123. case 'trade_fee':
  124. echo '<td>';
  125. if (($trade['trade_fee_quotecurr'] != NULL) && ($trade['trade_fee_quotecurr'] != 0)) {
  126. echo obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade['trade_fee_quotecurr'], 8) . ' ' . $trade['trade_quote_currency'];
  127. }
  128. if (($trade['trade_fee_basecurr'] != NULL) && ($trade['trade_fee_basecurr'] != 0)) {
  129. echo obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade['trade_fee_basecurr'], 8) . ' ' . $trade['trade_base_currency'];
  130. }
  131.  
  132. echo '</td>';
  133. break;
  134. case 'costreceive_quote_exec_net':
  135. case 'costreceive_quote_estimate':
  136. echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($trade[$att], 8) . ' ' . $trade['trade_quote_currency'] . '</td>';
  137. break;
  138. default:
  139. echo '<td>' . $trade[$att] . '</td>';
  140. break;
  141. }
  142. }
  143.  
  144. echo '</tr>';
  145. }
  146.  
  147. echo '</table></div>';
  148. 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" . ' ';
  149. $ticks = obf_DQ4MEA8PzIBNCE9FSE2EgU0JyUzFzI(100);
  150. $opacity = '';
  151. if (obf_DSFbDTMOXB0vJgc9JAQCBRs5ChMxWxE($ticks) || (count($ticks) === 0)) {
  152. $opacity = 'opacity:0.5';
  153. }
  154.  
  155. $columns = ['ticker_price' => 'Price', 'ticker_base' => 'Base', 'ticker_quote' => 'Quote', 'ticktimestamp' => 'Timestamp', 'platform' => 'Exchange'];
  156. 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="">';
  157.  
  158. foreach ($columns as $att => $label) {
  159. echo '<th>' . $label . '</th>';
  160. }
  161.  
  162. echo '</thead>';
  163.  
  164. foreach ($ticks as $tick) {
  165. echo '<tr>';
  166.  
  167. foreach ($columns as $att => $label) {
  168. if ($att == 'ticker_price') {
  169. echo '<td>' . obf_DT0MDwJcGDYkBx45OAZbFSEbGxghMiI($tick[$att], 8) . '</td>';
  170. }
  171. else {
  172. echo '<td>' . $tick[$att] . '</td>';
  173. }
  174. }
  175.  
  176. echo '</tr>';
  177. }
  178.  
  179. echo '</table></div>';
  180. 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 = ';
  181. echo $traderIdNamesMapJson;
  182. 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( \'';
  183. echo __SITE_URL;
  184. 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( \'';
  185. echo __SITE_URL;
  186. 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";
  187. include 'footer.php';
  188.  
  189. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement