sbd-npm 1.2.75 → 1.2.77

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 -44
  3. package/util.js +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.75",
3
+ "version": "1.2.77",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -98,7 +98,7 @@ let Stock = {
98
98
  Stock.fetch_big_deal();
99
99
  break;
100
100
  case "rps":
101
- Stock.fetch_rps_data();
101
+ Util.fetch_rps_data(Stock.code);
102
102
  break;
103
103
  case "hist_trade": // 个股历史交易记录
104
104
  if (Stock.hist_start_date && Stock.hist_end_date) {
@@ -414,49 +414,6 @@ let Stock = {
414
414
  }
415
415
  },
416
416
 
417
- fetch_rps_data: function () {
418
- Util.show_loading();
419
- Util.init_table_skeleton({
420
- "element_id": "rps_table",
421
- "head_cols": [
422
- {"name": "时间"},
423
- {"name": "RPS20", "tooltip": "20日股价相对强度,表示过去20个交易日内,该股票的价格涨幅超过了市场上多少的股票,该值为85,表示该股在过去20日内的价格涨幅超过了市场上85%的股票"},
424
- {"name": "20日涨跌"},
425
- {"name": "RPS60", "tooltip": "60日股价相对强度,表示过去60个交易日内,该股票的价格涨幅超过了市场上多少的股票,该值为85,表示该股在过去60日内的价格涨幅超过了市场上85%的股票"},
426
- {"name": "60日涨跌"},
427
- {"name": "RPS120", "tooltip": "120日股价相对强度,表示过去120个交易日内,该股票的价格涨幅超过了市场上多少的股票,该值为85,表示该股在过去120日内的价格涨幅超过了市场上85%的股票"},
428
- {"name": "120日涨跌"},
429
- ]
430
- });
431
- Util.post("/stock/" + Stock.code, {action: "rps"}, function (j) {
432
- let _html = [];
433
- j["data"].forEach(function (item) {
434
- _html.push("<tr>");
435
- _html.push("<td>", Util.seconds_to_format(item["date"], "%Y-%m-%d"), "</td>");
436
- _html.push("<td style='background-color: ", item["rps20_color"], "'>", item["rps20"], "</td>");
437
- _html.push("<td>", Util.parse_ratio(item["change_percent20"] * 100, 2), "</td>");
438
- _html.push("<td style='background-color: ", item["rps60_color"], "'>", item["rps60"], "</td>");
439
- _html.push("<td>", Util.parse_ratio(item["change_percent60"] * 100, 2), "</td>");
440
- _html.push("<td style='background-color: ", item["rps120_color"], "'>", item["rps120"], "</td>");
441
- _html.push("<td>", Util.parse_ratio(item["change_percent120"] * 100, 2), "</td>");
442
- _html.push("</tr>");
443
- });
444
- if (_html.length > 0) {
445
- Util.render_table_html("rps_table_body", _html);
446
- } else {
447
- let now = Util.now();
448
- if ((now - Stock.ttm_second) < Util.one_year_second) {
449
- let obj = $("#rps_table_body");
450
- let td_num = obj.parent().find('thead td').length;
451
- obj.html('<tr><td colspan="' + td_num + '">上市时间(' + Util.seconds_to_format(Stock.ttm_second, "%Y-%m-%d") + ')不足一年不做统计!</td></tr>');
452
- } else {
453
- Util.render_table_html("rps_table_body", []);
454
- }
455
- }
456
- Util.hide_tips();
457
- });
458
- },
459
-
460
417
  fetch_holder_top: function () {
461
418
  Util.show_loading();
462
419
  Util.init_table_skeleton({
package/util.js CHANGED
@@ -189,6 +189,7 @@ const Util = {
189
189
  post: function (url, payload, callback, data_type = "json") {
190
190
  $.ajax({
191
191
  url: url,
192
+ async: true,
192
193
  type: 'POST',
193
194
  dataType: data_type,
194
195
  //headers: {'X-CSRFToken': Util.get_cookie('csrftoken')},
@@ -899,6 +900,43 @@ const Util = {
899
900
  });
900
901
  },
901
902
 
903
+ /**
904
+ * 股价相对强度(Relative Price Strength)
905
+ * @param code
906
+ */
907
+ fetch_rps_data: function (code) {
908
+ Util.show_loading();
909
+ $("#rps_head").html(Util.pack_html_link("https://bafybeibav23h2xcyzevh4o26kb7mpz5j2ra3uryqycpkstuvsddfjgffwy.ipfs.dweb.link/欧奈尔RPS指标.html", "股价相对强度(Relative Price Strength)"));
910
+ Util.init_table_skeleton({
911
+ "element_id": "rps_table",
912
+ "head_cols": [
913
+ {"name": "时间"},
914
+ {"name": "RPS20", "tooltip": "20日股价相对强度,表示过去20个交易日内,该股票的价格涨幅超过了市场上多少的股票,该值为85,表示该股在过去20日内的价格涨幅超过了市场上85%的股票"},
915
+ {"name": "20日涨跌"},
916
+ {"name": "RPS60", "tooltip": "60日股价相对强度,表示过去60个交易日内,该股票的价格涨幅超过了市场上多少的股票,该值为85,表示该股在过去60日内的价格涨幅超过了市场上85%的股票"},
917
+ {"name": "60日涨跌"},
918
+ {"name": "RPS120", "tooltip": "120日股价相对强度,表示过去120个交易日内,该股票的价格涨幅超过了市场上多少的股票,该值为85,表示该股在过去120日内的价格涨幅超过了市场上85%的股票"},
919
+ {"name": "120日涨跌"},
920
+ ]
921
+ });
922
+ Util.post("/stock/" + code, {action: "rps"}, function (j) {
923
+ let _html = [];
924
+ j["data"].forEach(function (item) {
925
+ _html.push("<tr>");
926
+ _html.push("<td>", Util.seconds_to_format(item["date"], "%Y-%m-%d"), "</td>");
927
+ _html.push("<td style='background-color: ", item["rps20_color"], "'>", item["rps20"], "</td>");
928
+ _html.push("<td>", Util.parse_ratio(item["change_percent20"] * 100, 2), "</td>");
929
+ _html.push("<td style='background-color: ", item["rps60_color"], "'>", item["rps60"], "</td>");
930
+ _html.push("<td>", Util.parse_ratio(item["change_percent60"] * 100, 2), "</td>");
931
+ _html.push("<td style='background-color: ", item["rps120_color"], "'>", item["rps120"], "</td>");
932
+ _html.push("<td>", Util.parse_ratio(item["change_percent120"] * 100, 2), "</td>");
933
+ _html.push("</tr>");
934
+ });
935
+ Util.render_table_html("rps_table_body", _html);
936
+ Util.hide_tips();
937
+ });
938
+ },
939
+
902
940
  /**
903
941
  * 初始分类股票的显示表格
904
942
  * @param stock_category