sbd-npm 1.2.97 → 1.2.99

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 +95 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.97",
3
+ "version": "1.2.99",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -570,6 +570,16 @@ const Util = {
570
570
  return Util.is_us(code) ? "US" : (Util.is_hk(code) ? "HK" : (Util.is_sh(code) ? "SH" : "SZ"));
571
571
  },
572
572
 
573
+ /**
574
+ * 基金前缀
575
+ * @param code
576
+ * @returns {string}
577
+ */
578
+ code_to_fund_symbol: function(code) {
579
+ let prefix = code.substr(0, 1) === "5" ? "SH": "SZ";
580
+ return prefix + code;
581
+ },
582
+
573
583
  /**
574
584
  * 是否交易时间
575
585
  * @returns {boolean}
@@ -993,7 +1003,7 @@ const Util = {
993
1003
  }
994
1004
  let table_options = {
995
1005
  "element_id": table_id,
996
- "caption": '<caption><span id="index_data"></span><div class="pull-right" id="' + table_id + '_body_tips"></div></caption>',
1006
+ "caption": '<caption><a href="#"><i class="glyphicon glyphicon-cog" style="color: #bdbdbd;"></i></a> <span id="index_data"></span><div class="pull-right" id="' + table_id + '_body_tips"></div></caption>',
997
1007
  "head_cols": head_cols
998
1008
  };
999
1009
  if (alert_tips.length > 0) {
@@ -1003,6 +1013,7 @@ const Util = {
1003
1013
  Util["stock_category_table_id"] = table_id;
1004
1014
  Util.post(location.pathname, {active_div: stock_category}, function (j) {
1005
1015
  Util["stock_category_data"] = j["data"];
1016
+ Util["stock_category_index"] = j["index_list"] ? j["index_list"] : [];
1006
1017
  Util.render_type_option($("#stock_category_industry"), j["data"], "industry", Util.render_stock_category_html);
1007
1018
  Util.render_type_option($("#stock_category_area"), j["data"], "area", Util.render_stock_category_html);
1008
1019
  Util.render_stock_category_html();
@@ -1010,9 +1021,6 @@ const Util = {
1010
1021
  $("#stock_category_remark_title").html(Util.pack_html_link(j["concept_url"], "备注<i class='glyphicon glyphicon-link'></i>"));
1011
1022
  }
1012
1023
  Util.hide_tips();
1013
- let index_list = j["index_list"] ? j["index_list"] : [];
1014
- let is_us = stock_category === "us" ? 1 : 0;
1015
- Util.init_stock_stuff(table_id + "_body", index_list, is_us);
1016
1024
  });
1017
1025
  },
1018
1026
 
@@ -1048,13 +1056,16 @@ const Util = {
1048
1056
  }
1049
1057
  });
1050
1058
  }
1051
- Util.render_table_html(Util["stock_category_table_id"] + "_body", _html);
1059
+ let table_body_id = Util["stock_category_table_id"] + "_body";
1060
+ Util.render_table_html(table_body_id, _html);
1052
1061
  if (is_us === 1) {
1053
1062
  $("img").on("error", function () {
1054
1063
  $(this).attr("src", "https://storage.googleapis.com/iex/api/logos/LI.png");
1055
1064
  });
1056
1065
  }
1057
- $("#" + Util["stock_category_table_id"] + "_body_tips").html('共 <span class="label label-info">' + total_num + '</span> 家');
1066
+ $("#" + table_body_id + "_tips").html('共 <span class="label label-info">' + total_num + '</span> 家');
1067
+ let index_list = Util["stock_category_index"] ? Util["stock_category_index"] : [];
1068
+ Util.init_stock_stuff(table_body_id, index_list, is_us);
1058
1069
  }
1059
1070
  },
1060
1071
 
@@ -1104,7 +1115,8 @@ const Util = {
1104
1115
  let public_date = j["public_date"] > 0 ? Util.seconds_to_format(j["public_date"], "%Y-%m-%d") : "--";
1105
1116
  let issue_date = j["issue_date"] > 0 ? Util.seconds_to_format(j["issue_date"], "%Y-%m-%d") : "--";
1106
1117
  _html.push("<tr title='最后更新时间: ", Util.seconds_to_format(j["update_time"], "%Y-%m-%d"), "' class='info'><th colspan='14' text-align='center'>基金概况</th></tr>");
1107
- _html.push("<tr><td colspan='3'>基金代码</td><td colspan='4'>", Util.pack_html_link('https://fund.eastmoney.com/' + j["fund_code"] + '.html', j["fund_code"]), "</td><td colspan='3'>基金名</td><td colspan='4'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + j["fund_code"] + '.html', j["fund_name"]), "</td></tr>");
1118
+ //_html.push("<tr><td colspan='3'>基金代码</td><td colspan='4'>", Util.pack_html_link('https://fund.eastmoney.com/' + j["fund_code"] + '.html', j["fund_code"]), "</td><td colspan='3'>基金名</td><td colspan='4'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + j["fund_code"] + '.html', j["fund_name"]), "</td></tr>");
1119
+ _html.push("<tr><td colspan='3'>基金代码</td><td colspan='4'>", Util.pack_html_link('https://xueqiu.com/S/' + Util.code_to_fund_symbol(j["fund_code"]), j["fund_code"]), "</td><td colspan='3'>基金名</td><td colspan='4'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + j["fund_code"] + '.html', j["fund_name"]), "</td></tr>");
1108
1120
  _html.push("<tr><td colspan='3'>基金类型</td><td colspan='4'>", j["fund_type"], "</td><td colspan='3'>投资类型</td><td colspan='4'>", j["invest_type"], "</td></tr>");
1109
1121
  _html.push("<tr><td colspan='3'>单位净值</td><td colspan='4'>", net, "</td><td colspan='3'>资产规模</td><td colspan='4'>", assets, "</td></tr>");
1110
1122
  _html.push("<tr><td colspan='3'>成立日期</td><td colspan='4'>", public_date, "</td><td colspan='3'>发行日期</td><td colspan='4'>", issue_date, "</td></tr>");
@@ -1215,6 +1227,69 @@ const Util = {
1215
1227
  });
1216
1228
  },
1217
1229
 
1230
+ init_category_top_modal: function(category_top_type) {
1231
+ Util.init_modal_skeleton("category_top_modal", '');
1232
+ $("#category_top_modal_title").html("<select id='category_top_type'><option value='1'>行业ETF</option><option value='2'>同花顺行业</option><option value='3'>申万行业</option></select> 每日涨幅第一的时间统计分析(时间为过去一年内)");
1233
+ Util.init_table_skeleton({
1234
+ "element_id": "category_top_modal_body",
1235
+ "caption": '<caption class="text-right"><span class="label label-info">次数</span>: 时间期间内每日涨幅第一的上榜次数, <span class="label label-info">间隔</span>: 每两次上榜之间的平均天数间隔, <span class="label label-info">距差</span>: 当前时间距离最近一次涨幅第一的间隔天数</caption>',
1236
+ "head_cols": [
1237
+ {"name": "名称"},
1238
+ {"name": "次数", "table_sort": 1},
1239
+ {"name": "间隔", "table_sort": 1, "class": "info"},
1240
+ {"name": "距差", "table_sort": 1},
1241
+ {"name": "时间"},
1242
+ ]
1243
+ });
1244
+ let etm_obj = $('#category_top_modal');
1245
+ etm_obj.on('shown.bs.modal', function (e) {
1246
+ Util.render_category_top_modal();
1247
+ });
1248
+ etm_obj.on('hidden.bs.modal', function () {
1249
+ Util.hide_tips();
1250
+ });
1251
+ let ctt_obj = $("#category_top_type");
1252
+ ctt_obj.find("option[value='" + category_top_type + "']").attr("selected", true);
1253
+ ctt_obj.change(function() {
1254
+ Util.render_category_top_modal();
1255
+ });
1256
+ },
1257
+
1258
+ render_category_top_modal: function() {
1259
+ Util.show_loading();
1260
+ Util.post(location.pathname, {"action": "category_top_statistics", "type": $("#category_top_type").val()}, function (j) {
1261
+ let _html = [];
1262
+ j["data"].forEach(function (item) {
1263
+ let date_data = [];
1264
+ _html.push("<tr>");
1265
+ item["name"] = item["name"] + "(" + item["code"] + ")";
1266
+ _html.push("<td>", Util.pack_html_link("https://xueqiu.com/S/" + Util.code_to_fund_symbol(item["code"]), item["name"]), "</td>");
1267
+ _html.push("<td>", item["num"], "</td>");
1268
+ _html.push("<td data-val='", item["interval_day"], "'>", (item["interval_day"] < 10000 ? (item["interval_day"] + "天") : "--"), "</td>");
1269
+ if (item["dist_day"] < item["interval_day"]) {
1270
+ _html.push("<td data-val='", item["dist_day"], "'>", item["dist_day"], "天</td>");
1271
+ } else {
1272
+ _html.push("<td class='danger' data-val='", item["dist_day"], "'>", item["dist_day"], "天</td>");
1273
+ }
1274
+ item["data"].forEach(function (d) {
1275
+ let date_format = Util.seconds_to_format(d["date"], "%Y-%m-%d");
1276
+ if (d["date"] === j["latest_date"]) {
1277
+ date_format = "<span class='label label-info'>" + date_format + " </span>";
1278
+ }
1279
+ date_data.push(date_format + "(" + Util.parse_ratio(d["p_change"]) + ")&nbsp;&nbsp;&nbsp;");
1280
+ });
1281
+ date_data = date_data.join("")
1282
+ if (item["num"] > 6) {
1283
+ date_data += "...";
1284
+ }
1285
+ _html.push("<td class='text-left'>", date_data, "</td>");
1286
+ _html.push("</tr>");
1287
+ });
1288
+ Util.render_table_html("category_top_modal_body_body", _html);
1289
+ Util.hide_tips();
1290
+ });
1291
+ },
1292
+
1218
1293
  /**
1219
1294
  * 初始货币汇率组件
1220
1295
  * @param component_id
@@ -2682,9 +2757,19 @@ const Util = {
2682
2757
  */
2683
2758
  pack_holder_num: function (item) {
2684
2759
  if (item["holder_num"] && item["holder_num"] > 0) {
2685
- let url = Util.get_url("holder_num") + "?code=" + item["code"];
2686
- let pre_holder_num = item["pre_holder_num"] ? item["pre_holder_num"] : 0;
2687
- return Util.pack_html_link(url, Util.digit_compare_trend(item["holder_num"], pre_holder_num));
2760
+ let holder_url = Util.get_url("holder_num") + "?code=" + item["code"];
2761
+ let holder_info = "";
2762
+ if (item["pre_holder_num"] && item["pre_holder_num"] > 0) {
2763
+ let rate = item["holder_num"] / item["pre_holder_num"];
2764
+ if (rate > 9) {
2765
+ holder_info = '<b data-val="900" title="' + item["pre_holder_num"] + '" class="text-danger">' + item["holder_num"] + '(+900%)</b>';
2766
+ } else {
2767
+ holder_info = Util.digit_compare_trend(item["holder_num"], item["pre_holder_num"]);
2768
+ }
2769
+ } else {
2770
+ holder_info = Util.digit_compare_trend(item["holder_num"], 0);
2771
+ }
2772
+ return Util.pack_html_link(holder_url, holder_info);
2688
2773
  }
2689
2774
  return "--";
2690
2775
  },