sbd-npm 1.1.86 → 1.1.89

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 (2) hide show
  1. package/package.json +1 -1
  2. package/util.js +25 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.86",
3
+ "version": "1.1.89",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -865,7 +865,7 @@ const Util = {
865
865
  _html = Util.stock_basics_html(_html, item);
866
866
  _html.push("<td id='high_", item["code"], "'>0</td>");
867
867
  _html.push("<td id='low_", item["code"], "'>0</td>");
868
- _html.push("<td data-val='", item["year_price"], "' class='year_price_", item["code"], "'>--</td>");
868
+ _html.push("<td class='year_price_", item["code"], "'>", (item["stock_price"] ? Util.year_price_rate(item["stock_price"], item["year_price"]) : "--"), "</td>");
869
869
  _html.push("<td class='high_52week_", item["code"], "'>--</td>");
870
870
  if (is_us === 0) {
871
871
  _html.push("<td id='amount_", item["code"], "'>--</td>");
@@ -1000,7 +1000,7 @@ const Util = {
1000
1000
  _html.push("<tr class='" + component_tr + "'>");
1001
1001
  _html.push("<td>", index + 1, "</td>");
1002
1002
  _html = Util.stock_basics_html(_html, item);
1003
- _html.push("<td data-val='", item["year_price"], "' class='year_price_", item["code"], "'>--</td>");
1003
+ _html.push("<td class='year_price_", item["code"], "'>", (item["stock_price"] ? Util.year_price_rate(item["stock_price"], item["year_price"]) : "--"), "</td>");
1004
1004
  let stock_num_tips = "";
1005
1005
  if (item["stock_num"] > 0 && item["pre_stock_num"] > 0) {
1006
1006
  let gap_stock_num = item["stock_num"] - item["pre_stock_num"];
@@ -1940,9 +1940,9 @@ const Util = {
1940
1940
  } else {
1941
1941
  Util.refresh_index_price(element_id, index_list.join("-"), is_us, 0);
1942
1942
  }
1943
- if (valid_code_list.length > 0) { // 涨跌统计
1943
+ let total_num = valid_code_list.length;
1944
+ if (total_num > 0 && total_num < 100) { // 涨跌统计
1944
1945
  if ($("#" + element_id + "_tips").length) {
1945
- let total_num = valid_code_list.length;
1946
1946
  let average_change_percent = Math.round((total_change_percent / total_num) * 10000) / 100;
1947
1947
  let average_year_change_percent = Math.round((total_year_change_percent / total_num) * 10000) / 100;
1948
1948
  let week_tips_id = element_id + "week_tips";
@@ -1951,13 +1951,16 @@ const Util = {
1951
1951
  valid_code_list.forEach(function (code) {
1952
1952
  code_price_dict[code] = j[code]["price"];
1953
1953
  });
1954
- Util.post("/action", {action: "code_5d_price", code_list: code_list.join("-")}, function (j) {
1954
+ Util.post("/action", {action: "code_d5_price", code_list: code_list.join("-")}, function (j) {
1955
1955
  let total_num = 0;
1956
1956
  let total_week_change_percent = 0;
1957
- $.each(j, function (code, price_5d) {
1958
- if (price_5d > 0 && code_price_dict[code]) {
1957
+ $.each(j, function (code, d5_price) {
1958
+ if (d5_price > 0 && code_price_dict[code]) {
1959
1959
  total_num += 1;
1960
- total_week_change_percent += ((code_price_dict[code] - price_5d) / price_5d);
1960
+ total_week_change_percent += ((code_price_dict[code] - d5_price) / d5_price);
1961
+ $(".d5_price_" + code).each(function () {
1962
+ $(this).html(Util.year_price_rate(code_price_dict[code], d5_price));
1963
+ });
1961
1964
  }
1962
1965
  });
1963
1966
  if (total_num > 0) {
@@ -2445,6 +2448,16 @@ const Util = {
2445
2448
  return Util.to_float(digit / 100000000, fraction);
2446
2449
  },
2447
2450
 
2451
+ /**
2452
+ * 转为以万为单位的数值
2453
+ * @param digit
2454
+ * @param fraction
2455
+ * @returns {*|number}
2456
+ */
2457
+ to_ten_thousand: function (digit, fraction = 2) {
2458
+ return Util.to_float(digit / 10000, fraction);
2459
+ },
2460
+
2448
2461
  /**
2449
2462
  * 转为相应单位的数值
2450
2463
  * @param digit
@@ -3108,12 +3121,12 @@ const Util = {
3108
3121
 
3109
3122
  /**
3110
3123
  * 大单交易
3111
- * @param obj_id
3124
+ * @param element_id
3112
3125
  */
3113
- big_deal_pie: function (obj_id, data) {
3126
+ big_deal_pie: function (element_id, data) {
3114
3127
  let buy = Util.to_unit(data["buy1000"] + data["buy800"] + data["buy600"] + data["buy400"]);
3115
3128
  let sell = Util.to_unit(data["sell1000"] + data["sell800"] + data["sell600"] + data["sell400"]);
3116
- $("#" + obj_id + "_tips").html("流入: <b class='text-danger'>" + buy + "</b>,流出: <b class='text-success'>" + sell + "</b>");
3129
+ $("#" + element_id + "_tips").html("流入: <b class='text-danger'>" + Util.strip_html(buy) + "</b>,流出: <b class='text-success'>" + Util.strip_html(sell) + "</b>");
3117
3130
  let bd_data = [
3118
3131
  {name: '超大单流入', value: Util.to_hundred_million(data["buy1000"])},
3119
3132
  {name: '大单流入', value: Util.to_hundred_million(data["buy800"])},
@@ -3124,7 +3137,7 @@ const Util = {
3124
3137
  {name: '大单流出', value: Util.to_hundred_million(data["sell800"])},
3125
3138
  {name: '超大单流出', value: Util.to_hundred_million(data["sell1000"])}
3126
3139
  ];
3127
- let BigDealPie = echarts.init(document.getElementById(obj_id), {});
3140
+ let BigDealPie = echarts.init(document.getElementById(element_id), {});
3128
3141
  BigDealPie.setOption({
3129
3142
  tooltip: {
3130
3143
  trigger: 'item',