Commit 336d41ba authored by 赵杰's avatar 赵杰

fund_name

parent 47358623
...@@ -324,24 +324,43 @@ def get_radar_data(fund): ...@@ -324,24 +324,43 @@ def get_radar_data(fund):
{'name': '综合评分', 'data': '%.2f' % total_score}]} {'name': '综合评分', 'data': '%.2f' % total_score}]}
def get_fund_name(fund): def get_fund_name(fund, fund_type=1):
with TAMP_SQL(tamp_fund_engine) as tamp_fund: if fund_type == 0:
tamp_fund_session = tamp_fund.session with TAMP_SQL(tamp_fund_engine) as tamp_fund:
sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund) tamp_fund_session = tamp_fund.session
# df = pd.read_sql(sql, con) sql = "SELECT name FROM public_fund_basic WHERE ts_code='{}'".format(fund)
cur = tamp_fund_session.execute(sql) # df = pd.read_sql(sql, con)
data = cur.fetchall() cur = tamp_fund_session.execute(sql)
df = pd.DataFrame(list(data), columns=['fund_short_name']) data = cur.fetchall()
if len(df) == 0: df = pd.DataFrame(list(data), columns=['fund_short_name'])
with TAMP_SQL(tamp_product_engine) as tamp_product: return df
tamp_product_session = tamp_product.session elif fund_type == 1 or fund_type == 2:
sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund) with TAMP_SQL(tamp_fund_engine) as tamp_fund:
# df = pd.read_sql(sql, con) tamp_fund_session = tamp_fund.session
cur = tamp_product_session.execute(sql) sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund)
data = cur.fetchall() # df = pd.read_sql(sql, con)
df = pd.DataFrame(list(data), columns=['fund_short_name']) cur = tamp_fund_session.execute(sql)
return df data = cur.fetchall()
return df df = pd.DataFrame(list(data), columns=['fund_short_name'])
if len(df) == 0:
with TAMP_SQL(tamp_product_engine) as tamp_product:
tamp_product_session = tamp_product.session
sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund)
# df = pd.read_sql(sql, con)
cur = tamp_product_session.execute(sql)
data = cur.fetchall()
df = pd.DataFrame(list(data), columns=['fund_short_name'])
return df
return df
else:
with TAMP_SQL(tamp_fund_engine) as tamp_fund:
tamp_fund_session = tamp_fund.session
sql = "SELECT fund_name FROM ifa_imported_fund_info WHERE id='{}'".format(fund)
# df = pd.read_sql(sql, con)
cur = tamp_fund_session.execute(sql)
data = cur.fetchall()
df = pd.DataFrame(list(data), columns=['fund_short_name'])
return df
# 获取排名信息 # 获取排名信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment