jq-test-tab.html~ 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <html>
  2. <head>
  3. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  4. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  5. <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  6. <script type="text/javascript">
  7. google.load("visualization", "1.1", {packages:["bar", 'table','gauge']});
  8. // google.load('visualization', '1', {'packages':['table']});
  9. // google.load("visualization", "1.1", {packages:["corechart"]});
  10. google.setOnLoadCallback(drawChart);
  11. function drawChart() {
  12. var data = google.visualization.arrayToDataTable([
  13. ['Strike Price', 'P', 'C', ],
  14. [166.000000,0.0,0],[170.000000,0.0,0],[180.000000,0.0,0],[184.000000,-3.0,0],[194.000000,-2.0,0],[196.000000,-2.0,0],[198.000000,-5.0,0],[202.000000,-4.0,0],[204.000000,-2.0,0],[206.000000,-1.0,0],[208.000000,-2.0,0],[210.000000,0,1.0],[210.000000,1.0,0],[212.000000,0.2,0],[214.000000,0.8,0],[218.000000,0,1.0],[222.000000,0,2.6],[224.000000,0,2.0],[230.000000,0,-2.0],[232.000000,0,0.0],[234.000000,0,-5.0],[236.000000,0,-5.0],[242.000000,0,-10.6],[246.000000,0,-4.0],[248.000000,0,-2.0],
  15. ]);
  16. var dataTbl = google.visualization.arrayToDataTable([
  17. ["symbol","right","avgcost","spotpx","pos","delta","theta","pos_delta","pos_theta","unreal_pl","last_updated"],["HSI-20151029-19600-P","P",1220.000000,10.999415,-2.000000,-0.017335,-2.626098,1.733541,262.609770,1340.058501,"20151015154159"],["HSI-20151029-17000-P","P",0.000000,0.999858,0.000000,-0.001570,-0.367255,-0.000000,-0.000000,0.000000,"20151015154159"],["MHI-20151029-21200-P","P",577.000000,38.015015,1.000000,-0.069802,-5.771672,-0.698022,-57.716718,-196.849852,"20151015154158"],["HSI-20151029-16600-P","P",0.000000,1.000131,0.000000,-0.001368,-0.401291,-0.000000,-0.000000,0.000000,"20151015154158"],["HSI-20151029-23600-C","C",3710.000000,128.000081,-5.000000,0.238123,-10.314758,-59.530862,2578.689575,-13450.020328,"20151015154158"],["MHI-20151029-22200-C","C",5337.000000,809.982506,3.000000,0.755569,-11.214440,22.667071,-336.433210,8288.475195,"20151015154159"],["MHI-20151029-24200-C","C",259.666667,30.009168,-3.000000,0.077842,-4.512433,-2.335257,135.373002,-121.275038,"20151015154159"],["HSI-20151029-23200-C","C",0.000000,245.987692,0.000000,0.384603,-12.750187,0.000000,-0.000000,0.000000,"20151015154159"],["HSI-20151029-23000-C","C",6920.000000,331.997167,-2.000000,0.468138,-13.411048,-46.813799,1341.104780,-19359.716673,"20151015154158"],["HSI-20151029-19800-P","P",2440.000000,12.999661,-5.000000,-0.021363,-2.933807,5.340751,733.451731,8950.084803,"20151015154158"],["HSI-20151029-20200-P","P",3157.500000,16.996602,-4.000000,-0.028473,-3.528713,5.694512,705.742570,9230.679501,"20151015154159"],["HSI-20151029-24800-C","C",970.000000,12.998640,-2.000000,0.033693,-2.661560,-3.369343,266.156038,640.136038,"20151015154159"],["HSI-20151029-20400-P","P",4170.000000,20.001493,-2.000000,-0.033855,-3.935196,3.385514,393.519593,6339.850713,"20151015154159"],["HSI-20151029-22200-C","C",19030.000000,844.965289,2.000000,0.762449,-11.303327,76.244913,-1130.332660,46436.528922,"20151015154158"],["HSI-20151029-20600-P","P",4020.000000,24.000015,-1.000000,-0.041617,-4.412872,2.080836,220.643579,2819.999261,"20151015154159"],["HSI-20151029-21800-C","C",26230.000000,1179.999803,1.000000,0.813468,-11.894354,40.673386,-594.717682,32769.990165,"20151015154158"],["HSI-20151029-18000-P","P",0.000000,5.002001,0.000000,-0.007135,-1.375584,-0.000000,-0.000000,0.000000,"20151015154159"],["HSI-20151029-18400-P","P",803.333333,4.000004,-3.000000,-0.005950,-1.227311,0.892491,184.096614,1809.999362,"20151015154159"],["MHI-20151029-21400-P","P",1587.000000,55.000054,4.000000,-0.099203,-7.155289,-3.968102,-286.211565,-4147.997845,"20151015154159"],["HSI-20151029-20800-P","P",1570.000000,28.000660,-2.000000,-0.048540,-4.878946,4.854034,487.894639,339.933967,"20151015154159"],["MHI-20151029-21000-P","P",7424.972471,35.011453,5.000000,-0.061412,-5.588610,-3.070591,-279.430515,-35374.289691,"20151015154158"],["HSI-20151029-24200-C","C",2210.000000,43.004258,-10.000000,0.097327,-5.864800,-48.663551,2932.399938,597.871083,"20151015154159"],["HSI-20151029-23400-C","C",7470.000000,179.981209,-5.000000,0.307659,-11.715105,-76.914625,2928.776302,-7645.302173,"20151015154159"],["MHI-20151029-22400-C","C",5781.426662,697.989984,5.000000,0.700919,-12.462483,35.045972,-623.124158,5992.365893,"20151015154159"],["HSI-20151029-24600-C","C",970.000000,19.989759,-4.000000,0.049350,-3.597504,-9.869926,719.500722,-117.951718,"20151015154158"],["MHI-20151029-21000-C","C",9023.000000,1951.987772,5.000000,0.881182,-11.919761,44.059124,-595.988068,52484.388615,"20151015154159"],["HSI-20151029-22400-C","C",22780.000000,688.991707,1.000000,0.699093,-12.395655,34.954667,-619.782736,11669.585360,"20151015154159"],["HSI-20151029-19400-P","P",895.000000,8.999886,-2.000000,-0.014173,-2.264148,1.417251,226.414831,890.011389,"20151015154158"],
  18. ]);
  19. var options = {
  20. width: 900,
  21. chart: {
  22. title: 'Option Postion Distribution. PUT:CALL Ratio [-19.00 : -22.00]',
  23. subtitle: 'for the month of 20151029, ',
  24. },
  25. };
  26. var chart = new google.charts.Bar(document.getElementById('barchart_material'));
  27. chart.draw(data, options);
  28. // chart table display implied volatilities in a nicely formatted table
  29. var chartTbl = new google.visualization.Table(document.getElementById('chartTbl_div'));
  30. //var portTbl = new google.visualization.Table(document.getElementById('portTblDiv'));
  31. var formatter = new google.visualization.NumberFormat({pattern:'0.00'});
  32. for (var i = 2; i < 9; i++)
  33. formatter.format(dataTbl, i);
  34. var options2 = {
  35. displayAnnotations: true,
  36. showRowNumber: true, width: '100%', height: '100%', allowHtml: true,
  37. };
  38. chartTbl.draw(dataTbl, options2);
  39. $('input[id="b_reload"]').click();
  40. ////////////////////////////////////////////////////////////////////////////////
  41. // guage functions
  42. var dataG = google.visualization.arrayToDataTable([
  43. ['Label', 'Value'],
  44. ['Delta', 0],
  45. ['Delta-C', 0],
  46. ['Delta-P', 0]
  47. ]);
  48. var optionsG = {
  49. width: 400, height: 120,
  50. redFrom: -50, redTo: -25,
  51. yellowFrom:-24, yellowTo: -15,
  52. greenFrom: -10, greenTo: 10,
  53. minorTicks: 5,
  54. min: -50, max: 50
  55. };
  56. var dataT = google.visualization.arrayToDataTable([
  57. ['Label', 'Value'],
  58. ['Theta', 0],
  59. ['Theta-C', 0],
  60. ['Theta-P', 0]
  61. ]);
  62. var optionsT = {
  63. width: 400, height: 120,
  64. redFrom: -3000, redTo: -2000,
  65. yellowFrom:-1999, yellowTo: 500,
  66. greenFrom: 5000, greenTo: 15000,
  67. minorTicks: 5,
  68. min: -3000, max: 15000
  69. };
  70. var gchart = new google.visualization.Gauge(document.getElementById('chart_div'));
  71. // refreshPortSummary();
  72. // gchart.draw(dataG, optionsG);
  73. var tchart = new google.visualization.Gauge(document.getElementById('chartTheta_div'));
  74. refreshPortSummary();
  75. function refreshPortSummary(){
  76. $.ajax({
  77. type: 'Post',
  78. url: '/ws_port_summary',
  79. success: function (data) {
  80. //alert(data);
  81. var jdata = JSON.parse(data);
  82. $('#temp').text(data);
  83. //alert(jdata.delta_all);
  84. dataG.setValue(0, 1, Math.round(jdata.delta_all*100)/100);
  85. dataG.setValue(1, 1, Math.round(jdata.delta_c*100)/100);
  86. dataG.setValue(2, 1, Math.round(jdata.delta_p*100)/100);
  87. gchart.draw(dataG, optionsG);
  88. dataT.setValue(0, 1, Math.round(jdata.theta_all));
  89. dataT.setValue(1, 1, Math.round(jdata.theta_c));
  90. dataT.setValue(2, 1, Math.round(jdata.theta_p));
  91. tchart.draw(dataT, optionsT);
  92. $('#pt_status').text("Unreal P/L: " + Math.round(jdata.unreal_pl*100)/100 + " Cal Status: " + jdata.status);
  93. }
  94. });
  95. };
  96. setInterval(function() {
  97. refreshPortSummary();
  98. }, 5000);
  99. } // end drawChart
  100. //})
  101. // });
  102. </script>
  103. <script>
  104. $(function() {
  105. $( "#tabs" ).tabs();
  106. });
  107. </script>
  108. </head>
  109. <body>
  110. <div id="tabs">
  111. <ul>
  112. <li><a href="#tabs-1">Nunc tincidunt</a></li>
  113. <li><a href="#tabs-2">Proin dolor</a></li>
  114. <li><a href="#tabs-3">Aenean lacinia</a></li>
  115. </ul>
  116. <div id="tabs-1">
  117. <div id='pt_status'></div>
  118. <div id="chart_div" style="width: 400px; height: 120px;"></div>
  119. <div id="chartTheta_div" style="width: 400px; height: 120px;"></div>
  120. </div>
  121. <div id="tabs-2">
  122. <div id="barchart_material" style="width: 900px; height: 500px;"></div>
  123. <div id='chartTbl_div' style='width: 900px; height: 500px;'></div>
  124. </div>
  125. <div id="tabs-3">
  126. </div>
  127. </div>
  128. </body>
  129. </html>