sbd-npm 1.3.4 → 1.3.6

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/constant.js CHANGED
@@ -180,6 +180,7 @@ const MenuList = [
180
180
  {'key': 'hk_hsm100', 'name': '恒生中国100指数', 'url': '/0x759fcb84a0a322125df6748dffad66d7b2b44c2d'},
181
181
  {'key': 'hk_biotechnology', 'name': '生物科技', 'url': '/0xa131be85db2beb939e93207d0966c3710c7b761a'},
182
182
  {'key': 'hk_sell_short', 'name': '沽空排行', 'url': '/0x4ecddc987891875a42d206620cd97ca382613485'},
183
+ {'key': 'hk_stock_exchange', 'name': '港股通持股排行', 'url': '/0x7549960a2de98a41a1b78e63202003a175b93dbb'},
183
184
  ]
184
185
  },
185
186
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -951,7 +951,7 @@ let Stock = {
951
951
  Stock["pfc_stock_chart"] = Util.multi_axis_line(Stock["pfc_stock_chart"], "pfc_stock_line_canvas", date_data, '总持股数(万股)', stock_num_data, '股价', price_data);
952
952
  Stock["pfc_fund_chart"] = Util.multi_axis_line(Stock["pfc_fund_chart"], "pfc_fund_line_canvas", date_data, '持仓家数', fund_num_data, '股价', price_data);
953
953
  if (j["cur_stock_num"] && j["cur_stock_num"] > 0 && j["pre_stock_num"] && j["pre_stock_num"] > 0) {
954
- $("#pfc_stock_tips").html("(当前持股数: <b class='text-info'>" + Util.to_unit(j["cur_stock_num"] * 10000, 3) + "</b>, 环比: " + Util.year_price_rate(j["cur_stock_num"], j["pre_stock_num"]) + ")");
954
+ $("#pfc_stock_tips").html("(当前持股数: <b class='text-info'>" + Util.to_unit(j["cur_stock_num"] * 10000, 4) + "</b>, 环比: " + Util.year_price_rate(j["cur_stock_num"], j["pre_stock_num"]) + ")");
955
955
  }
956
956
  if (j["cur_fund_num"] && j["cur_fund_num"] > 0 && j["pre_fund_num"] && j["pre_fund_num"] > 0) {
957
957
  $("#pfc_fund_tips").html("(当前基金数: <b class='text-info'>" + Util.to_unit(j["cur_fund_num"]) + "</b>, 环比: " + Util.year_price_rate(j["cur_fund_num"], j["pre_fund_num"]) + ")");
@@ -1094,11 +1094,8 @@ let Stock = {
1094
1094
  },
1095
1095
 
1096
1096
  fetch_margin: function () {
1097
+ let is_summary = Stock["rzye_chart"] ? 0 : 1;
1097
1098
  Stock["rzye_chart"] = Util.show_chart_loading(Stock["rzye_chart"], "rzye_line_canvas");
1098
- let is_summary = 0;
1099
- if (!Stock.rzye_chart) {
1100
- is_summary = 1;
1101
- }
1102
1099
  let payload = {
1103
1100
  action: "margin",
1104
1101
  is_summary: is_summary,
@@ -1115,39 +1112,38 @@ let Stock = {
1115
1112
  }
1116
1113
  rzye_high = Math.max(rzye_high, item["rzye"]);
1117
1114
  date_data.push(Util.seconds_to_format(item["date"], "%Y-%m-%d"));
1118
- rzye_data.push(Util.to_hundred_million(item["rzye"]));
1115
+ rzye_data.push(Util.to_hundred_million(item["rzye"], 3));
1119
1116
  rqye_data.push(Util.to_float(item["rqye"] / 10000, 2));
1120
1117
  price_data.push(item["price"]);
1121
1118
  });
1122
1119
  let margin_summary = "";
1123
- if (!Stock.rzye_chart && j["latest"].length > 0) {
1120
+ if (is_summary === 1 && j["latest"].length > 0) {
1124
1121
  if (j["latest"].length === 1) {
1125
- margin_summary = "最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): " + Util.to_unit(j["latest"][0]["rzye"]);
1122
+ margin_summary = " 最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): " + Util.to_unit(j["latest"][0]["rzye"], 3);
1126
1123
  } else if (j["latest"].length === 2) {
1127
1124
  let d1 = j["latest"][0];
1128
1125
  let d2 = j["latest"][1];
1129
1126
  let difference = d1["rzye"] - d2["rzye"];
1130
1127
  let dist_tips = "";
1131
1128
  if (difference > 0) {
1132
- dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["rzye"])) + "' style='color: #a94442;'>+" + Util.strip_html(Util.to_unit(difference)) + "</b>)";
1129
+ dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["rzye"], 3)) + "' style='color: #a94442;'>+" + Util.strip_html(Util.to_unit(difference, 3)) + "</b>)";
1133
1130
  } else if (difference < 0) {
1134
- dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["rzye"])) + "' style='color: #3c763d;'>" + Util.strip_html(Util.to_unit(difference)) + "</b>)";
1131
+ dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["rzye"], 3)) + "' style='color: #3c763d;'>" + Util.strip_html(Util.to_unit(difference, 3)) + "</b>)";
1135
1132
  }
1136
- margin_summary = "最新(" + Util.seconds_to_format(d1["date"], "%Y-%m-%d") + "): " + Util.to_unit(d1["rzye"]) + dist_tips;
1133
+ margin_summary = " 最新(" + Util.seconds_to_format(d1["date"], "%Y-%m-%d") + "): " + Util.to_unit(d1["rzye"], 3) + dist_tips;
1137
1134
  }
1138
1135
  }
1139
- margin_summary = '[' + Util.pack_html_link(j["url"], Stock.name) + ']融资余额(单位:亿)' + margin_summary + ' 最高: ' + Util.to_unit(rzye_high) + ' 最低: ' + Util.to_unit(rzye_low);
1136
+ margin_summary = Util.pack_html_link(j["url"], "[" + Stock.name + "融资余额(单位:亿)]") + margin_summary + ' 最高: ' + Util.to_unit(rzye_high, 3) + ' 最低: ' + Util.to_unit(rzye_low, 3);
1140
1137
  if (j["high"] && j["high"]["date"] && j["high"]["date"] > 0) {
1141
- margin_summary += ' 历史最高: ' + Util.to_unit(j["high"]["rzye"]) + '(' + Util.seconds_to_format(j["high"]["date"], "%Y-%m-%d") + ')';
1138
+ margin_summary += ' 历史最高: ' + Util.to_unit(j["high"]["rzye"], 3) + '(' + Util.seconds_to_format(j["high"]["date"], "%Y-%m-%d") + ')';
1142
1139
  }
1143
1140
  if (j["low"] && j["low"]["date"] && j["low"]["date"] > 0) {
1144
- margin_summary += ' 历史最低: ' + Util.to_unit(j["low"]["rzye"]) + '(' + Util.seconds_to_format(j["low"]["date"], "%Y-%m-%d") + ')';
1141
+ margin_summary += ' 历史最低: ' + Util.to_unit(j["low"]["rzye"], 3) + '(' + Util.seconds_to_format(j["low"]["date"], "%Y-%m-%d") + ')';
1145
1142
  }
1146
1143
  $("#margin_summary").html(margin_summary);
1147
1144
  Stock["rzye_chart"] = Util.multi_axis_line(Stock["rzye_chart"], "rzye_line_canvas", date_data, '融资余额', rzye_data, '股价', price_data);
1148
- let flow_data = [];
1145
+ let flow_data = [], color_data = [];
1149
1146
  date_data = [];
1150
- let color_data = [];
1151
1147
  j["flow_data"].forEach(function (item) {
1152
1148
  if (item["value"] !== 0) {
1153
1149
  date_data.push(item["date"]);
@@ -1188,7 +1184,7 @@ let Stock = {
1188
1184
  let circulation_stock = $("#circulation_stock").attr("data-val");
1189
1185
  let latest_html = "";
1190
1186
  if (j["latest"].length === 1) {
1191
- let holding_num = Util.to_hundred_million(j["latest"][0]["volume"]);
1187
+ let holding_num = Util.to_hundred_million(j["latest"][0]["volume"], 3);
1192
1188
  let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1193
1189
  latest_html = "最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): " + holding_num + "亿股, 占 <b>" + holding_rate + "%</b> 流通股, ";
1194
1190
  } else if (j["latest"].length === 2) {
package/util.js CHANGED
@@ -27,6 +27,7 @@ const Util = {
27
27
  interval_timer: null,
28
28
  stock_timer_id: 0,
29
29
  is_init: 0,
30
+ is_load: 0,
30
31
  // 1年的天数
31
32
  one_year_day: 365,
32
33
  // 一天的秒数
@@ -470,22 +471,19 @@ const Util = {
470
471
  * 港股股票的基础HTML
471
472
  * @param html
472
473
  * @param item
473
- * @param exchange_rate
474
474
  * @returns {*}
475
475
  */
476
- stock_hk_html: function (html, item, exchange_rate) {
477
- let market_capital_hkd = Util.to_float(item["market_capital"], 2);
478
- let market_capital_cny = Util.to_float((item["market_capital"] * exchange_rate) / 100, 2);
476
+ stock_hk_html: function (html, item) {
479
477
  html.push("<td>", Util.snowball_url(item["code"]), "</td>");
480
478
  html.push("<td>", Util.stock_url(item["code"], item["name"]), "</td>");
481
479
  html.push("<td class='hk_industry'>", item["industry"], "</td>");
482
480
  html.push("<td>", Util.map_url(item["province_city"]), "</td>");
483
481
  html.push("<td>", Util.to_float((item["pe_ttm"] ? item["pe_ttm"] : item["pe"]), 2), "</td>");
484
482
  html.push("<td>", Util.to_float(item["total_shares"], 2), "亿</td>");
485
- html.push("<td>", market_capital_hkd, "亿(", market_capital_cny, "亿)</td>");
486
- html.push("<td>", item["chairman"], "</td>");
483
+ html.push("<td>", Util.to_float(item["market_capital"], 3), "亿</td>");
487
484
  html.push("<td class='price_", item["code"], "'>", item["price"], "</td>");
488
485
  html.push("<td>", Util.year_price_rate(item["price"], item["year_price"]), "</td>");
486
+ html.push("<td>", Util.year_price_rate(item["price"], item["d5_price"]), "</td>");
489
487
  html.push("<td>", Util.digit_compare_trend(item["high_52week"], item["price"]), "</td>");
490
488
  html.push("<td>", Util.digit_compare_trend(item["low_52week"], item["price"]), "</td>");
491
489
  return html;