sbd-npm 1.1.81 → 1.1.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.npmignore ADDED
@@ -0,0 +1 @@
1
+ sbd-npm.md
package/menu.js CHANGED
@@ -21,6 +21,7 @@ const MenuList = [
21
21
  'icon': 'th',
22
22
  'menu': [
23
23
  {'key': 'daily_price_top', 'name': '每日新高', 'url': '/947b66233a7bddda51a0ae0bb735ef3d'},
24
+ {'key': 'daily_price_up_limit', 'name': '每日涨停', 'url': '/393762e465bc20efd911d25518754caa'},
24
25
  {'key': 'daily_margin', 'name': '融资融券', 'url': '/b3c3792c371ad62f28b1eacc1d6edf31'},
25
26
  {'key': 'daily_volume', 'name': '成交量(大量)', 'url': '/5f3f29dc703951cd66f5c6320fa369ae'},
26
27
  {'key': 'daily_gap', 'name': '缺口', 'url': '/d058569e38097c2e55539d181a135552'},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.81",
3
+ "version": "1.1.84",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/summary_daily.js CHANGED
@@ -149,10 +149,12 @@ $(document).ready(function () {
149
149
  stock_rate_html.push(_pack_stock_rate("-7% ~ -5%", pr["r7_5"], "bg-green"));
150
150
  stock_rate_html.push(_pack_stock_rate("-10% ~ -7%", pr["r10_7"], "bg-green"));
151
151
  $("#stock_rate_bar").html(stock_rate_html.join(""));
152
- $("#rate_up").html(pr["r0_3"] + pr["r3_5"] + pr["r5_7"] + pr["r7_10"]);
153
- $("#rate_up_limit").html(pr["r10"]);
154
- $("#rate_down").html(pr["r10_7"] + pr["r7_5"] + pr["r5_3"] + pr["r3_0"]);
155
- $("#rate_down_limit").html(pr["r_10"]);
152
+ let up_num = pr["r0_3"] + pr["r3_5"] + pr["r5_7"] + pr["r7_10"];
153
+ let down_num = pr["r10_7"] + pr["r7_5"] + pr["r5_3"] + pr["r3_0"];
154
+ let stock_rate_tips = '涨: <b style="color: #FFF;" class="label label-danger">' + up_num + '</b> (涨停:<b><a style="text-decoration: underline;" class="text-danger" href="#" data-toggle="modal" data-target=".stock-rate-modal" data-cp="10% ~ 10%">' + pr["r10"] + '</a></b>), ';
155
+ stock_rate_tips += '跌: <b style="color: #FFF;" class="label label-success">' + down_num + '</b> (跌停:<b><a style="text-decoration: underline;" class="text-success" href="#" data-toggle="modal" data-target=".stock-rate-modal" data-cp="-10% ~ -10%">' + pr["r_10"] + '</a></b>), ';
156
+ stock_rate_tips += '涨跌比: <b style="color: #FFF;" class="label label-info">' + Util.to_float(up_num / down_num, 2) + '</b>';
157
+ $("#stock_rate_tips").html(stock_rate_tips);
156
158
  },
157
159
 
158
160
  /**
package/util.js CHANGED
@@ -764,7 +764,7 @@ const Util = {
764
764
  * 表格加载状态
765
765
  * @param element_id
766
766
  */
767
- set_table_loading: function(element_id) {
767
+ set_table_loading: function (element_id) {
768
768
  let obj = $("#" + element_id);
769
769
  let td_num = obj.parent().find('thead td').length;
770
770
  obj.html('<tr><td colspan="' + td_num + '">Loading...</td></tr>');
@@ -846,7 +846,7 @@ const Util = {
846
846
  });
847
847
  },
848
848
 
849
- render_stock_category_html: function() {
849
+ render_stock_category_html: function () {
850
850
  if (Util["stock_category_table_id"]) {
851
851
  let _html = [];
852
852
  let total_num = 0;
@@ -1888,7 +1888,17 @@ const Util = {
1888
1888
  Util.show_tips("Loading...");
1889
1889
  //获取股票详情数据
1890
1890
  Util.post("/action", {action: "code_detail", code_list: code_list.join("-")}, function (j) {
1891
+ let valid_code_list = [];
1892
+ let total_change_percent = 0;
1893
+ let total_year_change_percent = 0;
1891
1894
  $.each(j, function (code, item) {
1895
+ if (item["price"] && item["previous_price"] && item["price"] > 0 && item["previous_price"] > 0) {
1896
+ valid_code_list.push(item["code"]);
1897
+ total_change_percent += ((item["price"] - item["previous_price"]) / item["previous_price"]);
1898
+ if (item["year_price"] && item["year_price"] > 0) {
1899
+ total_year_change_percent += ((item["price"] - item["year_price"]) / item["year_price"]);
1900
+ }
1901
+ }
1892
1902
  Util.render_price(item);
1893
1903
  if (item["holder_num"] && item["holder_num"] > 0) {
1894
1904
  $(".holder_" + code).each(function () {
@@ -1927,6 +1937,33 @@ const Util = {
1927
1937
  } else {
1928
1938
  Util.refresh_index_price(element_id, index_list.join("-"), is_us, 0);
1929
1939
  }
1940
+ if (valid_code_list.length > 0) { // 涨跌统计
1941
+ if ($("#" + element_id + "_tips").length) {
1942
+ let total_num = valid_code_list.length;
1943
+ let average_change_percent = Math.round((total_change_percent / total_num) * 10000) / 100;
1944
+ let average_year_change_percent = Math.round((total_year_change_percent / total_num) * 10000) / 100;
1945
+ let week_tips_id = element_id + "week_tips";
1946
+ $("#" + element_id + "_tips").html('共 <span class="label label-info">' + total_num + '</span> 家 平均涨跌: ' + Util.parse_ratio(average_change_percent) + "<span id='" + week_tips_id + "'></span> 年初至今: " + Util.parse_ratio(average_year_change_percent));
1947
+ let code_price_dict = {};
1948
+ valid_code_list.forEach(function (code) {
1949
+ code_price_dict[code] = j[code]["price"];
1950
+ });
1951
+ Util.post("/action", {action: "code_5d_price", code_list: code_list.join("-")}, function (j) {
1952
+ let total_num = 0;
1953
+ let total_week_change_percent = 0;
1954
+ $.each(j, function (code, price_5d) {
1955
+ if (price_5d > 0 && code_price_dict[code]) {
1956
+ total_num += 1;
1957
+ total_week_change_percent += ((code_price_dict[code] - price_5d) / price_5d);
1958
+ }
1959
+ });
1960
+ if (total_num > 0) {
1961
+ let average_week_change_percent = Math.round((total_week_change_percent / total_num) * 10000) / 100;
1962
+ $("#" + week_tips_id).html(" 最近5日: " + Util.parse_ratio(average_week_change_percent));
1963
+ }
1964
+ });
1965
+ }
1966
+ }
1930
1967
  Util.hide_tips();
1931
1968
  });
1932
1969
  }