Greasy Fork 支持简体中文。

新式双低转债轮动评分

从kirk91的双低转债轮动评分复制过来修改的新式双低评分。按照 转股溢价 + 纯债溢价 = 转债价格*2-转股价值-纯债价值 计算评分, 并将结果渲染在已有的数据表格上, 并支持按照评分字段进行排序

目前為 2020-07-17 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 新式双低转债轮动评分
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description 从kirk91的双低转债轮动评分复制过来修改的新式双低评分。按照 转股溢价 + 纯债溢价 = 转债价格*2-转股价值-纯债价值 计算评分, 并将结果渲染在已有的数据表格上, 并支持按照评分字段进行排序
  6. // @author kirk91
  7. // @match *://www.jisilu.cn/data/cbnew/
  8. // @match *://jisilu.cn/data/cbnew/
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. function insertScoreHeader() {
  14. var header_html = '<th style="width: 70px; white-space: nowrap;" title="新式双低=转股溢价+纯债溢价=转债价格*2-转股价值-纯债价值" class="header sticky">新式双低</th>';
  15. $('#flex_cb thead th:last-child').before(header_html);
  16. }
  17.  
  18. function insertScoreData() {
  19. $("#flex_cb tbody tr").each(function(index){
  20. var bond_id = $(this).find("td[data-name|=bond_id] a").text()
  21. var bond_name = $(this).find("td[data-name|=bond_nm]").text()
  22. var price_text = $(this).find("td[data-name|=price]").text();
  23. var convert_value = $(this).find("td[data-name|=convert_value]").text();
  24. var bond_value = $(this).find("td[data-name|=bond_value]").text();
  25. var score = (parseFloat(price_text) * 2 - parseFloat(bond_value) - parseFloat(convert_value)).toFixed(2);
  26. var score_html = '<td data-name="score" style="width:40px;white-space: nowrap">' + score + '</td>';
  27. $(this).find("td[data-name|=cbOpt]").before(score_html);
  28. });
  29. }
  30.  
  31. function insertIdHeader() {
  32. var header_html = '<th style="width: 30px; white-space: nowrap;" title="自增id" class="header sticky" sorter=false>序号</th>';
  33. $('#flex_cb thead tr:last').prepend(header_html);
  34. }
  35.  
  36. function insertIdData() {
  37. $("#flex_cb tbody tr").each(function(index){
  38. var html = '<td data-name="id" style="width:20px;white-space: nowrap">' + (index+1) + '</td>';
  39. $(this).prepend(html);
  40. });
  41. }
  42.  
  43. (function() {
  44. 'use strict';
  45.  
  46. // only match #cb page
  47. if (location.hash != "#cb") {
  48. return;
  49. }
  50.  
  51. // TODO: replace it with flex_cb table data ready event.
  52. setTimeout(function(){
  53. // id
  54. insertIdHeader();
  55. insertIdData();
  56.  
  57. // score
  58. insertScoreHeader();
  59. insertScoreData();
  60.  
  61. // attach sorter to the new header
  62. // unbind the old click event handlers
  63. $("#flex_cb thead th").unbind("click");
  64. // rebuild the table sorter
  65. $('#flex_cb').tablesorter({widgets: ['zebra']});
  66. // remove the client event handler of id field
  67. $('#flex_cb thead th:first').unbind("click");
  68. }, 1500);
  69.  
  70. $('#flex_cb').on('sortEnd', function(){
  71. // keep the id
  72. $(this).find('tbody tr').each(function(index){
  73. $(this).find('td:first').text(index+1);
  74. });
  75. });
  76. $('#flex_cb').on("reload", function(){
  77. insertIdData();
  78. insertScoreData();
  79. });
  80. })();