Commit dc21a972 authored by 陈涛's avatar 陈涛

修改结算手续费bug,修改净值计算bug

parent 629021f0
......@@ -154,8 +154,8 @@ async def create_staking_api(
assets, adjust_assets, pending_assets, staking_assets, nodes = await query_fund_assets_and_nodes(fund_collect,
fund_id=create_staking_bill.fund_id,
fund_status=FundStatus.active)
assert assets.get(create_staking_bill.currency, 0) >= create_staking_bill.volume, '余额不足'
assets[create_staking_bill.currency] -= create_staking_bill.volume
assert assets.get(create_staking_bill.currency, 0) >= create_staking_bill.volume + create_staking_bill.fee, '余额不足'
assets[create_staking_bill.currency] -= create_staking_bill.volume + create_staking_bill.fee
# 防止增加的币种没有 设置默认值
pending_assets.setdefault(create_staking_bill.currency, 0)
pending_assets[create_staking_bill.currency] += create_staking_bill.volume
......
import datetime
from typing import Optional
import re
from loguru import logger
import pytz
from fastapi import APIRouter, Depends, Query, Body
from fastapi.background import BackgroundTasks
......@@ -83,11 +84,15 @@ async def recalculate_nav(
background_task: BackgroundTasks,
start: datetime.datetime = Query(..., title="开始时间"),
end: datetime.datetime = Query(None, title="结束时间"),
fund_collect: AgnosticCollection = Depends(get_fund_collect),
):
fund_data = await fund_collect.find_one({"id": fund_id})
end = end or datetime.datetime.utcnow()
delta = end - start
for i in range(delta.days + 1):
date = start + datetime.timedelta(days=i)
for i in range(delta.days):
settlement_time = re.findall(r"(\d+):00", fund_data["settlement_time"])[0]
date = start + datetime.timedelta(days=i, hours=int(settlement_time))
logger.info(f"[重新计算净值]fund_id={fund_id}, date={date}")
background_task.add_task(calculate_nav, fund_id=fund_id, calc_time=date, update_fund=False)
response = Response(data=True)
return response
......@@ -51,6 +51,7 @@ class StakingBill(MyBaseModel):
pub_key: str = Field(..., description='节点key')
remark: str = Field(default="", description="备注")
record_time: int = Field(default_factory=utc_now_timestamp, description='记录时间')
fee: float = Field(0, description="手续费")
class AdjustBill(MyBaseModel):
......
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