Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PyFund
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈涛
PyFund
Commits
dc21a972
Commit
dc21a972
authored
Jun 16, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改结算手续费bug,修改净值计算bug
parent
629021f0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
bill.py
api/bill.py
+2
-2
nav.py
api/nav.py
+8
-3
bill.py
model/bill.py
+1
-0
No files found.
api/bill.py
View file @
dc21a972
...
@@ -154,8 +154,8 @@ async def create_staking_api(
...
@@ -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
,
assets
,
adjust_assets
,
pending_assets
,
staking_assets
,
nodes
=
await
query_fund_assets_and_nodes
(
fund_collect
,
fund_id
=
create_staking_bill
.
fund_id
,
fund_id
=
create_staking_bill
.
fund_id
,
fund_status
=
FundStatus
.
active
)
fund_status
=
FundStatus
.
active
)
assert
assets
.
get
(
create_staking_bill
.
currency
,
0
)
>=
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
assets
[
create_staking_bill
.
currency
]
-=
create_staking_bill
.
volume
+
create_staking_bill
.
fee
# 防止增加的币种没有 设置默认值
# 防止增加的币种没有 设置默认值
pending_assets
.
setdefault
(
create_staking_bill
.
currency
,
0
)
pending_assets
.
setdefault
(
create_staking_bill
.
currency
,
0
)
pending_assets
[
create_staking_bill
.
currency
]
+=
create_staking_bill
.
volume
pending_assets
[
create_staking_bill
.
currency
]
+=
create_staking_bill
.
volume
...
...
api/nav.py
View file @
dc21a972
import
datetime
import
datetime
from
typing
import
Optional
from
typing
import
Optional
import
re
from
loguru
import
logger
import
pytz
import
pytz
from
fastapi
import
APIRouter
,
Depends
,
Query
,
Body
from
fastapi
import
APIRouter
,
Depends
,
Query
,
Body
from
fastapi.background
import
BackgroundTasks
from
fastapi.background
import
BackgroundTasks
...
@@ -83,11 +84,15 @@ async def recalculate_nav(
...
@@ -83,11 +84,15 @@ async def recalculate_nav(
background_task
:
BackgroundTasks
,
background_task
:
BackgroundTasks
,
start
:
datetime
.
datetime
=
Query
(
...
,
title
=
"开始时间"
),
start
:
datetime
.
datetime
=
Query
(
...
,
title
=
"开始时间"
),
end
:
datetime
.
datetime
=
Query
(
None
,
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
()
end
=
end
or
datetime
.
datetime
.
utcnow
()
delta
=
end
-
start
delta
=
end
-
start
for
i
in
range
(
delta
.
days
+
1
):
for
i
in
range
(
delta
.
days
):
date
=
start
+
datetime
.
timedelta
(
days
=
i
)
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
)
background_task
.
add_task
(
calculate_nav
,
fund_id
=
fund_id
,
calc_time
=
date
,
update_fund
=
False
)
response
=
Response
(
data
=
True
)
response
=
Response
(
data
=
True
)
return
response
return
response
model/bill.py
View file @
dc21a972
...
@@ -51,6 +51,7 @@ class StakingBill(MyBaseModel):
...
@@ -51,6 +51,7 @@ class StakingBill(MyBaseModel):
pub_key
:
str
=
Field
(
...
,
description
=
'节点key'
)
pub_key
:
str
=
Field
(
...
,
description
=
'节点key'
)
remark
:
str
=
Field
(
default
=
""
,
description
=
"备注"
)
remark
:
str
=
Field
(
default
=
""
,
description
=
"备注"
)
record_time
:
int
=
Field
(
default_factory
=
utc_now_timestamp
,
description
=
'记录时间'
)
record_time
:
int
=
Field
(
default_factory
=
utc_now_timestamp
,
description
=
'记录时间'
)
fee
:
float
=
Field
(
0
,
description
=
"手续费"
)
class
AdjustBill
(
MyBaseModel
):
class
AdjustBill
(
MyBaseModel
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment