Skip to content

Commit

Permalink
1) Add exclude_modules param to gen_exports
Browse files Browse the repository at this point in the history
2) Fix tests
  • Loading branch information
foolcage committed Dec 18, 2024
1 parent a1dfffa commit 4f14cda
Show file tree
Hide file tree
Showing 38 changed files with 369 additions and 267 deletions.
2 changes: 1 addition & 1 deletion src/zvt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def old_db_to_provider_dir(data_path):

if platform.system() == "Windows":
try:
import zvt.recorders.qmt.quotes.qmt_kdata_recorder as qmt_kdata_recorde
import zvt.recorders.qmt as qmt_recorder
except Exception as e:
logger.error("QMT not work", e)
else:
Expand Down
3 changes: 3 additions & 0 deletions src/zvt/autocode/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def gen_exports(
dir_path="./domain",
gen_flag="# the __all__ is generated",
export_from_package=False,
exclude_modules=None,
export_modules=None,
excludes=None,
export_var=False,
Expand Down Expand Up @@ -160,6 +161,8 @@ def gen_exports(
dir_path = os.path.dirname(file)
modules = all_sub_modules(dir_path)
if modules:
if exclude_modules:
modules = set(modules) - set(exclude_modules)
if export_modules:
modules = set(modules) & set(export_modules)
lines.append(
Expand Down
22 changes: 22 additions & 0 deletions src/zvt/domain/meta/stockhk_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ class Stockhk(StockhkMetaBase, TradableEntity):
#: 是否属于港股通
south = Column(Boolean)

@classmethod
def get_trading_t(cls):
"""
0 means t+0
1 means t+1
:return:
"""
return 0

@classmethod
def get_trading_intervals(cls, include_bidding_time=False):
"""
overwrite it to get the trading intervals of the entity
:return: list of time intervals, in format [(start,end)]
"""
if include_bidding_time:
return [("09:15", "12:00"), ("13:00", "16:00")]
else:
return [("09:30", "12:00"), ("13:00", "16:00")]


register_schema(providers=["em"], db_name="stockhk_meta", schema_base=StockhkMetaBase)

Expand Down
4 changes: 2 additions & 2 deletions src/zvt/fill_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def gen_kdata_schemas():
# gen_exports('trader')
# gen_exports('autocode')
# gen_exports("zhdate")
# gen_exports("recorders", export_from_package=True)
gen_exports("tag", export_from_package=False)
gen_exports("recorders", export_from_package=True, exclude_modules=["qmt"])
# gen_exports("tag", export_from_package=False)
# gen_kdata_schemas()
# zip_dir(ZVT_TEST_DATA_PATH, zip_file_name=DATA_SAMPLE_ZIP_PATH)
62 changes: 28 additions & 34 deletions src/zvt/recorders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,56 +73,50 @@ def init_main_index(provider="exchange"):
# common code of the package
# export interface in __all__ which contains __all__ of its sub modules

# import all from submodule joinquant
from .joinquant import *
from .joinquant import __all__ as _joinquant_all

__all__ += _joinquant_all

# import all from submodule exchange
from .exchange import *
from .exchange import __all__ as _exchange_all

__all__ += _exchange_all

# import all from submodule em
from .em import *
from .em import __all__ as _em_all
# import all from submodule sina
from .sina import *
from .sina import __all__ as _sina_all

__all__ += _em_all
__all__ += _sina_all

# import all from submodule wb
from .wb import *
from .wb import __all__ as _wb_all
# import all from submodule jqka
from .jqka import *
from .jqka import __all__ as _jqka_all

__all__ += _wb_all
__all__ += _jqka_all

# import all from submodule consts
from .consts import *
from .consts import __all__ as _consts_all

__all__ += _consts_all

# import all from submodule jqka
from .jqka import *
from .jqka import __all__ as _jqka_all

__all__ += _jqka_all

# import all from submodule eastmoney
from .eastmoney import *
from .eastmoney import __all__ as _eastmoney_all

__all__ += _eastmoney_all

# import all from submodule qmt
from .qmt import *
from .qmt import __all__ as _qmt_all
# import all from submodule joinquant
from .joinquant import *
from .joinquant import __all__ as _joinquant_all

__all__ += _qmt_all
__all__ += _joinquant_all

# import all from submodule sina
from .sina import *
from .sina import __all__ as _sina_all
# import all from submodule exchange
from .exchange import *
from .exchange import __all__ as _exchange_all

__all__ += _sina_all
__all__ += _exchange_all

# import all from submodule wb
from .wb import *
from .wb import __all__ as _wb_all

__all__ += _wb_all

# import all from submodule em
from .em import *
from .em import __all__ as _em_all

__all__ += _em_all
29 changes: 15 additions & 14 deletions src/zvt/recorders/eastmoney/__init__.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
# -*- coding: utf-8 -*-#


# the __all__ is generated
__all__ = []

# __init__.py structure:
# common code of the package
# export interface in __all__ which contains __all__ of its sub modules

# import all from submodule meta
from .meta import *
from .meta import __all__ as _meta_all

__all__ += _meta_all

# import all from submodule holder
from .holder import *
from .holder import __all__ as _holder_all

__all__ += _holder_all

# import all from submodule common
from .common import *
from .common import __all__ as _common_all
# import all from submodule trading
from .trading import *
from .trading import __all__ as _trading_all

__all__ += _common_all
__all__ += _trading_all

# import all from submodule finance
from .finance import *
from .finance import __all__ as _finance_all

__all__ += _finance_all

# import all from submodule common
from .common import *
from .common import __all__ as _common_all

__all__ += _common_all

# import all from submodule dividend_financing
from .dividend_financing import *
from .dividend_financing import __all__ as _dividend_financing_all

__all__ += _dividend_financing_all

# import all from submodule trading
from .trading import *
from .trading import __all__ as _trading_all
# import all from submodule meta
from .meta import *
from .meta import __all__ as _meta_all

__all__ += _trading_all
__all__ += _meta_all
24 changes: 12 additions & 12 deletions src/zvt/recorders/eastmoney/dividend_financing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
# common code of the package
# export interface in __all__ which contains __all__ of its sub modules

# import all from submodule eastmoney_dividend_detail_recorder
from .eastmoney_dividend_detail_recorder import *
from .eastmoney_dividend_detail_recorder import __all__ as _eastmoney_dividend_detail_recorder_all

__all__ += _eastmoney_dividend_detail_recorder_all

# import all from submodule eastmoney_dividend_financing_recorder
from .eastmoney_dividend_financing_recorder import *
from .eastmoney_dividend_financing_recorder import __all__ as _eastmoney_dividend_financing_recorder_all

__all__ += _eastmoney_dividend_financing_recorder_all

# import all from submodule eastmoney_rights_issue_detail_recorder
from .eastmoney_rights_issue_detail_recorder import *
from .eastmoney_rights_issue_detail_recorder import __all__ as _eastmoney_rights_issue_detail_recorder_all

__all__ += _eastmoney_rights_issue_detail_recorder_all

# import all from submodule eastmoney_dividend_detail_recorder
from .eastmoney_dividend_detail_recorder import *
from .eastmoney_dividend_detail_recorder import __all__ as _eastmoney_dividend_detail_recorder_all

__all__ += _eastmoney_dividend_detail_recorder_all

# import all from submodule eastmoney_spo_detail_recorder
from .eastmoney_spo_detail_recorder import *
from .eastmoney_spo_detail_recorder import __all__ as _eastmoney_spo_detail_recorder_all

__all__ += _eastmoney_spo_detail_recorder_all

# import all from submodule eastmoney_dividend_financing_recorder
from .eastmoney_dividend_financing_recorder import *
from .eastmoney_dividend_financing_recorder import __all__ as _eastmoney_dividend_financing_recorder_all

__all__ += _eastmoney_dividend_financing_recorder_all
13 changes: 7 additions & 6 deletions src/zvt/recorders/eastmoney/finance/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-#


# the __all__ is generated
__all__ = []

Expand All @@ -13,6 +14,12 @@

__all__ += _eastmoney_finance_factor_recorder_all

# import all from submodule eastmoney_cash_flow_recorder
from .eastmoney_cash_flow_recorder import *
from .eastmoney_cash_flow_recorder import __all__ as _eastmoney_cash_flow_recorder_all

__all__ += _eastmoney_cash_flow_recorder_all

# import all from submodule eastmoney_income_statement_recorder
from .eastmoney_income_statement_recorder import *
from .eastmoney_income_statement_recorder import __all__ as _eastmoney_income_statement_recorder_all
Expand All @@ -30,9 +37,3 @@
from .eastmoney_balance_sheet_recorder import __all__ as _eastmoney_balance_sheet_recorder_all

__all__ += _eastmoney_balance_sheet_recorder_all

# import all from submodule eastmoney_cash_flow_recorder
from .eastmoney_cash_flow_recorder import *
from .eastmoney_cash_flow_recorder import __all__ as _eastmoney_cash_flow_recorder_all

__all__ += _eastmoney_cash_flow_recorder_all
12 changes: 6 additions & 6 deletions src/zvt/recorders/eastmoney/holder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
# common code of the package
# export interface in __all__ which contains __all__ of its sub modules

# import all from submodule eastmoney_top_ten_tradable_holder_recorder
from .eastmoney_top_ten_tradable_holder_recorder import *
from .eastmoney_top_ten_tradable_holder_recorder import __all__ as _eastmoney_top_ten_tradable_holder_recorder_all

__all__ += _eastmoney_top_ten_tradable_holder_recorder_all

# import all from submodule eastmoney_top_ten_holder_recorder
from .eastmoney_top_ten_holder_recorder import *
from .eastmoney_top_ten_holder_recorder import __all__ as _eastmoney_top_ten_holder_recorder_all

__all__ += _eastmoney_top_ten_holder_recorder_all

# import all from submodule eastmoney_top_ten_tradable_holder_recorder
from .eastmoney_top_ten_tradable_holder_recorder import *
from .eastmoney_top_ten_tradable_holder_recorder import __all__ as _eastmoney_top_ten_tradable_holder_recorder_all

__all__ += _eastmoney_top_ten_tradable_holder_recorder_all

# import all from submodule eastmoney_stock_actor_recorder
from .eastmoney_stock_actor_recorder import *
from .eastmoney_stock_actor_recorder import __all__ as _eastmoney_stock_actor_recorder_all
Expand Down
1 change: 1 addition & 0 deletions src/zvt/recorders/eastmoney/meta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-#


# the __all__ is generated
__all__ = []

Expand Down
13 changes: 7 additions & 6 deletions src/zvt/recorders/eastmoney/trading/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# -*- coding: utf-8 -*-#


# the __all__ is generated
__all__ = []

# __init__.py structure:
# common code of the package
# export interface in __all__ which contains __all__ of its sub modules

# import all from submodule eastmoney_manager_trading_recorder
from .eastmoney_manager_trading_recorder import *
from .eastmoney_manager_trading_recorder import __all__ as _eastmoney_manager_trading_recorder_all

__all__ += _eastmoney_manager_trading_recorder_all

# import all from submodule eastmoney_holder_trading_recorder
from .eastmoney_holder_trading_recorder import *
from .eastmoney_holder_trading_recorder import __all__ as _eastmoney_holder_trading_recorder_all

__all__ += _eastmoney_holder_trading_recorder_all

# import all from submodule eastmoney_manager_trading_recorder
from .eastmoney_manager_trading_recorder import *
from .eastmoney_manager_trading_recorder import __all__ as _eastmoney_manager_trading_recorder_all

__all__ += _eastmoney_manager_trading_recorder_all
40 changes: 20 additions & 20 deletions src/zvt/recorders/em/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
# common code of the package
# export interface in __all__ which contains __all__ of its sub modules

# import all from submodule trading
from .trading import *
from .trading import __all__ as _trading_all

__all__ += _trading_all

# import all from submodule actor
from .actor import *
from .actor import __all__ as _actor_all

__all__ += _actor_all

# import all from submodule misc
from .misc import *
from .misc import __all__ as _misc_all
Expand All @@ -20,32 +32,20 @@

__all__ += _quotes_all

# import all from submodule meta
from .meta import *
from .meta import __all__ as _meta_all

__all__ += _meta_all

# import all from submodule macro
from .macro import *
from .macro import __all__ as _macro_all

__all__ += _macro_all

# import all from submodule em_api
from .em_api import *
from .em_api import __all__ as _em_api_all

__all__ += _em_api_all

# import all from submodule trading
from .trading import *
from .trading import __all__ as _trading_all
# import all from submodule macro
from .macro import *
from .macro import __all__ as _macro_all

__all__ += _trading_all
__all__ += _macro_all

# import all from submodule actor
from .actor import *
from .actor import __all__ as _actor_all
# import all from submodule meta
from .meta import *
from .meta import __all__ as _meta_all

__all__ += _actor_all
__all__ += _meta_all
Loading

0 comments on commit 4f14cda

Please sign in to comment.