Administrator
2023-10-19 10af901f9f578d494adf4a9d7abc58d581ce7b2e
交易记录日志输出优化
1个文件已修改
22 ■■■■ 已修改文件
output/code_info_output.py 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
output/code_info_output.py
@@ -335,6 +335,11 @@
    def format_l2_data(item):
        return f"{item['val']['time']}#{item['val']['num']}手#{round(item['val']['num'] * float(item['val']['price']) * 100 / 10000, 1)}万"
    def load_cancel_watch_index(latest_cancel_watch_index_dict_):
        for k in latest_cancel_watch_index_dict_:
            records_new_data.append(latest_cancel_watch_index_dict_[k])
        latest_cancel_watch_index_dict_.clear()
    # 获取炸板信息
    limit_up_info = code_price_manager.Buy1PriceManager().get_limit_up_info(code)
    break_time = limit_up_info[1]
@@ -348,6 +353,8 @@
    index = 0
    if records:
        try:
            latest_cancel_watch_index_dict = {}
            for record in records:
                time_ = record[0]
                type = record[1]
@@ -390,21 +397,24 @@
                            indexes_data.append(format_l2_data(total_datas[index]))
                        desc = f"【{format_l2_data(total_datas[indexes[0]])}】-【{format_l2_data(total_datas[indexes[-1]])}】"
                        if cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN:
                            records_new_data.append((time_, "L撤后囊括", desc, indexes_data))
                            latest_cancel_watch_index_dict[cancel_type] = (time_, "L撤后囊括", desc, indexes_data)
                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_UP:
                            records_new_data.append((time_, "L撤前囊括", desc, indexes_data))
                            latest_cancel_watch_index_dict[cancel_type] = (time_, "L撤前囊括", desc, indexes_data)
                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_H:
                            records_new_data.append((time_, "H撤囊括", desc, indexes_data))
                            latest_cancel_watch_index_dict[cancel_type] = (time_, "H撤囊括", desc, indexes_data)
                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_D:
                            records_new_data.append((time_, "D撤囊括", desc, indexes_data))
                            latest_cancel_watch_index_dict[cancel_type] = (time_, "D撤囊括", desc, indexes_data)
                        elif cancel_type == trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_S:
                            records_new_data.append((time_, "S撤囊括", desc, indexes_data))
                            latest_cancel_watch_index_dict[cancel_type] = (time_, "S撤囊括", desc, indexes_data)
                elif type == trade_record_log_util.TYPE_FORBIDDEN_BUY:
                    records_new_data.append((time_, "加入黑名单", f"原因:{data['msg']}", []))
                elif type == trade_record_log_util.TYPE_CANT_PLACE_ORDER:
                    records_new_data.append((time_, "不能下单", f"原因:{data['msg']}", []))
                elif type == trade_record_log_util.TYPE_CANCEL:
                    load_cancel_watch_index(latest_cancel_watch_index_dict)
                    records_new_data.append((time_, "撤单", f"原因:{data['msg']}", []))
            load_cancel_watch_index(latest_cancel_watch_index_dict)
            records_new_data.sort(key=lambda x: x[0])
            if records_new_data:
                for d in records_new_data:
                    records_new.append(f"【{d[0]}】" + "{:<10}".format(f'【{d[1]}】') + d[2])
@@ -416,6 +426,6 @@
if __name__ == '__main__':
    code = '603131'
    code = '603399'
    l2_data_util.load_l2_data(code)
    __load_trade_record(code, l2_data_util.local_today_datas.get(code))