sbd-npm 1.3.61 → 1.3.63

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/constant.js +1 -1
  2. package/package.json +1 -1
  3. package/util.js +105 -47
package/constant.js CHANGED
@@ -27,11 +27,11 @@ const MenuList = [
27
27
  {'key': 'trend_kdj', 'name': 'KDJ金叉', 'url': '/0x3382bdaec4e8715ce27ca2b538dce09a2f8f5e50'},
28
28
  {'key': 'trend_macd_cross', 'name': 'MACD金叉', 'url': '/0x277bc35fcd21059103dd7917c8bfe0c474880b85'},
29
29
  {'key': 'trend_bull_trend', 'name': '多头趋势', 'url': '/0x37b24777154ee090926e57bfa5602efa5c89b8a8'},
30
+ {'key': 'trend_fund_hold', 'name': '基金数持股变化', 'url': '/0x706c0e77ca3e314b5186c763e6ee857b744e9880'},
30
31
  {'key': 'trend_money_inflow', 'name': '资金流入历史最高', 'url': '/0xfbfc92be1eebe9ccf5b2f14b9a2ea25f2cc941b8'},
31
32
  {'key': 'trend_boll', 'name': '布林线', 'url': '/0x7f2c6b9542ce7626669ab4910cbf7e8812883fea'},
32
33
  {'key': 'trend_holder_minimum', 'name': '股东数历史最少', 'url': '/0xf0c0c360a283689c83ae216c6bbb03777d8068ca'},
33
34
  {'key': 'trend_down_maximum', 'name': '历史高位最大跌幅', 'url': '/0x8d7b8abeec94e2ebe4b25115272d9d5899355c43'},
34
- {'key': 'trend_fund_hold', 'name': '基金数持股变化', 'url': '/0x706c0e77ca3e314b5186c763e6ee857b744e9880'},
35
35
  {'key': 'trend_week_minimum', 'name': '周成交低点', 'url': '/0xa9dfc159b157ae3b694a12dc42fb8feaa75bcf51'},
36
36
  {'key': 'trend_margin', 'name': '融资融券余额涨幅', 'url': '/0x9a2c22255e4f87592b10432c8ab24b14c82692af'},
37
37
  {'key': 'trend_index_month', 'name': '指数每年月份涨跌', 'url': '/0xf59cc6347d851edfe836a6c1c23c518cb83e27de'},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.61",
3
+ "version": "1.3.63",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -1093,50 +1093,8 @@ const Util = {
1093
1093
  {"name": ""},
1094
1094
  ]
1095
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);
1096
+ Util.post("/stock/" + code, {action: "public_fund", public_fund_date: $("#public_fund_date").val()}, function (j) {
1097
+ Util.render_public_fund(j);
1140
1098
  if (j["date"] && j["date"] > 0) {
1141
1099
  $("#public_fund_title").find("a").each(function() {
1142
1100
  let t_text = $(this).text();
@@ -1158,12 +1116,100 @@ const Util = {
1158
1116
  $("#public_fund_date").change(function () {
1159
1117
  Util.fetch_public_fund(code);
1160
1118
  });
1119
+ $(".public_fund_difference").each(function() {
1120
+ $(this).click(function() {
1121
+ let public_fund_date = $("#public_fund_date").val();
1122
+ if (Util.regexp_date_yyyy_mm_dd(public_fund_date)) {
1123
+ public_fund_date = Util.format_to_second(public_fund_date);
1124
+ let prev_public_fund_date = Util.get_prev_public_fund_date("public_fund_date", public_fund_date);
1125
+ if (prev_public_fund_date > 0 && public_fund_date > prev_public_fund_date) {
1126
+ Util.show_loading();
1127
+ Util.set_table_loading("public_fund_table_body");
1128
+ let payload = {
1129
+ action: "public_fund_difference",
1130
+ type: $(this).attr("data-val"),
1131
+ date: public_fund_date,
1132
+ pre_date: prev_public_fund_date
1133
+ };
1134
+ Util.post("/stock/" + code, payload, function (j) {
1135
+ Util.render_public_fund(j);
1136
+ Util.hide_tips();
1137
+ });
1138
+ }
1139
+ }
1140
+ });
1141
+ });
1161
1142
  });
1162
1143
  }
1163
1144
  Util.hide_tips();
1164
1145
  });
1165
1146
  },
1166
1147
 
