Commit 296ef63a authored by 赵杰's avatar 赵杰

修复同一日期多笔分红的核减

parent 9b2205d5
......@@ -173,6 +173,29 @@ class UserCustomerDataAdaptor:
inter_order_df = order_df.copy()
inter_order_df.sort_values(by="confirm_share_date", inplace=True)
def operate_type4(df):
"""
处理同一天同一个基金的多笔分红记录(不同银行账号付款导致的作业流订单分红也会拆开成多笔)
"""
df_row = []
fund_dis_his = {}
for index, row in df.iterrows():
fund_id = row["fund_id"]
if row["order_type"] != 4:
df_row.append(row)
continue
dis_his = fund_dis_his.get(fund_id, None)
if dis_his is None:
fund_dis_his[fund_id] = row
continue
if row["confirm_share_date"] == dis_his["confirm_share_date"]:
dis_his["confirm_share"] += row["confirm_share"]
dis_his["original_confirm_share"] += row["original_confirm_share"]
dis_his["divident_share"] += row["divident_share"]
dis_his["reduce_share"] += row["reduce_share"]
final_df = pd.DataFrame(data=df_row + list(fund_dis_his.values()))
return final_df
def reduce_order(fund_order, d_fund_id, d_date, d_nav):
"""
再平衡分红后单子的份额数量,对分红前的单子进行拆分
......@@ -191,6 +214,11 @@ class UserCustomerDataAdaptor:
return fund_order
if inter_order_df[inter_order_df["order_type"] == 4].groupby(["fund_id", "confirm_share_date"]).count()[
"order_id"].max() > 1:
inter_order_df = operate_type4(inter_order_df)
inter_order_df.sort_values(by="confirm_share_date", inplace=True)
for index, row in inter_order_df.iterrows():
if row["order_type"] == 4:
dividend_date = row["confirm_share_date"]
......
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