index.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. /* @var $this \yii\web\View */
  3. use common\helpers\Utils;
  4. $mt4user = Yii::$app->getUser()->getIdentity(false)->getMt4user();
  5. $this->title = '首页';
  6. ?>
  7. <div class="row">
  8. <div class="col-md-3">
  9. <?= $this->render('/common/_left_menu.php') ?>
  10. </div>
  11. <div class="col-md-9">
  12. <div class="ibox">
  13. <div class="ibox-title">
  14. <h5>账户信息</h5>
  15. </div>
  16. <div class="ibox-content">
  17. <table class="table table-striped">
  18. <tbody>
  19. <tr>
  20. <th>账户</th>
  21. <td><?= $mt4user['LOGIN'] ?></td>
  22. <th>杠杆</th>
  23. <td>1:<?= $mt4user['LEVERAGE'] ?></td>
  24. </tr>
  25. <tr>
  26. <th>余额</th>
  27. <td><?= $mt4user['BALANCE'] ?></td>
  28. <th>保证金</th>
  29. <td><?= $mt4user['MARGIN'] ?></td>
  30. </tr>
  31. <tr>
  32. <th>可用保证金</th>
  33. <td><?= $mt4user['MARGIN_FREE'] ?></td>
  34. <th>保证金比例</th>
  35. <td><?= $mt4user['MARGIN_LEVEL'] ?></td>
  36. </tr>
  37. <tr>
  38. <th>净值</th>
  39. <td><?= $mt4user['EQUITY'] ?></td>
  40. <th>总交易次数</th>
  41. <td><?= $historyTotalCount ?></td>
  42. </tr>
  43. <!--<tr>
  44. <th>盈利交易</th>
  45. <td><?= $historyWinCount ?> (<?= Utils::formatFloatOrInt($historyWinPercent, 5) ?>%)</td>
  46. <th>亏损交易</th>
  47. <td><?= $historyLossCount ?> (<?= Utils::formatFloatOrInt($historyLossPercent, 5) ?>%)</td>
  48. </tr>-->
  49. </tbody>
  50. </table>
  51. </div>
  52. </div>
  53. <div class="row">
  54. <div class="col-md-12">
  55. <div class="ibox-title">
  56. <h5>总收益</h5>
  57. </div>
  58. <div class="ibox-content">
  59. <div class="flot-chart">
  60. <div class="flot-chart-content" id="sumProfitByDay"></div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <hr>
  66. <div class="row">
  67. <div class="col-md-12">
  68. <div class="ibox-title">
  69. <h5>交易手数</h5>
  70. </div>
  71. <div class="ibox-content">
  72. <div class="flot-chart">
  73. <div class="flot-chart-content" id="volumeSumByDay"></div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <hr>
  79. <div class="row">
  80. <div class="col-md-4">
  81. <div class="ibox-title">
  82. <h5>总笔数</h5>
  83. <span class="pull-right label label-warning"><?= $historyTotalCount ?></span>
  84. </div>
  85. <div class="ibox-content">
  86. <div class="flot-chart">
  87. <div class="flot-chart-pie-content" id="totalCount"></div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="col-md-4">
  92. <div class="ibox-title">
  93. <h5>交易货币分布</h5>
  94. </div>
  95. <div class="ibox-content">
  96. <div class="flot-chart">
  97. <div class="flot-chart-pie-content" id="symbolCount"></div>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="col-md-4">
  102. <div class="ibox-title">
  103. <h5>交易来源分布</h5>
  104. </div>
  105. <div class="ibox-content">
  106. <div class="flot-chart">
  107. <div class="flot-chart-pie-content" id="reasonCount"></div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <?php $this->beginBlock('footer_script'); ?>
  115. <!-- Flot -->
  116. <script src="<?= STATIC_URL ?>/ui/js/plugins/flot/jquery.flot.js"></script>
  117. <script src="<?= STATIC_URL ?>/ui/js/plugins/flot/jquery.flot.tooltip.min.js"></script>
  118. <script src="<?= STATIC_URL ?>/ui/js/plugins/flot/jquery.flot.resize.js"></script>
  119. <script src="<?= STATIC_URL ?>/ui/js/plugins/flot/jquery.flot.pie.js"></script>
  120. <script src="<?= STATIC_URL ?>/ui/js/plugins/flot/jquery.flot.time.js"></script>
  121. <script>
  122. $(document).ready(function () {
  123. var sumProfitByDay = <?= $sumProfitByDay ?>;
  124. $.plot($('#sumProfitByDay'), [{
  125. data: sumProfitByDay
  126. }], {
  127. xaxes: [{
  128. mode: 'time',
  129. timeformat: '%y/%m/%d'
  130. }],
  131. colors: ['#1ab394'],
  132. grid: {
  133. color: '#999999',
  134. hoverable: true,
  135. clickable: true,
  136. tickColor: '#D4D4D4',
  137. borderWidth: 0,
  138. hoverable: true //IMPORTANT! this is needed for tooltip to work,
  139. },
  140. tooltip: true,
  141. tooltipOpts: {
  142. content: '截止 %x 的总收益 %y ',
  143. xDateFormat: '%y/%m/%d',
  144. onHover: function (flotItem, $tooltipEl) {
  145. // console.log(flotItem, $tooltipEl);
  146. }
  147. }
  148. })
  149. var volumeSumByDay = <?= $volumeSumByDay ?>;
  150. $.plot($('#volumeSumByDay'), [{
  151. data: volumeSumByDay
  152. }], {
  153. xaxes: [{
  154. mode: 'time',
  155. timeformat: '%y/%m/%d'
  156. }],
  157. yaxis: {
  158. tickDecimals: 2
  159. },
  160. colors: ['#1ab394'],
  161. grid: {
  162. color: '#999999',
  163. hoverable: true,
  164. clickable: true,
  165. tickColor: '#D4D4D4',
  166. borderWidth: 0,
  167. hoverable: true //IMPORTANT! this is needed for tooltip to work,
  168. },
  169. tooltip: true,
  170. tooltipOpts: {
  171. content: '截止 %x 的总交易手数 %y 手',
  172. xDateFormat: '%y/%m/%d',
  173. onHover: function (flotItem, $tooltipEl) {
  174. // console.log(flotItem, $tooltipEl);
  175. }
  176. }
  177. })
  178. var data1 = <?= $symbolCount ?>;
  179. if (!$.isEmptyObject(data1)) {
  180. var plotObj1 = $.plot($('#symbolCount'), data1, {
  181. series: {
  182. pie: {
  183. show: true
  184. }
  185. },
  186. grid: {
  187. hoverable: true
  188. },
  189. tooltip: true,
  190. tooltipOpts: {
  191. content: '%p.0%, %s', // show percentages, rounding to 2 decimal places
  192. shifts: {
  193. x: 20,
  194. y: 0
  195. },
  196. defaultTheme: false
  197. }
  198. })
  199. }
  200. var data2 = <?= $reasonCount ?>;
  201. if (!$.isEmptyObject(data2)) {
  202. var plotObj2 = $.plot($('#reasonCount'), data2, {
  203. series: {
  204. pie: {
  205. show: true
  206. }
  207. },
  208. grid: {
  209. hoverable: true
  210. },
  211. tooltip: true,
  212. tooltipOpts: {
  213. content: '%p.0%, %s', // show percentages, rounding to 2 decimal places
  214. shifts: {
  215. x: 20,
  216. y: 0
  217. },
  218. defaultTheme: false
  219. }
  220. })
  221. }
  222. var data3 = [
  223. {
  224. label: 'Win',
  225. data: <?= $historyWinCount ?>,
  226. },
  227. {
  228. label: 'Loss',
  229. data: <?= $historyLossCount ?>,
  230. }
  231. ]
  232. var plotObj3 = $.plot($('#totalCount'), data3, {
  233. series: {
  234. pie: {
  235. show: true
  236. }
  237. },
  238. grid: {
  239. hoverable: true
  240. },
  241. tooltip: true,
  242. tooltipOpts: {
  243. content: '%p.0%, %s', // show percentages, rounding to 2 decimal places
  244. shifts: {
  245. x: 20,
  246. y: 0
  247. },
  248. defaultTheme: false
  249. }
  250. })
  251. })
  252. </script>
  253. <?php $this->endBlock(); ?>