Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
R
robo-dividend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wenwen.tang
robo-dividend
Commits
2b9e7ee0
Commit
2b9e7ee0
authored
Jan 06, 2023
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6258
parent
c7eac260
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
robo_executor.py
robo_executor.py
+30
-30
No files found.
robo_executor.py
View file @
2b9e7ee0
...
...
@@ -90,36 +90,36 @@ class BacktestExecutor(RoboExecutor):
self
.
_rule
.
clear_signal
()
def
start_exec
(
self
):
if
self
.
is_sync_data
:
for
sync
in
self
.
_syncs
:
sync
.
do_sync
()
if
self
.
is_clean_up
:
self
.
clear_datas
()
if
self
.
start_step
.
within
(
BacktestStep
.
EWMA_VALUE
)
and
self
.
end_step
.
without
(
BacktestStep
.
EWMA_VALUE
):
logger
.
info
(
"start to build fund ewma value."
.
center
(
50
,
'-'
))
now
=
dt
.
now
()
wait
([
self
.
async_build_risk_date
(
x
[
'id'
])
for
x
in
self
.
_datum
.
get_datums
(
type
=
DatumType
.
FUND
,
risk
=
(
3
,
4
,
5
))])
logger
.
info
(
f
"build fund ewma value success, use[{(dt.now() - now).seconds}s]"
)
if
self
.
start_step
.
within
(
BacktestStep
.
ASSET_POOL
)
and
self
.
end_step
.
without
(
BacktestStep
.
ASSET_POOL
):
logger
.
info
(
"start to build asset pool"
.
center
(
50
,
'-'
))
now
=
dt
.
now
()
workdays
=
workday_range
(
self
.
start_date
,
self
.
end_date
)
for
date
in
workdays
:
self
.
_risk
.
get_risk_pool
(
date
)
for
date
in
workdays
:
self
.
_pool
.
get_pool
(
date
)
logger
.
info
(
f
"build asset pool success, use[{(dt.now() - now).seconds}s]"
)
if
self
.
start_step
.
within
(
BacktestStep
.
NORMAL_PORTFOLIO
)
and
self
.
end_step
.
without
(
BacktestStep
.
NORMAL_PORTFOLIO
):
logger
.
info
(
"start to build normal portfolios"
.
center
(
50
,
'-'
))
now
=
dt
.
now
()
wait
([
self
.
async_build_portfolios
(
day
,
risk
)
for
risk
in
PortfoliosRisk
for
day
in
workday_range
(
self
.
start_date
,
self
.
end_date
)])
logger
.
info
(
f
"build normal portfolios success, use[{(dt.now() - now).seconds}s]"
)
if
self
.
start_step
.
within
(
BacktestStep
.
HOLD_PORTFOLIO
)
and
self
.
end_step
.
without
(
BacktestStep
.
HOLD_PORTFOLIO
):
logger
.
info
(
"start to build hold portfolios"
.
center
(
50
,
'-'
))
now
=
dt
.
now
()
wait
([
self
.
async_build_hold
(
x
)
for
x
in
PortfoliosRisk
])
logger
.
info
(
f
"build hold portfolios success, use[{(dt.now() - now).seconds}s]"
)
logger
.
info
(
"start to export report"
.
center
(
50
,
'-'
))
#
if self.is_sync_data:
#
for sync in self._syncs:
#
sync.do_sync()
#
if self.is_clean_up:
#
self.clear_datas()
#
if self.start_step.within(BacktestStep.EWMA_VALUE) and self.end_step.without(BacktestStep.EWMA_VALUE):
#
logger.info("start to build fund ewma value.".center(50, '-'))
#
now = dt.now()
#
wait([self.async_build_risk_date(x['id']) for x in self._datum.get_datums(type=DatumType.FUND, risk=(3, 4, 5))])
#
logger.info(f"build fund ewma value success, use[{(dt.now() - now).seconds}s]")
#
if self.start_step.within(BacktestStep.ASSET_POOL) and self.end_step.without(BacktestStep.ASSET_POOL):
#
logger.info("start to build asset pool".center(50, '-'))
#
now = dt.now()
#
workdays = workday_range(self.start_date, self.end_date)
#
for date in workdays:
#
self._risk.get_risk_pool(date)
#
for date in workdays:
#
self._pool.get_pool(date)
#
logger.info(f"build asset pool success, use[{(dt.now() - now).seconds}s]")
#
if self.start_step.within(BacktestStep.NORMAL_PORTFOLIO) and self.end_step.without(BacktestStep.NORMAL_PORTFOLIO):
#
logger.info("start to build normal portfolios".center(50, '-'))
#
now = dt.now()
#
wait([self.async_build_portfolios(day, risk) for risk in PortfoliosRisk for day in workday_range(self.start_date, self.end_date)])
#
logger.info(f"build normal portfolios success, use[{(dt.now() - now).seconds}s]")
#
if self.start_step.within(BacktestStep.HOLD_PORTFOLIO) and self.end_step.without(BacktestStep.HOLD_PORTFOLIO):
#
logger.info("start to build hold portfolios".center(50, '-'))
#
now = dt.now()
#
wait([self.async_build_hold(x) for x in PortfoliosRisk])
#
logger.info(f"build hold portfolios success, use[{(dt.now() - now).seconds}s]")
#
logger.info("start to export report".center(50, '-'))
now
=
dt
.
now
()
file
=
self
.
_export
.
export
(
max_date
=
self
.
end_date
)
logger
.
info
(
f
"report file[{os.path.basename(file)}] exported successfully. use[{(dt.now() - now).seconds}s]."
)
...
...
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