Exemple #1
0
def fetch_bond_info():
    """
    获取债券数据的文件,如果文件已经存在,则跳过
    :return:
    """
    date_time = datetime.datetime.today()
    date = date_time.date()

    exist_flag = ('债券成交{}.csv'.format(date)) in os.listdir('./csv')
    if exist_flag:  # 已经存在
        print('今日结果已经存在')
        # time.sleep(300)# 延时五分钟
        return 0
    else:
        print('获取今日成交')
        if ('ak' not in locals()):  # 避免重复import
            import akshare as ak
        bond_df_raw = ak.bond_spot_deal()
        bond_df_raw.to_csv('./csv/债券成交{}.csv'.format(date), encoding='gbk')
        print('成交获取完成')
        th = threading.Thread(target=msg_box, args=(date, ))
        th.start()
        return 0
def hmm():
    import akshare as ak
    bond_df = ak.bond_spot_deal()
    print(dict(bond_df))
    return 'aaa'