Administrator
2023-10-09 63df682b36955113788fd4da32416b91ab27e147
输出调整
1个文件已修改
202 ■■■■■ 已修改文件
output/code_info_output.py 202 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
output/code_info_output.py
@@ -41,7 +41,6 @@
    return f"<head><style>{base_output_content['css']}</style></head>"
def money_desc(money):
    if abs(money) > 100000000:
        return f"{round(money / 100000000, 2)}亿"
@@ -87,7 +86,6 @@
        l2_data_util.load_l2_data(code)
        total_datas = l2_data_util.local_today_datas.get(code)
    if is_target_code:
        params["score_data"] = {}
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        limit_up_time = limit_up_time_manager.LimitUpTimeManager().get_limit_up_time_cache(code)
        volume_rate, volume_info = code_volumn_manager.get_volume_rate(code, True)
@@ -95,148 +93,6 @@
                                                                                    True)
        ################################买前评分################################
        # ["换手量能", "竞价强度", "资金力度", "K线形态", "历史股性", "板块热度", "上板时间", "市值大小","股价大小"]
        # 换手量能
        # 获取当前量信息
        max_60, yest = code_volumn_manager.get_histry_volumn(code)
        today = code_volumn_manager.get_today_volumn(code)
        params["score_data"]["volume"] = {"score": score_list[6], "now": f"{round(int(today) / 1000000, 2)}",
                                          "high": {"num": round(max_60[0] / 1000000, 2), "date": max_60[1]},
                                          "rate": round(score_source_list[6] * 100, 2)}
        # 竞价强度
        params["score_data"]["bidding"] = {"score": score_list[2],
                                           "money": (score_source_list[2] if score_source_list[2] else 0)}
        # 资金力度
        deal_indexes = set()
        deal_info = ""
        params["score_data"]["deal_big_money"] = {"score": score_list[8], "money": score_source_list[8][0] // 10000,
                                                  "base_money": score_source_list[8][1] // 10000,
                                                  "rate": round(score_source_list[8][0] / score_source_list[8][1], 2)}
        if deal_indexes:
            temps = []
            for index in deal_indexes:
                temps.append(int(index))
            temps.sort()
            start_index = temps[0]
            end_index = temps[-1]
            try:
                deal_info = f"【{total_datas[start_index]['val']['time']}&{total_datas[start_index]['val']['num']}手-{total_datas[end_index]['val']['time']}&{total_datas[end_index]['val']['num']}手】,"
            except:
                pass
            params["score_data"]["deal_big_money"]["start"] = {"time": total_datas[start_index]['val']['time'],
                                                               "num": total_datas[start_index]['val']['num']}
            params["score_data"]["deal_big_money"]["end"] = {"time": total_datas[end_index]['val']['time'],
                                                             "num": total_datas[end_index]['val']['num']}
        # K线形态
        k_score = 0
        k_source = []
        for k in score_list[3]:
            k_score += k
        # (15个交易日是否涨幅24.9%,是否破前高,是否超跌,是否接近前高,是否N,是否V)
        for k in range(0, len(score_source_list[3])):
            if k == 0:
                if score_source_list[3][k][0]:
                    k_source.append(("涨幅过高", score_list[3][k]))
            elif k == 1:
                if score_source_list[3][k][0]:
                    k_source.append(("突破前高", score_list[3][k]))
            elif k == 2:
                if score_source_list[3][k][0]:
                    k_source.append(("超跌补涨", score_list[3][k]))
            elif k == 3:
                if score_source_list[3][k][0]:
                    k_source.append((f"逼近前高-{score_source_list[3][k][1]}】", score_list[3][k]))
            elif k == 4:
                if score_source_list[3][k][0]:
                    k_source.append(("N字型", score_list[3][k]))
            elif k == 5:
                if score_source_list[3][k][0]:
                    k_source.append(("V字型", score_list[3][k]))
            elif k == 6:
                if not score_source_list[3][k][0]:
                    k_source.append(("不满足任何形态", score_list[3][k]))
            elif k == 7:
                if score_source_list[3][k][0]:
                    k_source.append(("天量大阳", score_list[3][k]))
        params["score_data"]["k_form"] = {"score": k_score, "datas": k_source}
        log.logger_debug.info(f"K线形态耗时:{time.time() - __start_time}")
        __start_time = time.time()
        # 历史股性
        nature_score = 0
        nature_source = []
        for k in score_list[4]:
            nature_score += k
        code_nature_datas = {"score": nature_score, "limit_up_count": score_source_list[4][0]}
        for n in range(0, len(score_source_list[4])):
            if n == 0:
                nature_source.append(f"涨停次数【{score_source_list[4][n]}】")
            elif n == 1:
                if score_source_list[4][n]:
                    nature_source.append(f"首板溢价率【{round(score_source_list[4][n], 2)}】")
                    code_nature_datas["first_limit_up_yijia"] = round(score_source_list[4][1], 2)
                else:
                    nature_source.append(f"无首板")
                    code_nature_datas["first_limit_up_yijia"] = "无首板"
            elif n == 2:
                if score_source_list[4][n]:
                    nature_source.append(f"首板炸板溢价率【{round(score_source_list[4][n], 2)}】")
                    code_nature_datas["first_open_limit_up_yijia"] = round(score_source_list[4][2], 2)
                else:
                    nature_source.append(f"无首板炸板")
                    code_nature_datas["first_open_limit_up_yijia"] = "无首板炸板"
        params["score_data"]["code_nature"] = code_nature_datas
        log.logger_debug.info(f"历史股性耗时:{time.time() - __start_time}")
        __start_time = time.time()
        # 板块热度
        hot_block_score = 0
        for k in score_list[5]:
            hot_block_score += k
        hot_block_source_data = score_source_list[5]
        for k in hot_block_source_data:
            hot_block = {
                # 目标板块信息(板块名称,板块涨幅,历史板块出现次数)
                "target_block_info": ("无板块", 0, 0),
                # 涨停顺序
                "limit_up_index": 0,
                # 涨停代码数量
                "limit_up_codes_count": 0,
                # 板块代码涨幅信息
                "block_codes_rates_info": (0, 0),
                # 炸板代码数量
                "break_size": 0,
                # 炸板回封数量
                "re_limit_up_size": 0,
                # 高位版信息
                "high_block_infos": [],
            }
        params["score_data"]["hot_block"] = {"score": hot_block_score,
                                             "limit_up_index": hot_block_source_data['limit_up_index'] + 1,
                                             "block_name": hot_block_source_data['target_block_info'][0],
                                             "limit_up_count": hot_block_source_data['limit_up_codes_count'],
                                             "block_history_count": hot_block_source_data['target_block_info'][2],
                                             "open_limit_up_count": hot_block_source_data['break_size']}
        # 上板时间
        params["score_data"]["limit_up_time"] = {"score": score_list[7], "time": score_source_list[7]}
        # 市值大小
        params["score_data"]["zyltgb"] = {"score": score_list[0], "value": round(score_source_list[0] / 100000000, 2)}
        # 股价大小
        params["score_data"]["limit_up_price"] = {"score": score_list[1], "price": score_source_list[1]}
        params["score_data"]["total_score"] = score
        # zyltgb, limit_price, bidding, k_form, code_nature, hot_block, volume_rate, limit_up_time,
        # deal_big_money
@@ -298,7 +154,7 @@
            # buy_params_info.append("未识别")
            pass
        else:
            if trade_progress<len(total_datas):
            if trade_progress < len(total_datas):
                data = total_datas[trade_progress]
                params["trade_data"]["trade_progress"] = {"time": data['val']['time'],
                                                          "num": data['val']['num'], "money": round(
@@ -525,61 +381,7 @@
    return break_time, records_new, records_new_data
if __name__ == '__main__':
    plate_info = kpl_api.getStockIDPlate("600748")
    print(plate_info)
if __name__ == '__main__1':
    datas = {
        "base_url": "http://192.168.3.122/kp/",
        "code_name": "天域生态 002255",
        "score_data": {"volume": {"score": 20, "now": "12", "high": {"num": "56", "date": "2023-04-13"}},
                       "bidding": {"score": 10, "money": "4563"},
                       "deal_big_money": {"score": 10, "money": 0, "base_money": 456.5,
                                          "start": {"time": "09:00:00", "num": 1456},
                                          "end": {"time": "09:00:00", "num": 1456}},
                       "k_form": {"score": 10, "datas": ["破前高", "超跌补涨", "涨幅过高"]},
                       "code_nature": {"score": 10, "data_desc": "涨停次数2次"},
                       "hot_block": {"score": 10, "block_name": "影视", "limit_up_count": 10, "open_limit_up_count": 2},
                       "limit_up_time": {"score": 10, "time": "09:56:00"},
                       "zyltgb": {"score": 10, "value": "12.5"},
                       "limit_up_price": {"score": 10, "price": "6.35"},
                       "total_score": "210"
                       },
        "trade_data": {"star": {"desc": "被动买入", "count": 0},
                       "safe_count": {"base": 12, "now": 2},
                       "m": {"base": 1200, "now": 1000},
                       "big_num": {"base": 10, "now": 2},
                       "trade_progress": {"time": "09:12:12", "num": 1111, "money": "12.56"},
                       "buy_single": {"time": "09:12:12", "num": 1111, "money": "12.56"},
                       "buy_exec": {"time": "09:12:12", "num": 1111, "money": "12.56"},
                       },
        "xgb_code_infos": [{"date": "今天", "blocks": [
            {"name": "影视", "limit_up_count": 2, "index": 1, "price": "12.00", "rate": "+10.00%"},
            {"name": "文旅", "limit_up_count": 3, "index": 2, "price": "12.00", "rate": "+10.00%"},
        ]}],
        "initiative_buy_codes": [
            {"name": "测试1", "code": "000123", "score": 125, "limit_up": True, "open_limit_up": True},
            {"name": "测试2", "code": "000123", "score": 125, "limit_up": False, "open_limit_up": True},
            {"name": "测试2", "code": "000123", "score": 125, "limit_up": False, "open_limit_up": True},
            {"name": "测试2", "code": "000123", "score": 125, "limit_up": False, "open_limit_up": False}
        ],
        "passive_buy_codes": [{"name": "测试1", "code": "000123", "score": 125},
                              {"name": "测试2", "code": "000123", "score": 125},
                              {"name": "测试2", "code": "000123", "score": 125},
                              {"name": "测试2", "code": "000123", "score": 125}
                              ],
        "trade_record": {"open_limit_up": "10:00:03", "records": [
            {"type": 1, "index": 1, "time": "11:00:00", "score": 12},
            {"type": 0, "time": "11:26:00", "desc": "H撤撤单"}
        ]},
        "xgb_infos": [{"block": {"name": "测试1", "rate": "+12.00%", "limit_up_count": 10},
                       "codes": [
                           {"limit_up": True, "name": "测试代码", "code": "000654"},
                           {"limit_up": True, "name": "测试代码", "code": "000654"},
                           {"limit_up": True, "name": "测试代码", "code": "000654"},
                           {"limit_up": False, "name": "测试代码", "code": "000654"},
                       ]}]
    }
    print(render(datas))