Administrator
2024-05-08 2dfd00b7f6081574f9d35123b25dc7d388a8179d
bug修复
2个文件已修改
31 ■■■■ 已修改文件
huaxin_client/l2_client_for_cb.py 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test.py 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client_for_cb.py
@@ -301,15 +301,29 @@
    :return:
    """
    results = JueJinHttpApi.get_exchanges_codes("SHSE,SZSE", sec_types=[8], skip_suspended=True, skip_st=True,
                                                fields="symbol, sec_type, sec_id,sec_name, underlying_symbol, delisted_date")
                                                fields="symbol, sec_type, sec_id,sec_name, underlying_symbol, delisted_date, sec_level")
    fresults = []
    for r in results:
        tool.get_now_date_str()
        if int(tool.get_now_date_str('%Y%m%d')) >= int(r['delisted_date'].strftime('%Y%m%d')):
        if r['sec_name'].find('转') == -1 or r['sec_level'] != 1 or int(tool.get_now_date_str('%Y%m%d')) >= int(
                r['delisted_date'].strftime('%Y%m%d')):
            continue
        fresults.append(r)
    print(len(fresults))
    return [x['underlying_symbol'].split('.')[1] for x in fresults]
        # 排除同一股票有2个转债
    cb_count_dict = {}
    exclude_codes = []
    for r in fresults:
        if r['underlying_symbol'] not in cb_count_dict:
            cb_count_dict[r['underlying_symbol']] = []
        cb_count_dict[r['underlying_symbol']].append(r['symbol'])
        if len(cb_count_dict[r['underlying_symbol']]) > 1:
            print(r['underlying_symbol'], cb_count_dict[r['underlying_symbol']])
            exclude_codes.extend(cb_count_dict[r['underlying_symbol']])
    ffresults = []
    for x in fresults:
        if x['symbol'] in exclude_codes:
            continue
        ffresults.append(x)
    return [x['underlying_symbol'].split('.')[1] for x in ffresults]
def get_pre_price(codes):
test/test.py
@@ -1,5 +1,8 @@
from code_atrribute.history_k_data_util import JueJinHttpApi
from huaxin_client import l2_client_for_cb
from utils import tool
if __name__ == "__main__":
    codes = l2_client_for_cb.get_subscript_codes()
    # print(l2_client_for_cb.get_pre_price(codes))
    ffresults = l2_client_for_cb.get_subscript_codes()
    print("最终的数量", len(ffresults))