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
be00aa47
Commit
be00aa47
authored
Jun 16, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改每小时整点15结算净值
计算净值取上一小时收盘价
parent
dc21a972
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
7 deletions
+5
-7
fund.py
api/fund.py
+1
-1
scheduler.py
api/scheduler.py
+1
-1
nav.py
service/nav.py
+1
-1
price.py
service/price.py
+1
-1
scheduler.py
service/scheduler.py
+1
-3
No files found.
api/fund.py
View file @
be00aa47
...
@@ -55,7 +55,7 @@ async def create(
...
@@ -55,7 +55,7 @@ async def create(
trigger
=
"cron"
,
trigger
=
"cron"
,
timezone
=
pytz
.
UTC
,
timezone
=
pytz
.
UTC
,
hour
=
time_obj
.
hour
,
hour
=
time_obj
.
hour
,
minute
=
time_obj
.
minute
,
minute
=
15
,
args
=
[
data
[
"id"
]],
args
=
[
data
[
"id"
]],
id
=
job_id
,
id
=
job_id
,
misfire_grace_time
=
60
*
60
misfire_grace_time
=
60
*
60
...
...
api/scheduler.py
View file @
be00aa47
...
@@ -31,7 +31,7 @@ async def create(
...
@@ -31,7 +31,7 @@ async def create(
trigger
=
"cron"
,
trigger
=
"cron"
,
timezone
=
pytz
.
UTC
,
timezone
=
pytz
.
UTC
,
hour
=
time_obj
.
hour
,
hour
=
time_obj
.
hour
,
minute
=
time_obj
.
minute
,
minute
=
15
,
args
=
[
fund_id
],
args
=
[
fund_id
],
id
=
job_id
id
=
job_id
)
)
...
...
service/nav.py
View file @
be00aa47
...
@@ -69,7 +69,7 @@ async def calculate_nav(fund_id, calc_time: datetime.datetime = None, beach_serv
...
@@ -69,7 +69,7 @@ async def calculate_nav(fund_id, calc_time: datetime.datetime = None, beach_serv
if
calc_time
:
if
calc_time
:
# mongodb 查询历史数据
# mongodb 查询历史数据
hour_price_collect
=
get_hour_price_collect
(
app
.
state
.
mongodb_manager
)
hour_price_collect
=
get_hour_price_collect
(
app
.
state
.
mongodb_manager
)
price_data
=
await
get_price
(
list
(
amount
),
calc_time
,
hour_price_collect
)
price_data
=
await
get_price
(
list
(
amount
),
calc_time
-
datetime
.
timedelta
(
hours
=
1
)
,
hour_price_collect
)
else
:
else
:
# redis 查询最新数据
# redis 查询最新数据
redis_client
=
get_cmc_price_redis
(
app
.
state
.
redis_manager
)
redis_client
=
get_cmc_price_redis
(
app
.
state
.
redis_manager
)
...
...
service/price.py
View file @
be00aa47
...
@@ -305,7 +305,7 @@ async def get_price(coin_list, query_time, db_client) -> Dict[str, float]:
...
@@ -305,7 +305,7 @@ async def get_price(coin_list, query_time, db_client) -> Dict[str, float]:
cursor
=
db_client
.
find
({
'time'
:
query_time
,
"symbol"
:
{
"$in"
:
coin_list_copy
}})
cursor
=
db_client
.
find
({
'time'
:
query_time
,
"symbol"
:
{
"$in"
:
coin_list_copy
}})
temp_res
=
await
cursor
.
to_list
(
length
=
None
)
temp_res
=
await
cursor
.
to_list
(
length
=
None
)
for
item
in
temp_res
:
for
item
in
temp_res
:
result_dict
[
item
[
'symbol'
]]
=
item
[
'
open
'
]
result_dict
[
item
[
'symbol'
]]
=
item
[
'
close
'
]
return
result_dict
return
result_dict
...
...
service/scheduler.py
View file @
be00aa47
import
datetime
import
datetime
import
pytz
import
pytz
from
exception.db
import
NotFundError
from
exception.db
import
NotFundError
from
model.bill
import
StakingBill
from
model.bill
import
StakingBill
from
schema.fund
import
FundStatus
from
schema.fund
import
FundStatus
...
@@ -60,7 +58,7 @@ async def calculate_nav_task(fund_id=None):
...
@@ -60,7 +58,7 @@ async def calculate_nav_task(fund_id=None):
from
main
import
app
from
main
import
app
fund_collect
=
get_fund_collect
(
app
.
state
.
mongodb_manager
)
fund_collect
=
get_fund_collect
(
app
.
state
.
mongodb_manager
)
if
fund_id
:
if
fund_id
:
await
calculate_nav
(
fund_id
)
await
calculate_nav
(
fund_id
,
calc_time
=
datetime
.
datetime
.
utcnow
()
)
else
:
else
:
data
=
fund_collect
.
find
({
"status"
:
FundStatus
.
active
})
data
=
fund_collect
.
find
({
"status"
:
FundStatus
.
active
})
fund_list
=
await
data
.
to_list
(
length
=
None
)
fund_list
=
await
data
.
to_list
(
length
=
None
)
...
...
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