Commit 21571ed1 authored by 赵杰's avatar 赵杰

修复Decimal(NaN)

parent e027a0cb
......@@ -11,6 +11,7 @@ import numpy as np
from sqlalchemy import and_
import tushare as ts
import datetime
import math
from decimal import Decimal
from app.api.engine import tamp_user_engine, tamp_product_engine, TAMP_SQL
# from app.model.tamp_user_models import CustomerOrder, CustomerInfo
......@@ -128,6 +129,9 @@ class UserCustomerDataAdaptor:
all_fund_nav = all_fund_nav[all_fund_nav.index <= self.end_date]
all_fund_cnav = all_fund_cnav[all_fund_cnav.index <= self.end_date]
# for cur_fund_id in self.user_customer_order_df["fund_id"].unique():
# all_fund_nav[cur_fund_id][all_fund_nav[cur_fund_id].apply(lambda x: math.isnan(x))]=np.nan
# all_fund_cnav[cur_fund_id][all_fund_cnav[cur_fund_id].apply(lambda x: math.isnan(x))] = np.nan
self.last_nav_date = str(all_fund_cnav.dropna(how="all").index.values[-1])[:10]
return all_fund_nav, all_fund_cnav
......@@ -269,7 +273,7 @@ class UserCustomerDataAdaptor:
confirm_share_date = pd.to_datetime(row["confirm_share_date"])
# 根据确认净值日查看是否含有累积净值的数据,如果没有按照前后差值推算当天累积净值
if pd.isnull(cnav_df.loc[confirm_share_date, cur_fund_id]):
if pd.isnull(p_nav_df.loc[confirm_share_date, cur_fund_id]):
last_nav_data = p_nav_df[p_nav_df.index < confirm_share_date][cur_fund_id].dropna().tail(1)
last_cnav_data = p_cnav_df[p_cnav_df.index < confirm_share_date][cur_fund_id].dropna().tail(1)
# 判断上个净值日和当前确认日之中是否存在分红日
......@@ -332,4 +336,5 @@ class UserCustomerDataAdaptor:
# cnav_df[p_fund_id_ + "_profit_ratio"] = cnav_df[p_fund_id_ + "_earn"].apply(lambda x: Decimal(x)) / cnav_df[
# p_fund_id_ + "_net_amount"].shift()
# cnav_df[p_fund_id_ + "_net_amount"] = cnav_df[p_fund_id_ + "_share"] * cnav_df[p_fund_id_]
return cnav_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