sbd-npm 1.1.46 → 1.1.50

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/menu.js CHANGED
@@ -127,10 +127,10 @@ const MenuList = [
127
127
  {'key': 'concept_recommend', 'name': '关注', 'url': '/0f7226866475982d2a80497b9fa1719a'},
128
128
  {'key': 'concept_bellwether', 'name': '龙头股', 'url': '/2e1a34cc6bd2d6e92f962e4ef9b9f333'},
129
129
  {'key': 'concept_market_situation', 'name': '市值风云', 'url': '/4229754a8bec7b021c259956c70dba74'},
130
+ {'key': 'concept_cannon', 'name': '黄家礼炮', 'url': '/8cd8b9d6e96fba8cc87185ec5aa3b429'},
130
131
  {'key': 'concept_niu', 'name': '老曾阿牛', 'url': '/65656ebe27216279cd66db60c7837349'},
131
132
  {'key': 'concept_qian', 'name': '唐史主任司马迁', 'url': '/ee1480d344e0a5cc26db27e180f1e75e'},
132
133
  {'key': 'concept_dan', 'name': '但斌', 'url': '/548a55ff9dc4e6e09d02693cd6428983'},
133
- {'key': 'concept_cannon', 'name': '黄家礼炮', 'url': '/8cd8b9d6e96fba8cc87185ec5aa3b429'},
134
134
  {'key': 'concept_hill', 'name': '高瓴资本', 'url': '/a260940f6937ebb225f802b1dffd772e'},
135
135
  {'key': 'concept_hk', 'name': '港股', 'url': '/8bb2e92c534697fd52bff0faa7af854e'},
136
136
  {'key': 'concept_us', 'name': '美股', 'url': '/43d9d1304310863541c8bbb8ea8e8664'},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.46",
3
+ "version": "1.1.50",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/summary_daily.js CHANGED
@@ -31,8 +31,7 @@ $(document).ready(function () {
31
31
  },
32
32
 
33
33
  load_cache: function () {
34
- DailySummary["hsgt_money_flow_chart"] = Util.init_echarts_instance("hsgt_money_flow_line");
35
- DailySummary["hsgt_money_flow_chart"].showLoading();
34
+ DailySummary["hsgt_money_flow_chart"] = Util.show_chart_loading(DailySummary["hsgt_money_flow_chart"], "hsgt_money_flow_line");
36
35
  try {
37
36
  let cache = DailySummary.get_cache();
38
37
  if (cache.hasOwnProperty("market_overview")) {
package/util.js CHANGED
@@ -215,7 +215,7 @@ const Util = {
215
215
  * @returns {string}
216
216
  */
217
217
  industry_url: function (code, industry) {
218
- if (industry === "undefined") {
218
+ if (industry === "undefined" || industry === "None") {
219
219
  return "--";
220
220
  }
221
221
  if (industry) {
@@ -345,6 +345,12 @@ const Util = {
345
345
  $(this).html(Util.year_price_rate(item["price"], item["high_52week"]));
346
346
  });
347
347
  }
348
+ if (item["holder_num"] && item["holder_num"] > 0 && item["pre_holder_num"]) {
349
+ $(".holder_" + code).each(function () {
350
+ let url = Util.get_url("holder_num") + "?code=" + item["code"];
351
+ $(this).html(Util.pack_html_link(url, Util.digit_compare_trend(item["holder_num"], item["pre_holder_num"])));
352
+ });
353
+ }
348
354
  }
349
355
  if (item["high"]) {
350
356
  let high_price = Util.digit_compare_trend(item["high"], item["previous_price"]);
@@ -752,6 +758,69 @@ const Util = {
752
758
  });
753
759
  },
754
760
 
761
+ /**
762
+ * 初始分类股票的显示表格
763
+ * @param stock_category
764
+ * @param table_id
765
+ */
766
+ init_stock_category_data: function (stock_category, table_id) {
767
+ Util.show_tips("Loading...");
768
+ let head_cols = [
769
+ {"name": "代码"},
770
+ {"name": "名称"},
771
+ {"name": "PE", "title": "市盈率(Price Earnings Ratio)", "table_sort": 1},
772
+ {"name": "总市值", "table_sort": 1},
773
+ {"name": "行业"},
774
+ {"name": "地区"},
775
+ {"name": "当前价", "table_sort": 1},
776
+ {"name": "最高价"},
777
+ {"name": "最低价"},
778
+ {"name": "年初至今", "table_sort": 1},
779
+ {"name": "52周最高", "table_sort": 1}
780
+ ];
781
+ if (stock_category !== "us") {
782
+ head_cols.push({"name": "成交金额", "table_sort": 1});
783
+ head_cols.push({"name": "成交均价"});
784
+ head_cols.push({"name": "股东数", "table_sort": 1});
785
+ head_cols.push({"name": "备注", "id": "remark_title"});
786
+ }
787
+ Util.init_table_skeleton({
788
+ "element_id": table_id,
789
+ "caption": '<caption><span id="index_data"></span><div class="pull-right" id="' + table_id + '_body_tips"></div></caption>',
790
+ "head_cols": head_cols
791
+ });
792
+ Util.post(location.pathname, {active_div: stock_category}, function (j) {
793
+ let _html = [];
794
+ let total_num = 0;
795
+ j["data"].forEach(function (item) {
796
+ total_num++;
797
+ _html.push("<tr>");
798
+ item["code"] = item["code"].toLowerCase();
799
+ _html = Util.stock_basics_html(_html, item);
800
+ _html.push("<td id='high_", item["code"], "'>0</td>");
801
+ _html.push("<td id='low_", item["code"], "'>0</td>");
802
+ _html.push("<td data-val='", item["year_price"], "' class='year_price_", item["code"], "'>--</td>");
803
+ _html.push("<td class='high_52week_", item["code"], "'>--</td>");
804
+ if (stock_category !== "us") {
805
+ _html.push("<td id='amount_", item["code"], "'>--</td>");
806
+ _html.push("<td id='average_", item["code"], "'>--</td>");
807
+ _html.push("<td class='holder_", item["code"], "'>--</td>");
808
+ _html.push("<td id='remark_", item["code"], "'></td>");
809
+ }
810
+ _html.push("</tr>");
811
+ });
812
+ Util.render_table_html(table_id + "_body", _html);
813
+ $("#" + table_id + "_body_tips").html('共 <span class="label label-info">' + total_num + '</span> 家');
814
+ if (j["concept_url"]) {
815
+ $("#remark_title").html(Util.pack_html_link(j["concept_url"], "备注<i class='glyphicon glyphicon-link'></i>"));
816
+ }
817
+ Util.hide_tips();
818
+ let index_list = j["index_list"] ? j["index_list"] : [];
819
+ let is_us = stock_category === "us" ? 1 : 0;
820
+ Util.init_stock_stuff(table_id + "_body", index_list, is_us);
821
+ });
822
+ },
823
+
755
824
  /**
756
825
  * 初始公募基金组件
757
826
  * @param component_id
@@ -1026,7 +1095,7 @@ const Util = {
1026
1095
  _html.push("</tr>");
1027
1096
  });
1028
1097
  Util.render_table_html(component_id + "_body_body", _html);
1029
- $("#" + component_id + "_title").html("[" + Util.stock_url(code, j["stock_name"]) + "]资金流向明细(<span>净买入:<b title='" + summary_inflow + "' class='" + Util.text_color(summary_inflow) + "'>" + Util.to_unit(summary_inflow) + "</b>, 上榜次数:" + total_times + ", 买入次数:<b class='text-danger'>" + buy_times + "</b>, 卖出次数:<b class='text-success'>" + sell_times + "</b></span>)");
1098
+ $("#" + component_id + "_title").html("[" + Util.stock_url(code, j["stock_name"]) + "]资金流向明细(<span>净买入:<b title='" + summary_inflow + "' class='" + Util.text_color(summary_inflow) + "'>" + Util.to_unit(summary_inflow) + "</b>, 上榜次数:<b class='text-info'>" + total_times + "</b>, 买入次数:<b class='text-danger'>" + buy_times + "</b>, 卖出次数:<b class='text-success'>" + sell_times + "</b></span>)");
1030
1099
  });
1031
1100
  }
1032
1101
  });
@@ -1307,7 +1376,11 @@ const Util = {
1307
1376
  return default_val;
1308
1377
  },
1309
1378
 
1310
- // [为什么要用 setTimeout 模拟 setInterval ?](https://segmentfault.com/a/1190000038829248)
1379
+ /**
1380
+ * [为什么要用 setTimeout 模拟 setInterval ?](https://segmentfault.com/a/1190000038829248)
1381
+ * @param func
1382
+ * @param timeout
1383
+ */
1311
1384
  set_interval: function (func, timeout) {
1312
1385
  let handler = function () {
1313
1386
  func.call(null);
@@ -1321,11 +1394,22 @@ const Util = {
1321
1394
  // }
1322
1395
  },
1323
1396
 
1324
- encode_base64: function (encode_string) {
1397
+ /**
1398
+ * Base64 编码
1399
+ * https://baike.baidu.com/item/base64
1400
+ * @param encode_string
1401
+ * @returns {string}
1402
+ */
1403
+ base64_encode: function (encode_string) {
1325
1404
  return btoa(encodeURI(encode_string));
1326
1405
  },
1327
1406
 
1328
- decode_base64: function (base64) {
1407
+ /**
1408
+ * Base64 解码
1409
+ * @param base64
1410
+ * @returns {string}
1411
+ */
1412
+ base64_decode: function (base64) {
1329
1413
  return decodeURI(atob(base64));
1330
1414
  },
1331
1415
 
@@ -1507,6 +1591,10 @@ const Util = {
1507
1591
  });
1508
1592
  },
1509
1593
 
1594
+ /**
1595
+ * 表格排序
1596
+ * @param element_id
1597
+ */
1510
1598
  table_sort: function (element_id = "") {
1511
1599
  let selector = element_id === "" ? ".table_sort" : ("#" + element_id + " .table_sort");
1512
1600
  $(selector).each(function () {
@@ -2347,7 +2435,7 @@ const Util = {
2347
2435
  * @param date_type
2348
2436
  */
2349
2437
  startup_metrics_statistics: function (chart_instance, metrics, date_type) {
2350
- chart_instance = Util.show_echarts_loading(chart_instance, metrics + "_bar_canvas");
2438
+ chart_instance = Util.show_chart_loading(chart_instance, metrics + "_bar_canvas");
2351
2439
  $("." + metrics + "_bar_btn").each(function () {
2352
2440
  let d_type = $(this).attr("data-val");
2353
2441
  $(this).removeClass("btn-default");
@@ -2407,7 +2495,12 @@ const Util = {
2407
2495
  return 0;
2408
2496
  },
2409
2497
 
2410
- init_echarts_instance: function (element_id) {
2498
+ /**
2499
+ * 初始一个图表实例
2500
+ * @param element_id
2501
+ * @returns {*|jQuery|void}
2502
+ */
2503
+ init_chart_instance: function (element_id) {
2411
2504
  let element = document.getElementById(element_id);
2412
2505
  element.style.width = "width:100%";
2413
2506
  if (!element.style.height) {
@@ -2424,16 +2517,25 @@ const Util = {
2424
2517
  return echarts.init(element);
2425
2518
  },
2426
2519
 
2427
- show_echarts_loading: function (chart_instance, element_id) {
2520
+ /**
2521
+ * 初始图表加载状态
2522
+ * @param chart_instance
2523
+ * @param element_id
2524
+ * @returns {*|jQuery|void}
2525
+ */
2526
+ show_chart_loading: function (chart_instance, element_id) {
2428
2527
  Util.show_tips("Loading...");
2429
2528
  if (!chart_instance) {
2430
- chart_instance = Util.init_echarts_instance(element_id);
2529
+ chart_instance = Util.init_chart_instance(element_id);
2431
2530
  }
2432
2531
  chart_instance.showLoading();
2433
2532
  return chart_instance;
2434
2533
  },
2435
2534
 
2436
- echarts_mark_point: {
2535
+ /**
2536
+ * 图表描点配置
2537
+ */
2538
+ chart_mark_point: {
2437
2539
  "symbol": "circle",
2438
2540
  "symbolSize": 8,
2439
2541
  "label": {
@@ -2445,7 +2547,14 @@ const Util = {
2445
2547
  ]
2446
2548
  },
2447
2549
 
2448
- echarts_mark_line: function (chart_instance, y_val, color = "") {
2550
+ /**
2551
+ * 在图表上标线
2552
+ * @param chart_instance
2553
+ * @param y_val
2554
+ * @param color
2555
+ * @returns {*}
2556
+ */
2557
+ chart_mark_line: function (chart_instance, y_val, color = "") {
2449
2558
  color = color === "" ? "#E74C3C" : color;
2450
2559
  chart_instance.setOption({
2451
2560
  series: [{
@@ -2462,10 +2571,18 @@ const Util = {
2462
2571
  return chart_instance;
2463
2572
  },
2464
2573
 
2465
- // https://www.chartjs.org/samples/latest/charts/line/basic.html
2574
+ /**
2575
+ * https://www.chartjs.org/samples/latest/charts/line/basic.html
2576
+ * @param chart_instance
2577
+ * @param element_id
2578
+ * @param x_data
2579
+ * @param line_data
2580
+ * @param fill
2581
+ * @returns {*|jQuery|void}
2582
+ */
2466
2583
  chart_basic_line: function (chart_instance, element_id, x_data, line_data, fill = false) {
2467
2584
  if (!chart_instance) {
2468
- chart_instance = Util.init_echarts_instance(element_id);
2585
+ chart_instance = Util.init_chart_instance(element_id);
2469
2586
  }
2470
2587
  chart_instance.clear();
2471
2588
  let series_data = [];
@@ -2482,7 +2599,7 @@ const Util = {
2482
2599
  "itemStyle": {
2483
2600
  "color": color
2484
2601
  },
2485
- "markPoint": Util.echarts_mark_point,
2602
+ "markPoint": Util.chart_mark_point,
2486
2603
  "data": line["data"]
2487
2604
  };
2488
2605
  if (line["label"]) {
@@ -2531,7 +2648,7 @@ const Util = {
2531
2648
  // https://www.chartjs.org/samples/latest/charts/bar/vertical.html
2532
2649
  chart_basic_bar: function (chart_instance, element_id, x_data, bar_data, bar_title, bar_color_data) {
2533
2650
  if (!chart_instance) {
2534
- chart_instance = Util.init_echarts_instance(element_id);
2651
+ chart_instance = Util.init_chart_instance(element_id);
2535
2652
  }
2536
2653
  chart_instance.clear();
2537
2654
  chart_instance.setOption({
@@ -2593,7 +2710,7 @@ const Util = {
2593
2710
  // https://www.chartjs.org/samples/latest/charts/line/multi-axis.html
2594
2711
  multi_axis_line: function (chart_instance, element_id, x_data, y1_title, y1_data, y2_title, y2_data) {
2595
2712
  if (!chart_instance) {
2596
- chart_instance = Util.init_echarts_instance(element_id);
2713
+ chart_instance = Util.init_chart_instance(element_id);
2597
2714
  }
2598
2715
  chart_instance.clear();
2599
2716
  chart_instance.setOption({
@@ -2618,7 +2735,7 @@ const Util = {
2618
2735
  "itemStyle": {
2619
2736
  "color": "#36A2EB"
2620
2737
  },
2621
- "markPoint": Util.echarts_mark_point,
2738
+ "markPoint": Util.chart_mark_point,
2622
2739
  "data": y1_data
2623
2740
  },
2624
2741
  {
@@ -2633,7 +2750,7 @@ const Util = {
2633
2750
  "itemStyle": {
2634
2751
  "color": "#FF6384"
2635
2752
  },
2636
- "markPoint": Util.echarts_mark_point,
2753
+ "markPoint": Util.chart_mark_point,
2637
2754
  "data": y2_data,
2638
2755
  "yAxisIndex": 1
2639
2756
  }
@@ -2677,7 +2794,7 @@ const Util = {
2677
2794
  // https://www.chartjs.org/samples/latest/charts/combo-bar-line.html
2678
2795
  chart_bar_line: function (chart_instance, element_id, x_data, bar_data, bar_title, bar_color_data, line_data, line_title, zoom_start = 0) {
2679
2796
  if (!chart_instance) {
2680
- chart_instance = Util.init_echarts_instance(element_id);
2797
+ chart_instance = Util.init_chart_instance(element_id);
2681
2798
  }
2682
2799
  chart_instance.clear();
2683
2800
  let low_bar_index = 0;
@@ -2727,7 +2844,7 @@ const Util = {
2727
2844
  "itemStyle": {
2728
2845
  "color": "#4DC9F6"
2729
2846
  },
2730
- "markPoint": Util.echarts_mark_point,
2847
+ "markPoint": Util.chart_mark_point,
2731
2848
  "data": line_data
2732
2849
  },
2733
2850
  {
@@ -2829,7 +2946,7 @@ const Util = {
2829
2946
 
2830
2947
  bias_bar_line: function (chart_instance, element_id, x_data, bias120_data, color_data, bias20_data, bias60_data, price_data) {
2831
2948
  if (!chart_instance) {
2832
- chart_instance = Util.init_echarts_instance(element_id);
2949
+ chart_instance = Util.init_chart_instance(element_id);
2833
2950
  }
2834
2951
  chart_instance.clear();
2835
2952
  chart_instance.setOption({