sbd-npm 1.3.58 → 1.3.60

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 (3) hide show
  1. package/package.json +1 -1
  2. package/stock_basics.js +1 -94
  3. package/util.js +116 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.58",
3
+ "version": "1.3.60",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -86,7 +86,7 @@ let Stock = {
86
86
  Stock.fetch_report_organization();
87
87
  break;
88
88
  case "public_fund":
89
- Stock.fetch_public_fund();
89
+ Util.fetch_public_fund(Stock["code"]);
90
90
  break;
91
91
  case "public_fund_change":
92
92
  Stock.fetch_public_fund_change();
@@ -916,99 +916,6 @@ let Stock = {
916
916
  });
917
917
  },
918
918
 
919
- /**
920
- * 公募持股
921
- */
922
- fetch_public_fund: function () {
923
- Util.show_loading();
924
- Util.init_table_skeleton({
925
- "element_id": "public_fund_table",
926
- "head_cols": [
927
- {"name": "序号"},
928
- {"name": "基金代码"},
929
- {"name": "基金名"},
930
- {"name": "净值", "tooltip": "单位净值", "table_sort": 1},
931
- {"name": "资产规模", "table_sort": 1},
932
- {"name": "基金类型"},
933
- {"name": "投资类型"},
934
- {"name": "基金公司"},
935
- {"name": "成立日期", "table_sort": 1},
936
- {"name": "持有量", "table_sort": 1, "class": "info"},
937
- {"name": "持仓市值", "table_sort": 1},
938
- {"name": ""},
939
- ]
940
- });
941
- let payload = {
942
- action: "public_fund",
943
- public_fund_date: $("#public_fund_date").val()
944
- };
945
- Util.post("/stock/" + Stock["code"], payload, function (j) {
946
- let _html = [], total_public_fund = 0, total_stock_num = 0, total_market_capital = 0;
947
- j["data"].forEach(function (item) {
948
- total_public_fund++;
949
- total_stock_num += item["stock_num"];
950
- total_market_capital += item["market_capital"];
951
- let public_date = "--";
952
- if (item["public_date"] > 0) {
953
- public_date = Util.seconds_to_format(item["public_date"], "%Y-%m-%d");
954
- }
955
- let net = item["net"];
956
- let cls = Util.text_color(item["change_percent"])
957
- if (cls !== "") {
958
- net = "<b class='" + cls + "'>" + net + "(" + Util.to_float(item["change_percent"], 2) + "%)</b>";
959
- }
960
- _html.push("<tr class='", (($.inArray(item["fund_code"], j["etf_code_list"]) > -1) ? "danger" : ""), "'>");
961
- _html.push("<td>", total_public_fund, "</td>");
962
- _html.push("<td>", Util.pack_html_link('https://fund.eastmoney.com/' + item["fund_code"] + '.html', item["fund_code"]), "</td>");
963
- _html.push("<td title='基金概况'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + item["fund_code"] + '.html', item["fund_name"]), "</td>");
964
- _html.push("<td>", net, "</td>");
965
- _html.push("<td>", item["assets"], "亿</td>");
966
- _html.push("<td>", item["fund_type"], "</td>");
967
- _html.push("<td>", item["invest_type"], "</td>");
968
- _html.push("<td>", Util.pack_html_link("https://baike.baidu.com/item/" + item["administrator"].replace("基金管理", "基金"), item["administrator"]), "</td>");
969
- _html.push("<td>", public_date, "</td>");
970
- _html.push("<td data-val='", item["stock_num"], "' title='", item["stock_num"], "'>", Util.to_unit(item["stock_num"], 3), "股</td>");
971
- _html.push("<td data-val='", item["market_capital"], "' title='", item["market_capital"], "'>", Util.to_unit(item["market_capital"], 3), "</td>");
972
- _html.push("<td><a class='link_cls' data-toggle='modal' data-target='.public_fund_modal' data-val='", item["fund_code"], "'>详细</a></td>");
973
- _html.push("</tr>");
974
- });
975
- Util.render_table_html("public_fund_table_body", _html);
976
- let public_fund_tips = "";
977
- if (j["cur_fund_num"]) {
978
- total_public_fund = Util.pack_html_link(Util.get_url("trend_fund_hold"), '<span class="label label-info">' + j["cur_fund_num"] + '</span>');
979
- public_fund_tips = '共 ' + total_public_fund + ' 家(' + Util.year_price_rate(j["cur_fund_num"], j["pre_fund_num"], 1) + '), <span class="label label-info">' + Util.to_unit(j["cur_stock_num"], 3) + '</span> 股(' + Util.year_price_rate(j["cur_stock_num"], j["pre_stock_num"], 1) + '),<span class="label label-info">' + Util.to_unit(j["hold_value"], 3) + '</span>市值';
980
- } else {
981
- total_public_fund = Util.pack_html_link(Util.get_url("trend_fund_hold"), '<span class="label label-info">' + total_public_fund + '</span>');
982
- public_fund_tips = '共 ' + total_public_fund + ' 家, <span class="label label-info">' + Util.to_unit(total_stock_num, 3) + '</span> 股,<span class="label label-info">' + Util.to_unit(total_market_capital, 3) + '</span>市值';
983
- }
984
- $("#public_fund_tips").html(public_fund_tips);
985
- if (j["date"] && j["date"] > 0) {
986
- $("#public_fund_title").find("a").each(function() {
987
- let t_text = $(this).text();
988
- if (t_text.indexOf("持股详细查询") > -1) {
989
- $(this).attr("href", "https://data.eastmoney.com/zlsj/detail/" + Util.seconds_to_format(j["date"], "%Y-%m-%d") + "-1-" + Stock["code"] + ".html");
990
- }
991
- });
992
- }
993
- if ($("#public_fund_date").length === 0) {
994
- Util.post("/stock/" + Stock["code"], {action: "public_fund_date"}, function (j) {
995
- let _html = [];
996
- _html.push('<select id="public_fund_date">');
997
- j["data"].forEach(function (item) {
998
- let date_format = Util.seconds_to_format(item["date"], "%Y-%m-%d");
999
- _html.push('<option value="', date_format, '">', date_format, '(', item["num"], ')</option>');
1000
- });
1001
- _html.push('</select>');
1002
- $("#public_fund_date_zone").html(_html.join(""));
1003
- $("#public_fund_date").change(function () {
1004
- Stock.fetch_public_fund();
1005
- });
1006
- });
1007
- }
1008
- Util.hide_tips();
1009
- });
1010
- },
1011
-
1012
919
  /**
1013
920
  * 公募持股变化
1014
921
  */
package/util.js CHANGED
@@ -1070,6 +1070,100 @@ const Util = {
1070
1070
  });
