sbd-npm 1.2.98 → 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 +88 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.98",
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}
@@ -1105,7 +1115,8 @@ const Util = {
1105
1115
  let public_date = j["public_date"] > 0 ? Util.seconds_to_format(j["public_date"], "%Y-%m-%d") : "--";
1106
1116
  let issue_date = j["issue_date"] > 0 ? Util.seconds_to_format(j["issue_date"], "%Y-%m-%d") : "--";
1107
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>");
1108
- _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>");
1109
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>");
1110
1121
  _html.push("<tr><td colspan='3'>单位净值</td><td colspan='4'>", net, "</td><td colspan='3'>资产规模</td><td colspan='4'>", assets, "</td></tr>");
1111
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>");
@@ -1216,6 +1227,69 @@ const Util = {
1216
1227
  });
1217
1228
  },
1218
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
+
1219
1293
  /**
1220
1294
  * 初始货币汇率组件
1221
1295
  * @param component_id
@@ -2683,9 +2757,19 @@ const Util = {
2683
2757
  */
2684
2758
  pack_holder_num: function (item) {
2685
2759
  if (item["holder_num"] && item["holder_num"] > 0) {
2686
- let url = Util.get_url("holder_num") + "?code=" + item["code"];
2687
- let pre_holder_num = item["pre_holder_num"] ? item["pre_holder_num"] : 0;
2688
- 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);
2689
2773
  }
2690
2774
  return "--";
2691
2775
  },