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
d519456a
Commit
d519456a
authored
May 22, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
当结算时间为00:00时,结算前一天的净值
parent
e01ae898
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
nav.py
service/nav.py
+7
-5
No files found.
service/nav.py
View file @
d519456a
...
...
@@ -13,9 +13,7 @@ from service.price import get_price
async
def
calculate_nav
(
fund_id
,
calc_time
=
None
,
beach_service
=
BeaconChaService
()):
# todo 测试
calc_time
=
datetime
.
datetime
.
utcnow
()
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
pytz
.
UTC
)
-
datetime
.
timedelta
(
hours
=
2
)
date
=
datetime
.
datetime
.
utcnow
()
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
pytz
.
UTC
)
calc_time
=
datetime
.
datetime
.
utcnow
()
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
pytz
.
UTC
)
from
main
import
app
fund_collect
=
get_fund_collect
(
app
.
state
.
mongodb_manager
)
logger
.
info
(
f
'[定时任务开始执行] [计算净值] {fund_id} '
)
...
...
@@ -66,11 +64,15 @@ async def calculate_nav(fund_id, calc_time=None, beach_service=BeaconChaService(
"bill_type"
:
{
"$in"
:
[
"adjust"
,
"sub"
,
"redemption"
]}
})
result
=
await
cursor
.
to_list
(
length
=
None
)
total_fund_share
=
sum
(
-
item
[
"fund_share"
]
if
item
[
"bill_type"
]
==
"redemption"
else
item
[
"fund_share"
]
for
item
in
result
)
total_fund_share
=
sum
(
-
item
[
"fund_share"
]
if
item
[
"bill_type"
]
==
"redemption"
else
item
[
"fund_share"
]
for
item
in
result
)
value
=
sum
(
nav
.
values
())
net_value
=
round
(
value
/
total_fund_share
,
2
)
if
total_fund_share
else
fund_data
[
"base_nav"
]
net_value
=
round
(
value
/
total_fund_share
,
2
)
if
total_fund_share
>
0
else
fund_data
[
"base_nav"
]
await
fund_collect
.
update_one
({
'id'
:
fund_id
},
{
"$set"
:
{
"nva"
:
net_value
}})
nav_collect
=
get_nav_collect
(
app
.
state
.
mongodb_manager
)
date
=
datetime
.
datetime
.
utcnow
()
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
pytz
.
UTC
)
if
fund_data
[
"settlement_time"
]
==
"00:00"
:
date
-=
datetime
.
timedelta
(
days
=
1
)
nav_record
=
await
nav_collect
.
find_one
({
"fund_id"
:
fund_id
,
"record_date"
:
date
})
if
nav_record
:
error
=
f
'重复净值记录 [{nav_record}] [mongo] [{date}]'
...
...
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