sbd-npm 1.3.78 → 1.3.80

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/stock_basics.js +77 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.78",
3
+ "version": "1.3.80",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -1123,6 +1123,78 @@ let Stock = {
1123
1123
  }
1124
1124
  });
1125
1125
  Stock["margin_month_flow_chart"] = Util.chart_basic_bar(Stock["margin_month_flow_chart"], "margin_month_flow_bar_chart", date_data, flow_data, "增幅(单位:万)", color_data);
1126
+ if ($("#margin_modal_body").length === 0) {
1127
+ Stock.fetch_margin_modal();
1128
+ }
1129
+ Util.hide_tips();
1130
+ });
1131
+ },
1132
+
1133
+ fetch_margin_modal: function () {
1134
+ Util.init_modal_skeleton("margin_modal", '');
1135
+ let mm_obj = $('#margin_modal');
1136
+ mm_obj.on('shown.bs.modal', function (e) {
1137
+ let url = $("#margin_panel_title").find("a").first().attr("href");
1138
+ let title = Util.pack_html_link(url, "[" + Stock["name"] + "]融资余额明细数据");
1139
+ $("#margin_modal_title").html(title + "<span style='color: #BDBDBD;' id='margin_modal_summary'></span>");
1140
+ Util.init_table_skeleton({
1141
+ "element_id": "margin_modal_body",
1142
+ "caption": "none",
1143
+ "head_cols": [
1144
+ {"name": "日期", "class": "info", "table_sort": 1},
1145
+ {"name": "融资余额", "table_sort": 1, "title": "本日融资余额 = 前日融资余额 + 本日融资买入额 - 本日融资偿还额"},
1146
+ {"name": "融资余额增值", "table_sort": 1, "title": "当天融资余额跟前一天融资余额的差值,即`本日融资买入额` - `本日融资偿还额`"},
1147
+ {"name": "融资买入额", "table_sort": 1},
1148
+ {"name": "融资偿还额", "table_sort": 1, "title": "本日融资偿还额 = 本日直接还款额 + 本日卖券还款额 + 本日融资强制平仓额 + 本日融资正权益调整 - 本日融资负权益调整"},
1149
+ {"name": "融券余额", "table_sort": 1, "title": "本日融资融券余额 = 本日融资余额 + 本日融券余量金额"},
1150
+ {"name": "融券余量", "table_sort": 1, "title": "本日融券余量 = 前日融券余量 + 本日融券卖出数量 - 本日融券偿还量"},
1151
+ {"name": "收盘价", "table_sort": 1},
1152
+ {"name": "涨跌", "table_sort": 1},
1153
+ ]
1154
+ });
1155
+ Util.post("/stock/" + Stock["code"], {action: "margin_detail"}, function (j) {
1156
+ let _html = [];
1157
+ j["data"].forEach(function (item, index) {
1158
+ _html.push("<tr>");
1159
+ _html.push("<td>", Util.seconds_to_format(item["date"], "%Y-%m-%d"), "</td>");
1160
+ _html.push("<td title='", item["rzye"], "' data-val='", item["rzye"], "'>", Util.to_unit(item["rzye"], 3), "</td>");
1161
+ let net_rzye = "--", gap_rzye = 0;
1162
+ if (j["data"][index + 1] && j["data"][index + 1]["rzye"]) {
1163
+ gap_rzye = item["rzye"] - j["data"][index + 1]["rzye"];
1164
+ if (gap_rzye > 0) {
1165
+ net_rzye = "<b class='text-danger'>+" + Util.to_unit(gap_rzye, 3) + "</b>";
1166
+ } else if (gap_rzye < 0) {
1167
+ net_rzye = "<b class='text-success'>" + Util.to_unit(gap_rzye, 3) + "</b>";
1168
+ }
1169
+ }
1170
+ _html.push("<td title='", gap_rzye, "' data-val='", gap_rzye, "'>", net_rzye, "</td>");
1171
+ _html.push("<td title='", item["rzmre"], "' data-val='", item["rzmre"], "'>", Util.to_unit(item["rzmre"], 3), "</td>");
1172
+ _html.push("<td title='", item["rzche"], "' data-val='", item["rzche"], "'>", Util.to_unit(item["rzche"], 3), "</td>");
1173
+ _html.push("<td title='", item["rqye"], "' data-val='", item["rqye"], "'>", (item["rqye"] > 0 ? Util.to_unit(item["rqye"], 3) : "--"), "</td>");
1174
+ _html.push("<td title='", item["rqyl"], "' data-val='", item["rqyl"], "'>", Util.to_unit(item["rqyl"], 3), "</td>");
1175
+ let text_color = Util.text_color(item["p_change"]);
1176
+ _html.push("<td><b class='", text_color, "'>", item["close"], "</b></td>");
1177
+ item["p_change"] = item["p_change"] > 0 ? ("+" + Util.to_float(item["p_change"], 2)) : Util.to_float(item["p_change"], 2);
1178
+ _html.push("<td><b class='", text_color, "'>", item["p_change"], "%</b></td>");
1179
+ _html.push("</tr>");
1180
+ });
1181
+ Util.render_table_html("margin_modal_body_body", _html);
1182
+ if (j["data"].length > 1) {
1183
+ let margin_modal_summary = " [当前最新(" + Util.seconds_to_format(j["data"][0]["date"], "%Y-%m-%d") + ")的融资余额: <b class='text-info'>" + Util.to_unit(j["data"][0]["rzye"]) + "</b>";
1184
+ let gap_rzye = j["data"][0]["rzye"] - j["data"][1]["rzye"];
1185
+ if (gap_rzye > 0) {
1186
+ margin_modal_summary += ",相对于前一天余额增加 <b class='text-danger'>+" + Util.to_unit(gap_rzye) + "</b>";
1187
+ } else if (gap_rzye < 0) {
1188
+ margin_modal_summary += ",相对于前一天余额减少 <b class='text-success'>" + Util.to_unit(gap_rzye) + "</b>";
1189
+ }
1190
+ margin_modal_summary += "]";
1191
+ $("#margin_modal_summary").html(margin_modal_summary);
1192
+ }
1193
+ Util.hide_tips();
1194
+ });
1195
+ });
1196
+ mm_obj.on('hidden.bs.modal', function () {
1197
+ Util.set_table_loading("margin_modal_body_body");
1126
1198
  Util.hide_tips();
1127
1199
  });
1128
1200
  },
