admin
2025-08-22 ec060ce444cdd1c48a54686cadbc8950478eedcf
kp_html/kp/js/http.js
@@ -1,3 +1,16 @@
function is_trade_time() {
      var nowdate = new Date();
      h = nowdate.getHours();
      m = nowdate.getMinutes();
      total_m = h * 60 + m;
      if ((total_m >= (9 * 60 + 25) && total_m <= (11 * 60 + 30)) || (total_m >= 13 * 60 && total_m <= 15 *
            60)) {
         return true;
      } else {
         return false;
      }
}
var http_util = {
   request_callback: {},
   getQueryString: function(name) {
@@ -53,6 +66,18 @@
      }, callback);
   },
   get_blocks_in_money_info: function(type, callback) {
      http_util.http_request("/get_blocks_in_money_info", {
         type: type
      }, callback);
   },
   get_place_order_records: function(day, callback) {
      http_util.http_request("/get_place_order_records", {
         day: day
      }, callback);
   },
   get_limit_up_list: function(code, day, callback) {
      var params = {
         code: code
@@ -64,6 +89,15 @@
      http_util.http_request("/kpl/get_limit_up_list", params, callback);
   },
   get_limit_up_statistic_infos: function(day, callback) {
      var params = {};
      if (day) {
         params.day = day;
      }
      http_util.http_request("/kpl/get_limit_up_statistic_infos", params, callback);
   },
   get_plate_info: function(code, callback) {
      http_util.http_request("/kpl/get_plate_info", {
@@ -130,6 +164,15 @@
            type_desc = "移除暂不买"
            //移除想买
            break;
         case 8:
            data.type = 441;
            data.data.plates = [plate]
            type_desc = "加绿"
            break;
         case 9:
            data.type = 442;
            type_desc = "移绿"
            break;
      }
      console.log("socket请求", data)
@@ -150,10 +193,24 @@
   },
   get_want_codes: function(plate, callback) {
      pyjs.socket_request(JSON.stringify({
      http_util.socket_request(JSON.stringify({
         type: 403,
         plate: plate
      }), function(result) {
         result = JSON.parse(result);
         if (result.code == 0) {
            callback(result);
         }
      });
   },
   get_green_codes: function(callback) {
      var data = {
         type: 443
      };
      var sign = http_util.get_sign(data);
      data['sign'] = sign;
      http_util.socket_request(JSON.stringify(data), function(result) {
         console.log("结果:", result);
         result = JSON.parse(result);
         if (result.code == 0) {
            callback(result);
@@ -185,6 +242,7 @@
      md5Hash = md5(params_str);
      return md5Hash;
   },
   // 撤单
   cancel_order: function(code, success) {
      var data = {
         type: "cancel_order",
@@ -201,10 +259,37 @@
         }
      });
   },
   // 同步交易数据
   sync_trade_data: function(type, success) {
      var data = {
         type: "sync_trade_data",
         data: {
            "type": type
         }
      };
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         success(result);
      });
   },
   forbidden_plate: function(plate, callback) {
      http_util.http_request("/kpl/forbidden_plate", {
         plate: plate
      }, callback);
   },
   delete_forbidden_plate: function(plate, callback) {
      http_util.http_request("/kpl/del_forbidden_plate", {
         plate: plate
      }, callback);
   },
   list_forbidden_plate: function(callback) {
      http_util.http_request("/kpl/list_forbidden_plate", {}, callback);
   },
   list_deleted_forbidden_plate: function(callback) {
      http_util.http_request("/kpl/list_deleted_forbidden_plate", {}, callback);
   },
   // 获取板块下的代码
   get_plate_codes: function(plate, day, callback) {
@@ -216,6 +301,16 @@
      }
      http_util.http_request("/kpl/get_plate_codes", params, callback);
   },
   get_plate_codes_new: function(plate, day, callback) {
      var params = {
         plate: plate
      };
      if (day) {
         params.day = day;
      }
      http_util.http_request("/kpl/get_plate_codes_new", params, callback);
   },
   get_open_limit_up_count_rank(code, callback) {
@@ -243,13 +338,18 @@
   },
   //获取L2的数据
   get_l2_datas: function(code, date, callback) {
   get_l2_datas: function(code, date, end_index, fast_mode, callback) {
      var params = {
         code: code
         code: code,
         fast: fast_mode
      }
      if (date) {
         params['date'] = date
      }
      if (end_index != null && end_index) {
         params['end_index'] = parseInt(end_index)
      }
      console.log("L2参数", params);
      http_util.http_request("/get_l2_datas", params, callback);
@@ -295,12 +395,11 @@
      data = {
         type: "common",
         data: {
            ctype: "get_delegated_buy_code_infos"
            ctype: "get_delegated_buy_code_infos_v2"
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(data), function(result) {
         console.log(result);
         result = JSON.parse(result);
         callback(result);
      });
@@ -353,6 +452,12 @@
      http_util.http_request("/get_cb_list", params, callback);
   },
   get_new_blocks(callback) {
      var params = {}
      http_util.http_request("/get_new_blocks", params, callback);
   },
   buy_by_ths(code, callback) {
      var params = {
         "code": code
@@ -366,10 +471,190 @@
      }
      http_util.http_request("/statistic_latest_limit_up_block", params, callback);
   },
   // 获取距离给定时间最近的开盘啦涨停数据
   get_kpl_latest_limit_up_queue_by_time(time, callback) {
      var params = {
         "time": time,
      }
      http_util.http_request("/kpl/get_latest_limit_up_queue", params, callback);
   },
   get_account_commission_detail(callback) {
      http_util.http_request("/get_account_commission_detail", {}, callback);
   }
   },
   get_code_third_blocks: function(code, callback) {
      var params = {
         type: "common",
         data: {
            ctype: "get_code_third_blocks",
            code: code
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(params), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   get_block_codes_with_money: function(block, desc, callback) {
      http_util.http_request("/get_block_codes_with_money", {
         block: block,
         desc: desc
      }, callback);
   },
   // 获取所有L2订阅的列表
   get_l2_subscript_codes: function(callback) {
      // var params = {
      //    type: "get_huaxin_subscript_codes",
      //    data: {},
      //    sign: ''
      // }
      // http_util.socket_request(JSON.stringify(params), function(result) {
      //    result = JSON.parse(result);
      //    callback(result);
      // });
      http_util.http_request("/get_l2_subscript_codes", {}, callback);
   },
   get_big_order_deal_info: function(code, callback) {
      http_util.http_request("/get_l2_subscript_codes", {
         code: code
      }, callback);
   },
   get_all_special_codes: function(callback) {
      http_util.http_request("/get_all_special_codes", {}, callback);
   },
   get_new_blocks_special_codes: function(callback) {
      http_util.http_request("/get_new_blocks_special_codes", {}, callback);
   },
   // 设置累计成交大单的阈值
   set_total_deal_big_order_threshold_money: function(code, money, callback) {
      var params = {
         type: "common",
         data: {
            ctype: "set_total_deal_big_order_threshold_money",
            code: code,
            money: money
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(params), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   // 设置L后撤单比例
   set_l_down_rate: function(code, rate, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "set_l_down_rate",
            code: code,
            rate: rate
         },
         sign: ''
      }
      console.log("请求元数据:", data)
      console.log("请求json数据:", JSON.stringify(data))
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   remove_l_down_rate: function(code, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "remove_l_down_rate",
            code: code
         },
         sign: ''
      }
      console.log("请求元数据:", data)
      console.log("请求json数据:", JSON.stringify(data))
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
    // 获取委托队列
   get_trade_queue: function(code, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "get_trade_queue",
            code: code
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   // 获取已成交的大单
   get_deal_big_money_list: function(code, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "get_deal_big_money_list",
            code: code
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   get_want_buy_detail_list: function(callback) {
      var params = {
      }
      http_util.http_request("/get_want_buy_detail_list", params, callback);
   },
   get_l_down_watch_index_overview: function(code, callback) {
      var params = {
         code:code
      };
      http_util.http_request("/get_l_down_watch_index_overview", params, callback);
   },
   list_delegate_records: function(updateTime, callback) {
      var params = {
         update_time: updateTime,
      }
      http_util.http_request("/get_all_delegate_list", params, callback);
   },
   list_deal_records: function(updateTime, callback) {
      let data = {
         type: "deal_list",
         data: {
            update_time: updateTime
         },
         sign: ''
      };
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },