sbd-npm 1.1.79 → 1.1.82

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.
Files changed (3) hide show
  1. package/menu.js +3 -2
  2. package/package.json +1 -1
  3. package/util.js +39 -2
package/menu.js CHANGED
@@ -75,6 +75,7 @@ const MenuList = [
75
75
  {'key': 'macro_pmi', 'name': '制造业采购经理指数(PMI)', 'url': '/6669696b194ae77d596371139e6b53a7'},
76
76
  {'key': 'macro_new_investor', 'name': '新增投资者', 'url': '/2268c61c6d62cdc8c1c7143aa524e2f1'},
77
77
  {'key': 'macro_gold', 'name': '黄金ETF(GLD)', 'url': '/584b9ceb0c85571831f7211903147d47'},
78
+ {'key': 'macro_crude', 'name': '原油', 'url': '/78f8b798631b52153ff029fd301f9b8a'},
78
79
  ]
79
80
  },
80
81
  {
@@ -131,8 +132,9 @@ const MenuList = [
131
132
  {'key': 'concept_bellwether', 'name': '龙头股', 'url': '/2995afdea420471e00c536182e711bef'},
132
133
  {'key': 'concept_market_situation', 'name': '市值风云', 'url': '/02fdaf4d66cdecb092bcd65f569aa493'},
133
134
  {'key': 'concept_down_top', 'name': '15-21年的超跌股', 'url': '/ae3bbf97a358392cfaa0ceb35cb3fb57'},
134
- {'key': 'concept_cannon', 'name': '黄家礼炮', 'url': '/d6128a3ad91d545f2920fa2e324c37e1'},
135
135
  {'key': 'concept_cloud', 'name': '心似白云常自在', 'url': '/1d883188398a3a8c743748c5eb81fe7b'},
136
+ {'key': 'concept_cannon', 'name': '黄家礼炮', 'url': '/d6128a3ad91d545f2920fa2e324c37e1'},
137
+ {'key': 'concept_wen', 'name': '崇文不尚武', 'url': '/b6fd64a2c54250b8ac039123e74e9b7e'},
136
138
  {'key': 'concept_niu', 'name': '老曾阿牛', 'url': '/0f4a2714971424024c1ddd8651c26569'},
137
139
  {'key': 'concept_qian', 'name': '唐史主任司马迁', 'url': '/8b3e40fe74b4870244bc51125da7675a'},
138
140
  {'key': 'concept_dan', 'name': '但斌', 'url': '/3ac0a5857b1d9a111497c0e817e647a1'},
@@ -141,7 +143,6 @@ const MenuList = [
141
143
  {'key': 'concept_us', 'name': '美股', 'url': '/f986a81550e4d8a902f8bc0ef07757a6'},
142
144
  {'key': 'concept_chip', 'name': '芯片', 'url': '/491de7096b1cb9355766e5ffdd7018b6'},
143
145
  {'key': 'concept_military', 'name': '军工', 'url': '/1eb37c30e6be05148ba47c8ca6498a48'},
144
- {'key': 'concept_hkscc', 'name': '港交所', 'url': '/f23d044c3944d827d799f77da41a911e'},
145
146
  {'key': 'concept_ah', 'name': 'AH股', 'url': '/16f12053b288726b5d4720de879c3b5c'},
146
147
  {'key': 'concept_st', 'name': 'ST股', 'url': '/e0eb8a51da63f7ceb16a769d7d20bada'},
147
148
  {'key': 'concept_ten', 'name': '十倍股', 'url': '/c08abb44c7d6ce6fa09a8a66421acb20'},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.79",
3
+ "version": "1.1.82",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
  }