1148
+ /**
1149
+ * 基金数据渲染
1150
+ */
1151
+ render_public_fund: function(j) {
1152
+ let _html = [], total_public_fund = 0, total_stock_num = 0, total_market_capital = 0;
1153
+ j["data"] = j["data"] ? j["data"] : [];
1154
+ j["data"].forEach(function (item) {
1155
+ total_public_fund++;
1156
+ total_stock_num += item["stock_num"];
1157
+ total_market_capital += item["market_capital"];
1158
+ let public_date = "--";
1159
+ if (item["public_date"] > 0) {
1160
+ public_date = Util.seconds_to_format(item["public_date"], "%Y-%m-%d");
1161
+ }
1162
+ let net = item["net"];
1163
+ let cls = Util.text_color(item["change_percent"])
1164
+ if (cls !== "") {
1165
+ net = "<b class='" + cls + "'>" + net + "(" + Util.to_float(item["change_percent"], 2) + "%)</b>";
1166
+ }
1167
+ _html.push("<tr class='", (($.inArray(item["fund_code"], j["etf_code_list"]) > -1) ? "danger" : ""), "'>");
1168
+ _html.push("<td>", total_public_fund, "</td>");
1169
+ _html.push("<td>", Util.pack_html_link('https://fund.eastmoney.com/' + item["fund_code"] + '.html', item["fund_code"]), "</td>");
1170
+ _html.push("<td title='基金概况'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + item["fund_code"] + '.html', item["fund_name"]), "</td>");
1171
+ _html.push("<td>", net, "</td>");
1172
+ _html.push("<td>", item["assets"], "亿</td>");
1173
+ _html.push("<td>", item["fund_type"], "</td>");
1174
+ _html.push("<td>", item["invest_type"], "</td>");
1175
+ _html.push("<td>", Util.pack_fund_administrator(item), "</td>");
1176
+ _html.push("<td>", public_date, "</td>");
1177
+ _html.push("<td data-val='", item["stock_num"], "' title='", item["stock_num"], "'>", Util.to_unit(item["stock_num"], 3), "股</td>");
1178
+ _html.push("<td data-val='", item["market_capital"], "' title='", item["market_capital"], "'>", Util.to_unit(item["market_capital"], 3), "</td>");
1179
+ _html.push("<td><a class='link_cls' data-toggle='modal' data-target='.public_fund_modal' data-val='", item["fund_code"], "'>详细</a></td>");
1180
+ _html.push("</tr>");
1181
+ });
1182
+ Util.render_table_html("public_fund_table_body", _html);
1183
+ let public_fund_tips = "";
1184
+ if (j["cur_fund_num"]) {
1185
+ total_public_fund = Util.pack_html_link(Util.get_url("trend_fund_hold"), '<span class="label label-info">' + j["cur_fund_num"] + '</span>');
1186
+ 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>市值';
1187
+ } else {
1188
+ total_public_fund = Util.pack_html_link(Util.get_url("trend_fund_hold"), '<span class="label label-info">' + total_public_fund + '</span>');
1189
+ 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>市值';
1190
+ }
1191
+ $("#public_fund_tips").html(public_fund_tips);
1192
+ },
1193
+
1194
+ /**
1195
+ * 前一季度日时间
1196
+ */
1197
+ get_prev_public_fund_date: function(element_id, current_date) {
1198
+ let prev_date = 0;
1199
+ $("#" + element_id).find("option").each(function() {
1200
+ if (prev_date === 0) {
1201
+ let p_date = $(this).val();
1202
+ if (Util.regexp_date_yyyy_mm_dd(p_date)) {
1203
+ p_date = Util.format_to_second(p_date);
1204
+ if (current_date > p_date) {
1205
+ prev_date = p_date;
1206
+ }
1207
+ }
1208
+ }
1209
+ });
1210
+ return prev_date;
1211
+ },
1212
+
1167
1213
  /**
1168
1214
  * 公募持股变化
1169
1215
  * @param code
@@ -1191,9 +1237,21 @@ const Util = {
1191
1237
  price_data.push(item["price"]);
1192
1238
  _html.push("<tr>");
1193
1239
  _html.push("<td>", Util.pack_html_link("https://data.eastmoney.com/zlsj/detail/" + date_format + "-1-" + code + ".html", date_format), "</td>");
1194
- _html.push("<td>", item["price"], "</td>");
1195
- _html.push("<td data-val='", item["stock_num"], "' title='", item["stock_num"], "'>", Util.to_unit(item["stock_num"], 3), "股</td>");
1196
- _html.push("<td>", item["fund_num"], "</td>");
1240
+ if (item["pre_price"]) {
1241
+ _html.push("<td>", Util.digit_compare_trend(item["price"], item["pre_price"]), "</td>");
1242
+ } else {
1243
+ _html.push("<td>", item["price"], "</td>");
1244
+ }
1245
+ let stock_num_rate = "";
1246
+ if (item["pre_stock_num"]) {
1247
+ stock_num_rate = "(" + Util.year_price_rate(item["stock_num"], item["pre_stock_num"], 1) + ")";
1248
+ }
1249
+ _html.push("<td data-val='", item["stock_num"], "' title='", item["stock_num"], "'>", Util.to_unit(item["stock_num"], 3), "股", stock_num_rate, "</td>");
1250
+ let fund_num_rate = "";
1251
+ if (item["pre_fund_num"]) {
1252
+ fund_num_rate = "(" + Util.year_price_rate(item["fund_num"], item["pre_fund_num"], 1) + ")";
1253
+ }
1254
+ _html.push("<td>", item["fund_num"], fund_num_rate, "</td>");
1197
1255
  let market_capital = item["price"] * item["stock_num"];
1198
1256
  _html.push("<td data-val='", market_capital, "' title='", market_capital, "'>", Util.to_unit(market_capital, 4), "</td>");
1199
1257
  _html.push("</tr>");