@@ -1221,14 +1293,14 @@ let Stock = {
1221
1293
  _html.push("</tr>");
1222
1294
  });
1223
1295
  if (j["data"].length > 1) {
1224
- let hkex_holding_modal_summary = " (当前最新的持股比例<b class='text-info'>(" + j["data"][0]["ratio"] + "%)</b>";
1296
+ let hkex_holding_modal_summary = " [当前最新(" + Util.seconds_to_format(j["data"][0]["date"], "%Y-%m-%d") + ")的持股比例: <b class='text-info'>" + j["data"][0]["ratio"] + "%</b>";
1225
1297
  let gap_volume = j["data"][0]["volume"] - j["data"][1]["volume"];
1226
1298
  if (gap_volume > 0) {
1227
- hkex_holding_modal_summary += "相对于前一天持股增加 <b class='text-danger'>+" + Util.to_ten_thousand(gap_volume) + "万股</b>";
1299
+ hkex_holding_modal_summary += ",相对于前一天持股增加 <b class='text-danger'>+" + Util.to_ten_thousand(gap_volume) + "万股</b>";
1228
1300
  } else if (gap_volume < 0) {
1229
- hkex_holding_modal_summary += "相对于前一天持股减少 <b class='text-success'>" + Util.to_ten_thousand(gap_volume) + "万股</b>";
1301
+ hkex_holding_modal_summary += ",相对于前一天持股减少 <b class='text-success'>" + Util.to_ten_thousand(gap_volume) + "万股</b>";
1230
1302
  }
1231
- hkex_holding_modal_summary += ")";
1303
+ hkex_holding_modal_summary += "]";
1232
1304
  $("#hkex_holding_modal_summary").html(hkex_holding_modal_summary);
1233
1305
  }
1234
1306
  Util.render_table_html("hkex_holding_modal_body_body", _html);
@@ -1236,7 +1308,7 @@ let Stock = {
1236
1308
  });
1237
1309
  });
1238
1310
  hhm_obj.on('hidden.bs.modal', function () {
1239
- $("#hkex_holding_modal_body").html("Loading...");
1311
+ Util.set_table_loading("hkex_holding_modal_body_body");
1240
1312
  Util.hide_tips();
1241
1313
  });
1242
1314
  },