def save_hk_bluechips(stocks_list):
    print("************ 保存据处理开始:save_hk_bluechips **********:")
    try:
        for index in range(len(stocks_list)):
            data_list = []

            data_list.append(stocks_list[index]['f12'])  # dm
            data_list.append(stocks_list[index]['f14'])  # mc
            data_list.append(chkNum(stocks_list[index]['f2']))  # zxj
            data_list.append(chkNum(stocks_list[index]['f4']))  # zde
            data_list.append(chkNum(stocks_list[index]['f3']))  # zdf
            data_list.append(chkNum(stocks_list[index]['f17']))  # jk
            data_list.append(chkNum(stocks_list[index]['f15']))  # zg
            data_list.append(chkNum(stocks_list[index]['f16']))  # zd
            data_list.append(chkNum(stocks_list[index]['f18']))  # zs
            data_list.append(chkNum(stocks_list[index]['f5']))  # cjl
            data_list.append(chkNum(stocks_list[index]['f6']))  # cje
            print(data_list)

            #判断是否有相同的ID
            bb = select_hk_bluechips(data_list)
            if (bb):
                # 如果存在就进行更新
                update_hk_bluechips(data_list)
            else:
                #如果不存在,就进行插入数据
                insert_hk_bluechips(data_list)

            # 判断单个股票表是否存在,如果不存在则进行创建
            # 进行单个股票明细插入
            chk = select_stocks_byDM(data_list)
            if chk:
                update_hk_stocks(data_list)
            else:
                insert_hk_stocks(data_list)

    except Exception as e:
        print(e)
        db.rollback()
        db.close()
    print("************ 保存据处理结束:save_hk_bluechips **********:")
示例#2
0
from stock.dongfang.common.dataUtil import chkNum

if __name__ == '__main__':
    print(chkNum(1))
示例#3
0
def save_sh_sz_hk(stocks_list, dict_parm):
    print("************ 保存据处理开始:save_sh_sz_hk **********:")
    try:
        for index in range(len(stocks_list)):
            data_list = []

            data_list.append(stocks_list[index]['f1'])  # 固定值   -
            data_list.append(chkNum(stocks_list[index]['f2']))  # 最新价
            data_list.append(chkNum(stocks_list[index]['f3']))  # 涨跌幅
            data_list.append(chkNum(stocks_list[index]['f4']))  # 涨跌额
            data_list.append(chkNum(stocks_list[index]['f5']))  # 成交量
            data_list.append(chkNum(stocks_list[index]['f6']))  # 成交额
            data_list.append(chkNum(stocks_list[index]['f7']))  # 振幅
            data_list.append(chkNum(stocks_list[index]['f8']))  # 换手率
            data_list.append(chkNum(stocks_list[index]['f9']))  # 市盈率(动态)
            data_list.append(chkNum(stocks_list[index]['f10']))  # 量比
            data_list.append(chkNum(stocks_list[index]['f11']))  #
            data_list.append(stocks_list[index]['f12'])  # 代码 -
            data_list.append(stocks_list[index]['f13'])  #     -
            data_list.append(stocks_list[index]['f14'])  # 名称 -
            data_list.append(chkNum(stocks_list[index]['f15']))  # 最高
            data_list.append(chkNum(stocks_list[index]['f16']))  # 最低
            data_list.append(chkNum(stocks_list[index]['f17']))  # 今开
            data_list.append(chkNum(stocks_list[index]['f18']))  # 昨收
            data_list.append(chkNum(stocks_list[index]['f20']))  # 总市值
            data_list.append(chkNum(stocks_list[index]['f21']))  # 流通市值
            data_list.append(chkNum(stocks_list[index]['f22']))  #
            data_list.append(chkNum(stocks_list[index]['f23']))  # 市净率
            data_list.append(chkNum(stocks_list[index]['f24']))  # 最近3个月累计涨跌幅
            data_list.append(chkNum(stocks_list[index]['f25']))  # 今年以来累计涨幅
            data_list.append(stocks_list[index]['f26'])  # 上市时间
            data_list.append(chkNum(stocks_list[index]['f62']))  # 净流入额
            data_list.append(chkNum(stocks_list[index]['f115']))  # 市净率
            data_list.append(stocks_list[index]['f128'])  #
            data_list.append(stocks_list[index]['f140'])  # -
            data_list.append(stocks_list[index]['f141'])  # -
            data_list.append(stocks_list[index]['f136'])  # -
            data_list.append(stocks_list[index]['f152'])  # 固定2 -
            print(data_list)

            #判断是否有相同的ID
            bb = select_sh_sz_hk_board(data_list, dict_parm)
            if (bb):
                # 如果存在就进行更新
                update_sh_sz_hk_board(data_list, dict_parm)
            else:
                #如果不存在,就进行插入数据
                insert_sh_sz_hk_board(data_list, dict_parm)

            # 判断单个股票表是否存在,如果不存在则进行创建
            # 进行单个股票明细插入
            chk = select_stocks_byDM(data_list, dict_parm)
            if chk:
                update_us_stocks(data_list, dict_parm)
            else:
                insert_us_stocks(data_list, dict_parm)

    except Exception as e:
        print(e)
        db.rollback()
        db.close()
    print("************ 保存据处理结束:save_sh_sz_hk **********:")