sbd-npm 1.3.16 → 1.3.18

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 +74 -21
  3. package/util.js +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.16",
3
+ "version": "1.3.18",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -1177,51 +1177,104 @@ let Stock = {
1177
1177
  };
1178
1178
  Util.post("/stock/" + Stock["code"], payload, function (j) {
1179
1179
  Stock["hkex_holding_chart"].hideLoading();
1180
- let date_data = [];
1181
- let volume_data = [];
1182
- let price_data = [];
1180
+ let date_data = [], volume_data = [], price_data = [];
1183
1181
  j["data"].forEach(function (item) {
1184
1182
  date_data.push(Util.seconds_to_format(item["date"], "%Y-%m-%d"));
1185
1183
  volume_data.push(item["volume"]);
1186
1184
  price_data.push(item["price"]);
1187
1185
  });
1188
- let hhs_obj = $("#hkex_holding_summary");
1189
- let hkex_holding_summary = "[" + Util.pack_html_link(j["url"], hhs_obj.text()) + "]";
1186
+ let hkex_holding_summary = "[" + Util.pack_html_link(j["url"] + "&code=" + Stock["code"] + "&name=" + Stock["name"], Stock["name"]) + "]";
1190
1187
  if (j["latest"].length > 0) {
1191
- let circulation_stock = $("#circulation_stock").attr("data-val");
1192
- let latest_html = "";
1193
- if (j["latest"].length === 1) {
1194
- let holding_num = Util.to_hundred_million(j["latest"][0]["volume"], 3);
1195
- let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1196
- latest_html = "最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): " + holding_num + "亿股, 占 <b>" + holding_rate + "%</b> 流通股, ";
1197
- } else if (j["latest"].length === 2) {
1188
+ let latest_html = "最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): <span style='color: #FFF;' class='label label-info'>" + Util.to_hundred_million(j["latest"][0]["volume"], 4) + "</span>亿股";
1189
+ let dist_tips = "";
1190
+ if (j["latest"].length === 2) {
1198
1191
  let d1 = j["latest"][0];
1199
1192
  let d2 = j["latest"][1];
1200
1193
  let difference = d1["volume"] - d2["volume"];
1201
- let dist_tips = "";
1202
1194
  if (difference > 0) {
1203
1195
  dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["volume"])) + "股' style='color: #a94442;'>+" + Util.strip_html(Util.to_unit(difference)) + "股</b>)";
1204
1196
  } else if (difference < 0) {
1205
1197
  dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["volume"])) + "股' style='color: #3c763d;'>" + Util.strip_html(Util.to_unit(difference)) + "股</b>)";
1206
1198
  }
1207
- let holding_num = Util.to_hundred_million(d1["volume"]);
1208
- let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1209
- latest_html = "最新(" + Util.seconds_to_format(d1["date"], "%Y-%m-%d") + "): " + holding_num + "亿股" + dist_tips + ", 占 <b>" + holding_rate + "%</b> 流通股, ";
1210
1199
  }
1211
- hkex_holding_summary += (latest_html + ' 最高: ' + Util.to_unit(j["high"]["volume"]) + '股(' + Util.seconds_to_format(j["high"]["date"], "%Y-%m-%d") +
1212
- ') 最低: ' + Util.to_unit(j["low"]["volume"]) + '(' + Util.seconds_to_format(j["low"]["date"], "%Y-%m-%d") + ')');
1200
+ latest_html += dist_tips + ", 占 <span style='color: #FFF;' class='label label-info'>" + j["latest"][0]["ratio"] + "%</span> 流通股, ";
1201
+ hkex_holding_summary += (latest_html + ' 最高: <span style="color: #FFF;" class="label label-danger">' + Util.strip_html(Util.to_unit(j["high"]["volume"])) + '股</span>(' + Util.seconds_to_format(j["high"]["date"], "%Y-%m-%d") +
1202
+ ') 最低: <span style="color: #FFF;" class="label label-success">' + Util.strip_html(Util.to_unit(j["low"]["volume"])) + '股</span>(' + Util.seconds_to_format(j["low"]["date"], "%Y-%m-%d") + ')');
1213
1203
  }
1214
- hhs_obj.html(hkex_holding_summary);
1204
+ $("#hkex_holding_summary").html(hkex_holding_summary);
1215
1205
  Stock["hkex_holding_chart"] = Util.multi_axis_line(Stock["hkex_holding_chart"], "hkex_holding_line_canvas", date_data, '持股数', volume_data, '股价', price_data);
1216
- let flow_data = [];
1206
+ let flow_data = [], color_data = [];
1217
1207
  date_data = [];
1218
- let color_data = [];
1219
1208
  j["flow_data"].forEach(function (item) {
1220
1209
  date_data.push(item["date"]);
1221
1210
  flow_data.push(item["value"]);
1222
1211
  color_data.push(item["value"] > 0 ? "#E74C3C" : "#1ABB9C");
1223
1212
  });
1224
1213
  Stock["hkex_holding_month_flow_chart"] = Util.chart_basic_bar(Stock["hkex_holding_month_flow_chart"], "hkex_holding_month_flow_chart", date_data, flow_data, "增幅", color_data);
1214
+ if ($("#hkex_holding_modal_body").length === 0) {
1215
+ Stock.fetch_hkex_holding_modal();
1216
+ }
1217
+ Util.hide_tips();
1218
+ });
1219
+ },
1220
+
1221
+ fetch_hkex_holding_modal: function () {
1222
+ Util.init_modal_skeleton("hkex_holding_modal", '');
1223
+ $("#hkex_holding_modal_title").html("[" + Stock["name"] + "]港股通持股明细数据<span style='color: #BDBDBD;' id='hkex_holding_modal_summary'></span>");
1224
+ let hhm_obj = $('#hkex_holding_modal');
1225
+ hhm_obj.on('shown.bs.modal', function (e) {
1226
+ Util.init_table_skeleton({
1227
+ "element_id": "hkex_holding_modal_body",
1228
+ "caption": "none",
1229
+ "head_cols": [
1230
+ {"name": "日期", "class": "info", "table_sort": 1},
1231
+ {"name": "持股量(万股)", "table_sort": 1},
1232
+ {"name": "净买入股数", "table_sort": 1},
1233
+ {"name": "收盘价", "table_sort": 1},
1234
+ {"name": "涨跌", "table_sort": 1},
1235
+ {"name": "持股比例", "table_sort": 1, "title": "内地港股通账户持仓股数 / 流通股本数"},
1236
+ ]
1237
+ });
1238
+ Util.post("/stock/{{ stock['code'] }}", {action: "hk_stock_exchange"}, function (j) {
1239
+ let _html = [];
1240
+ j["data"].forEach(function (item, index) {
1241
+ _html.push("<tr>");
1242
+ _html.push("<td>", Util.seconds_to_format(item["date"], "%Y-%m-%d"), "</td>");
1243
+ _html.push("<td title='", item["volume"], "' data-val='", item["volume"], "'>", Util.to_ten_thousand(item["volume"], 4), "万股</td>");
1244
+ let net_volume = "--", gap_volume = 0;
1245
+ if (j["data"][index + 1] && j["data"][index + 1]["volume"]) {
1246
+ gap_volume = item["volume"] - j["data"][index + 1]["volume"];
1247
+ if (gap_volume > 0) {
1248
+ net_volume = "<b class='text-danger'>+" + Util.to_ten_thousand(gap_volume, 4) + "万股</b>";
1249
+ } else if (gap_volume < 0) {
1250
+ net_volume = "<b class='text-success'>" + Util.to_ten_thousand(gap_volume, 4) + "万股</b>";
1251
+ }
1252
+ }
1253
+ _html.push("<td data-val='", gap_volume, "'>", net_volume, "</td>");
1254
+ let text_color = Util.text_color(item["p_change"]);
1255
+ _html.push("<td><b class='", text_color, "'>", item["close"], "</b></td>");
1256
+ item["p_change"] = item["p_change"] > 0 ? ("+" + item["p_change"]) : item["p_change"];
1257
+ _html.push("<td><b class='", text_color, "'>", item["p_change"], "%</b></td>");
1258
+ _html.push("<td>", item["ratio"], "%</td>");
1259
+ _html.push("</tr>");
1260
+ });
1261
+ if (j["data"].length > 1) {
1262
+ let hkex_holding_modal_summary = " (当前最新的持股比例<b class='text-info'>(" + j["data"][0]["ratio"] + "%)</b>";
1263
+ let gap_volume = j["data"][0]["volume"] - j["data"][1]["volume"];
1264
+ if (gap_volume > 0) {
1265
+ hkex_holding_modal_summary += "相对于前一天持股增加 <b class='text-danger'>+" + Util.to_ten_thousand(gap_volume) + "万股</b>";
1266
+ } else if (gap_volume < 0) {
1267
+ hkex_holding_modal_summary += "相对于前一天持股减少 <b class='text-success'>" + Util.to_ten_thousand(gap_volume) + "万股</b>";
1268
+ }
1269
+ hkex_holding_modal_summary += ")";
1270
+ $("#hkex_holding_modal_summary").html(hkex_holding_modal_summary);
1271
+ }
1272
+ Util.render_table_html("hkex_holding_modal_body_body", _html);
1273
+ Util.hide_tips();
1274
+ });
1275
+ });
1276
+ hhm_obj.on('hidden.bs.modal', function () {
1277
+ $("#hkex_holding_modal_body").html("Loading...");
1225
1278
  Util.hide_tips();
1226
1279
  });
1227
1280
  },
package/util.js CHANGED
@@ -1091,8 +1091,8 @@ const Util = {
1091
1091
  Util.render_type_option($("#stock_category_industry"), j["data"], "industry", Util.render_stock_category_html);
1092
1092
  Util.render_type_option($("#stock_category_area"), j["data"], "area", Util.render_stock_category_html);
1093
1093
  Util.render_stock_category_html();
1094
- if (j["concept_url"]) {
1095
- $("#stock_category_remark_title").html(Util.pack_html_link(j["concept_url"], "备注<i class='glyphicon glyphicon-link'></i>"));
1094
+ if (j["portfolio_url"]) {
1095
+ $("#stock_category_remark_title").html(Util.pack_html_link(j["portfolio_url"], "备注<i class='glyphicon glyphicon-link'></i>"));
1096
1096
  }
1097
1097
  Util.hide_tips();
1098
1098
  });
@@ -2210,6 +2210,7 @@ const Util = {
2210
2210
  if (sort_type === Obj[sort_key].toString()) {
2211
2211
  let sort_cls = Obj[sort_order] === 0 ? "fa-sort-desc" : "fa-sort-asc";
2212
2212
  $("<i class='fa fa-fw " + sort_cls + "'></i>").insertAfter($(this));
2213
+ $(this).parent().addClass("info");
2213
2214
  } else {
2214
2215
  $("<i class='fa fa-fw fa-sort'></i>").insertAfter($(this));
2215
2216
  }