def get_securities_day_money_flow(security_list, date):
    # TODO: 疑问: 净占比有负数,且占比加起来不为100%
    fields = [
        "change_pct", "net_amount_main", "net_pct_main", "net_amount_xl",
        "net_pct_xl", "net_amount_l", "net_pct_l", "net_amount_m", "net_pct_m",
        "net_amount_s", "net_pct_s"
    ]
    data_df = jq.get_money_flow(security_list, start_date=date, end_date=date)
    if data_df.empty:
        return pd.DataFrame(
            {field: []
             for field in ["security"] + fields + ["date"]})
    data_df = data_df.rename(columns={"sec_code": "security"})
    data_df["date"] = date
    result_df = data_df[["security"] + fields + ["date"]]
    return result_df
def get_day_money_flow(security, date):
    # TODO: 疑问: 净占比有负数,且占比加起来不为100%
    fields = [
        "change_pct", "net_amount_main", "net_pct_main", "net_amount_xl",
        "net_pct_xl", "net_amount_l", "net_pct_l", "net_amount_m", "net_pct_m",
        "net_amount_s", "net_pct_s"
    ]
    data_df = jq.get_money_flow(security,
                                start_date=date,
                                end_date=date,
                                fields=fields)
    if data_df.empty:
        return pd.DataFrame(
            {field: []
             for field in ["security"] + fields + ["date"]})
    data_df["security"] = security
    data_df["date"] = date
    result_df = data_df[["security"] + fields + ["date"]]
    return result_df
예제 #3
0
#获取每日大单量,最上面的数据是最新的
dmb_list = []
sql = "SELECT dm FROM dmb order by id "
cursor.execute(sql)
for row in cursor.fetchall():
    if row[0].startswith('6'):
        r = row[0] + '.XSHG'
    else:
        r = row[0] + '.XSHE'
    dmb_list.append(r)

for o in range(0, len(dmb_list)):
    zjl_df = jq.get_money_flow([dmb_list[o]],
                               start_date='2015-01-01',
                               end_date='2019-05-10',
                               fields=[
                                   'date', 'change_pct', 'net_amount_xl',
                                   'net_amount_l', 'net_amount_m',
                                   'net_amount_s'
                               ])
    zjl_list = zjl_df.values.tolist()

    total = 0
    for p in range(0, len(zjl_list)):
        sql = "update %s set zdf=%.2f, cdd=%.2f ,  dd=%.2f  ,  zd=%.2f  ,  xd=%.2f  where date='%s'"
        data = ('TB' + dmb_list[o][:6], zjl_list[p][1], zjl_list[p][2],
                zjl_list[p][3], zjl_list[p][4], zjl_list[p][5],
                datetime.date(
                    datetime.fromtimestamp(zjl_list[p][0].timestamp())))
        cursor.execute(sql % data)
        connect.commit()  # 事务提交
        total = total + cursor.rowcount
예제 #4
0
파일: 数据更新.py 프로젝트: fswzb/CJSJ
                    volandincome_list[0][0][:6], volandincome_list[0][1],
                    volandincome_list[0][2], volandincome_list[0][3],
                    volandincome_list[0][4], date_new_list[u])
            cursor.execute(sql % data)
        except Exception as e:
            connect.rollback()  # 事务回滚
            continue
        else:
            connect.commit()  # 事务提交
    print('TB' + dm_insert_sh_list[q][:6], '市值数据获取完成')

    #获取资金流向
    zjl_df = jq.get_money_flow(dm_insert_sh_list[q],
                               start_date='2015-01-01',
                               end_date=d,
                               fields=[
                                   'date', 'change_pct', 'net_amount_xl',
                                   'net_amount_l', 'net_amount_m',
                                   'net_amount_s'
                               ])
    zjl_list = zjl_df.values.tolist()
    for p in range(0, len(zjl_list)):
        sql = "update %s set zdf=%.2f , cdd=%.2f ,  dd=%.2f  ,  zd=%.2f  ,  xd=%.2f  where date='%s'"
        data = ('TB' + dm_insert_list[q][0], zjl_list[p][1], zjl_list[p][2],
                zjl_list[p][3], zjl_list[p][4], zjl_list[p][5],
                datetime.date(
                    datetime.fromtimestamp(zjl_list[p][0].timestamp())))
        cursor.execute(sql % data)
        connect.commit()  # 事务提交
    print('TB' + dm_insert_sh_list[q][:6], '资金流数据获取完成')

    #获取流通股东