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
36651735
Commit
36651735
authored
Nov 10, 2022
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
依赖注入实现中
parent
228349ea
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
54 deletions
+15
-54
api.py
api.py
+0
-13
impl.py
datas/impl.py
+0
-16
__env_config.py
framework/__env_config.py
+11
-3
fund_optimize.py
fund_pool/fund_optimize.py
+3
-2
service.py
fund_pool/service.py
+0
-12
main.py
main.py
+1
-8
No files found.
api.py
deleted
100644 → 0
View file @
228349ea
from
abc
import
ABCMeta
,
abstractmethod
class
BaseBean
(
metaclass
=
ABCMeta
):
@
abstractmethod
def
do_something
(
self
):
pass
class
ServiceBean
(
metaclass
=
ABCMeta
):
@
abstractmethod
def
do_service
(
self
):
pass
datas/impl.py
deleted
100644 → 0
View file @
228349ea
from
api
import
BaseBean
from
framework
import
component
@
component
(
bean_name
=
"one"
)
class
OneImplBean
(
BaseBean
):
def
do_something
(
self
):
print
(
"one bean"
)
@
component
(
bean_name
=
"two"
)
class
TwoImplBean
(
BaseBean
):
def
do_something
(
self
):
print
(
"two bean"
)
\ No newline at end of file
framework/__env_config.py
View file @
36651735
import
os
import
re
from
functools
import
partial
from
functools
import
partial
,
reduce
from
.base
import
*
import
yaml
...
...
@@ -72,7 +72,7 @@ def env_var_constructor(loader, node, raw=False):
return
value
if
raw
else
yaml
.
safe_load
(
value
)
def
get
_config
(
config_name
=
None
):
def
build
_config
(
config_name
=
None
):
CONFIG_NAME
=
config_name
or
'config.yml'
path
=
f
'{get_project_path()}{os.path.sep}{CONFIG_NAME}'
with
open
(
path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
...
...
@@ -89,4 +89,12 @@ yaml.add_implicit_resolver(
'!env_var'
,
IMPLICIT_ENV_VAR_MATCHER
,
Loader
=
yaml
.
SafeLoader
)
config
=
get_config
()
config
=
build_config
()
def
get_config
(
module
:
str
):
result
=
config
if
module
:
for
name
in
module
.
split
(
'.'
):
result
=
result
[
name
]
if
name
in
result
else
{}
return
result
fund_pool/fund_optimize.py
View file @
36651735
import
pandas
as
pd
from
framework
import
filter_weekend
,
config
,
dict_remove
from
framework
import
filter_weekend
,
config
,
dict_remove
,
get_config
from
datas
import
navs
from
dateutil.relativedelta
import
relativedelta
from
empyrical
import
sortino_ratio
optimize_config
=
config
[
'fund_pool'
][
'fund_optimize'
]
if
'fund_pool'
in
config
and
'fund_optimize'
in
config
[
'fund_pool'
]
else
{}
optimize_config
=
get_config
(
__name__
)
sortino_config
=
[{
**
x
,
'name'
:
[
f
"sortino_{y[1]}_{y[0]}"
for
y
in
x
.
items
()
if
y
[
0
]
!=
'weight'
][
0
]}
for
x
in
optimize_config
[
'sortino_weight'
]]
\
if
'sortino_weight'
in
optimize_config
else
[]
...
...
fund_pool/service.py
deleted
100644 → 0
View file @
228349ea
from
api
import
BaseBean
,
ServiceBean
from
framework
import
autowired
,
component
@
component
class
ServiceImpl
(
ServiceBean
):
@
autowired
def
__init__
(
self
,
base
:
BaseBean
=
None
):
self
.
_base
=
base
def
do_service
(
self
):
self
.
_base
.
do_something
()
\ No newline at end of file
main.py
View file @
36651735
from
framework
import
logger
,
autowired
from
api
import
ServiceBean
@
autowired
def
test
(
service
:
ServiceBean
=
None
):
service
.
do_service
()
from
framework
import
logger
if
__name__
==
'__main__'
:
logger
.
info
(
dir
())
test
()
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