1071
1071
  },
1072
1072
 
1073
+ /**
1074
+ * 公募持股
1075
+ * @param code
1076
+ */
1077
+ fetch_public_fund: function (code) {
1078
+ Util.show_loading();
1079
+ Util.init_table_skeleton({
1080
+ "element_id": "public_fund_table",
1081
+ "head_cols": [
1082
+ {"name": "序号"},
1083
+ {"name": "基金代码"},
1084
+ {"name": "基金名"},
1085
+ {"name": "净值", "tooltip": "单位净值", "table_sort": 1},
1086
+ {"name": "资产规模", "table_sort": 1},
1087
+ {"name": "基金类型"},
1088
+ {"name": "投资类型"},
1089
+ {"name": "基金公司"},
1090
+ {"name": "成立日期", "table_sort": 1},
1091
+ {"name": "持有量", "table_sort": 1, "class": "info"},
1092
+ {"name": "持仓市值", "table_sort": 1},
1093
+ {"name": ""},
1094
+ ]
1095
+ });
1096
+ let payload = {
1097
+ action: "public_fund",
1098
+ public_fund_date: $("#public_fund_date").val()
1099
+ };
1100
+ Util.post("/stock/" + code, payload, function (j) {
1101
+ let _html = [], total_public_fund = 0, total_stock_num = 0, total_market_capital = 0;
1102
+ j["data"].forEach(function (item) {
1103
+ total_public_fund++;
1104
+ total_stock_num += item["stock_num"];
1105
+ total_market_capital += item["market_capital"];
1106
+ let public_date = "--";
1107
+ if (item["public_date"] > 0) {
1108
+ public_date = Util.seconds_to_format(item["public_date"], "%Y-%m-%d");
1109
+ }
1110
+ let net = item["net"];
1111
+ let cls = Util.text_color(item["change_percent"])
1112
+ if (cls !== "") {
1113
+ net = "<b class='" + cls + "'>" + net + "(" + Util.to_float(item["change_percent"], 2) + "%)</b>";
1114
+ }
1115
+ _html.push("<tr class='", (($.inArray(item["fund_code"], j["etf_code_list"]) > -1) ? "danger" : ""), "'>");
1116
+ _html.push("<td>", total_public_fund, "</td>");
1117
+ _html.push("<td>", Util.pack_html_link('https://fund.eastmoney.com/' + item["fund_code"] + '.html', item["fund_code"]), "</td>");
1118
+ _html.push("<td title='基金概况'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + item["fund_code"] + '.html', item["fund_name"]), "</td>");
1119
+ _html.push("<td>", net, "</td>");
1120
+ _html.push("<td>", item["assets"], "亿</td>");
1121
+ _html.push("<td>", item["fund_type"], "</td>");
1122
+ _html.push("<td>", item["invest_type"], "</td>");
1123
+ _html.push("<td>", Util.pack_fund_administrator(item), "</td>");
1124
+ _html.push("<td>", public_date, "</td>");
1125
+ _html.push("<td data-val='", item["stock_num"], "' title='", item["stock_num"], "'>", Util.to_unit(item["stock_num"], 3), "股</td>");
1126
+ _html.push("<td data-val='", item["market_capital"], "' title='", item["market_capital"], "'>", Util.to_unit(item["market_capital"], 3), "</td>");
1127
+ _html.push("<td><a class='link_cls' data-toggle='modal' data-target='.public_fund_modal' data-val='", item["fund_code"], "'>详细</a></td>");
1128
+ _html.push("</tr>");
1129
+ });
1130
+ Util.render_table_html("public_fund_table_body", _html);
1131
+ let public_fund_tips = "";
1132
+ if (j["cur_fund_num"]) {
1133
+ total_public_fund = Util.pack_html_link(Util.get_url("trend_fund_hold"), '<span class="label label-info">' + j["cur_fund_num"] + '</span>');
1134
+ public_fund_tips = '共 ' + total_public_fund + ' 家(' + Util.year_price_rate(j["cur_fund_num"], j["pre_fund_num"], 1) + '), <span class="label label-info">' + Util.to_unit(j["cur_stock_num"], 3) + '</span> 股(' + Util.year_price_rate(j["cur_stock_num"], j["pre_stock_num"], 1) + '),<span class="label label-info">' + Util.to_unit(j["hold_value"], 3) + '</span>市值';
1135
+ } else {
1136
+ total_public_fund = Util.pack_html_link(Util.get_url("trend_fund_hold"), '<span class="label label-info">' + total_public_fund + '</span>');
1137
+ public_fund_tips = '共 ' + total_public_fund + ' 家, <span class="label label-info">' + Util.to_unit(total_stock_num, 3) + '</span> 股,<span class="label label-info">' + Util.to_unit(total_market_capital, 3) + '</span>市值';
1138
+ }
1139
+ $("#public_fund_tips").html(public_fund_tips);
1140
+ if (j["date"] && j["date"] > 0) {
1141
+ $("#public_fund_title").find("a").each(function() {
1142
+ let t_text = $(this).text();
1143
+ if (t_text.indexOf("持股详细查询") > -1) {
1144
+ $(this).attr("href", "https://data.eastmoney.com/zlsj/detail/" + Util.seconds_to_format(j["date"], "%Y-%m-%d") + "-1-" + code + ".html");
1145
+ }
1146
+ });
1147
+ }
1148
+ if ($("#public_fund_date").length === 0) {
1149
+ Util.post("/stock/" + code, {action: "public_fund_date"}, function (j) {
1150
+ let _html = [];
1151
+ _html.push('<select id="public_fund_date">');
1152
+ j["data"].forEach(function (item) {
1153
+ let date_format = Util.seconds_to_format(item["date"], "%Y-%m-%d");
1154
+ _html.push('<option value="', date_format, '">', date_format, '(', item["num"], ')</option>');
1155
+ });
1156
+ _html.push('</select>');
1157
+ $("#public_fund_date_zone").html(_html.join(""));
1158
+ $("#public_fund_date").change(function () {
1159
+ Util.fetch_public_fund(code);
1160
+ });
1161
+ });
1162
+ }
1163
+ Util.hide_tips();
1164
+ });
1165
+ },
1166
+
1073
1167
  /**
1074
1168
  * 初始分类股票的显示表格
1075
1169
  * @param portfolio
@@ -1219,8 +1313,7 @@ const Util = {
1219
1313
  _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>");
1220
1314
  _html.push("<tr><td colspan='3'>单位净值</td><td colspan='4'>", net, "</td><td colspan='3'>资产规模</td><td colspan='4'>", assets, "</td></tr>");
1221
1315
  _html.push("<tr><td colspan='3'>成立日期</td><td colspan='4'>", public_date, "</td><td colspan='3'>发行日期</td><td colspan='4'>", issue_date, "</td></tr>");
1222
- let administrator = Util.pack_html_link("https://baike.baidu.com/item/" + j["administrator"].replace("基金管理", "基金"), j["administrator"]);
1223
- _html.push("<tr><td colspan='3'>基金管理公司</td><td colspan='4'>", administrator, "</td><td colspan='3'>基金经理</td><td colspan='4'>", j["managers"], "</td></tr>");
1316
+ _html.push("<tr><td colspan='3'>基金管理公司</td><td colspan='4'>", Util.pack_fund_administrator(j), "</td><td colspan='3'>基金经理</td><td colspan='4'>", j["managers"], "</td></tr>");
1224
1317
  _html.push("<tr><td colspan='5'>基金托管人</td><td colspan='9'>", (j["custodian"] ? j["custodian"] : "--"), "</td></tr>");
1225
1318
  _html.push("<tr><td colspan='5'>经办律师事务所</td><td colspan='9'>", (j["lawyer"] ? j["lawyer"] : "--"), "</td></tr>");
1226
1319
  _html.push("<tr><td colspan='5'>会计师事务所</td><td colspan='9'>", (j["accounting"] ? j["accounting"] : "--"), "</td></tr>");
@@ -2904,6 +2997,9 @@ const Util = {
2904
2997
  */
2905
2998
  pack_holder_num: function (item) {
2906
2999
  let holder_info = "--";
3000
+ if (item["code"] && Util.is_hk(item["code"])) {
3001
+ return holder_info;
3002
+ }
2907
3003
  if (item["holder_num"] && item["holder_num"] > 0) {
2908
3004
  if (item["pre_holder_num"] && item["pre_holder_num"] > 0) {
2909
3005
  holder_info = Util.digit_compare_trend(item["holder_num"], item["pre_holder_num"]);
@@ -2928,6 +3024,24 @@ const Util = {
2928
3024
  return Util.pack_html_link("/stock/" + item["code"] + "?tab=public_fund", fund_num);
2929
3025
  },
2930
3026
 
3027
+ /**
3028
+ * 组装基金公司数据
3029
+ * @param item
3030
+ * @returns {string}
3031
+ */
3032
+ pack_fund_administrator: function (item) {
3033
+ if (item["administrator"]) {
3034
+ let url = "";
3035
+ if (item["administrator_code"]) {
3036
+ url = "https://fund.eastmoney.com/company/" + item["administrator_code"] + ".html";
3037
+ } else {
3038
+ url = "https://baike.baidu.com/item/" + item["administrator"].replace("基金管理", "基金");
3039
+ }
3040
+ return Util.pack_html_link(url, item["administrator"]);
3041
+ }
3042
+ return "--";
3043
+ },
3044
+
2931
3045
  /**
2932
3046
  * 雪球人数关注排名数据
2933
3047
  * @param item