зеркало из https://github.com/microsoft/qlib.git
Correct errors and typos in doc strings (#1338)
* add missing parameters to doc string in order_generate * fix some typos in doc strings * reformat base on code style standard * Update qlib/backtest/__init__.py * Update examples/run_all_model.py * Update examples/run_all_model.py Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
This commit is contained in:
Родитель
2fae407b19
Коммит
94e420f755
|
@ -253,7 +253,7 @@ class ModelRunner:
|
||||||
default "" indicates that
|
default "" indicates that
|
||||||
qlib_uri : str
|
qlib_uri : str
|
||||||
the uri to install qlib with pip
|
the uri to install qlib with pip
|
||||||
it could be url on the we or local path (NOTE: the local path must be a absolute path)
|
it could be URI on the remote or local path (NOTE: the local path must be an absolute path)
|
||||||
exp_folder_name: str
|
exp_folder_name: str
|
||||||
the name of the experiment folder
|
the name of the experiment folder
|
||||||
wait_before_rm_env : bool
|
wait_before_rm_env : bool
|
||||||
|
|
|
@ -244,7 +244,7 @@ def backtest(
|
||||||
benchmark: str
|
benchmark: str
|
||||||
the benchmark for reporting.
|
the benchmark for reporting.
|
||||||
account : Union[float, int, Position]
|
account : Union[float, int, Position]
|
||||||
information for describing how to creating the account
|
information for describing how to create the account
|
||||||
For `float` or `int`:
|
For `float` or `int`:
|
||||||
Using Account with only initial cash
|
Using Account with only initial cash
|
||||||
For `Position`:
|
For `Position`:
|
||||||
|
|
|
@ -236,7 +236,7 @@ class Account:
|
||||||
if not self.current_position.skip_update():
|
if not self.current_position.skip_update():
|
||||||
stock_list = self.current_position.get_stock_list()
|
stock_list = self.current_position.get_stock_list()
|
||||||
for code in stock_list:
|
for code in stock_list:
|
||||||
# if suspend, no new price to be updated, profit is 0
|
# if suspended, no new price to be updated, profit is 0
|
||||||
if trade_exchange.check_stock_suspended(code, trade_start_time, trade_end_time):
|
if trade_exchange.check_stock_suspended(code, trade_start_time, trade_end_time):
|
||||||
continue
|
continue
|
||||||
bar_close = cast(float, trade_exchange.get_close(code, trade_start_time, trade_end_time))
|
bar_close = cast(float, trade_exchange.get_close(code, trade_start_time, trade_end_time))
|
||||||
|
|
|
@ -33,10 +33,14 @@ class OrderGenerator:
|
||||||
:type target_weight_position: dict
|
:type target_weight_position: dict
|
||||||
:param risk_degree:
|
:param risk_degree:
|
||||||
:type risk_degree: float
|
:type risk_degree: float
|
||||||
:param pred_date: the date the score is predicted
|
:param pred_start_time:
|
||||||
:type pred_date: pd.Timestamp
|
:type pred_start_time: pd.Timestamp
|
||||||
:param trade_date: the date the stock is traded
|
:param pred_end_time:
|
||||||
:type trade_date: pd.Timestamp
|
:type pred_end_time: pd.Timestamp
|
||||||
|
:param trade_start_time:
|
||||||
|
:type trade_start_time: pd.Timestamp
|
||||||
|
:param trade_end_time:
|
||||||
|
:type trade_end_time: pd.Timestamp
|
||||||
|
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
|
@ -72,10 +76,14 @@ class OrderGenWInteract(OrderGenerator):
|
||||||
:type target_weight_position: dict
|
:type target_weight_position: dict
|
||||||
:param risk_degree:
|
:param risk_degree:
|
||||||
:type risk_degree: float
|
:type risk_degree: float
|
||||||
:param pred_date:
|
:param pred_start_time:
|
||||||
:type pred_date: pd.Timestamp
|
:type pred_start_time: pd.Timestamp
|
||||||
:param trade_date:
|
:param pred_end_time:
|
||||||
:type trade_date: pd.Timestamp
|
:type pred_end_time: pd.Timestamp
|
||||||
|
:param trade_start_time:
|
||||||
|
:type trade_start_time: pd.Timestamp
|
||||||
|
:param trade_end_time:
|
||||||
|
:type trade_end_time: pd.Timestamp
|
||||||
|
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
|
@ -147,9 +155,12 @@ class OrderGenWOInteract(OrderGenerator):
|
||||||
) -> list:
|
) -> list:
|
||||||
"""generate_order_list_from_target_weight_position
|
"""generate_order_list_from_target_weight_position
|
||||||
|
|
||||||
generate order list directly not using the information (e.g. whether can be traded, the accurate trade price) at trade date.
|
generate order list directly not using the information (e.g. whether can be traded, the accurate trade price)
|
||||||
In target weight position, generating order list need to know the price of objective stock in trade date, but we cannot get that
|
at trade date.
|
||||||
value when do not interact with exchange, so we check the %close price at pred_date or price recorded in current position.
|
In target weight position, generating order list need to know the price of objective stock in trade date,
|
||||||
|
but we cannot get that
|
||||||
|
value when do not interact with exchange, so we check the %close price at pred_date or price recorded
|
||||||
|
in current position.
|
||||||
|
|
||||||
:param current:
|
:param current:
|
||||||
:type current: Position
|
:type current: Position
|
||||||
|
@ -159,10 +170,14 @@ class OrderGenWOInteract(OrderGenerator):
|
||||||
:type target_weight_position: dict
|
:type target_weight_position: dict
|
||||||
:param risk_degree:
|
:param risk_degree:
|
||||||
:type risk_degree: float
|
:type risk_degree: float
|
||||||
:param pred_date:
|
:param pred_start_time:
|
||||||
:type pred_date: pd.Timestamp
|
:type pred_start_time: pd.Timestamp
|
||||||
:param trade_date:
|
:param pred_end_time:
|
||||||
:type trade_date: pd.Timestamp
|
:type pred_end_time: pd.Timestamp
|
||||||
|
:param trade_start_time:
|
||||||
|
:type trade_start_time: pd.Timestamp
|
||||||
|
:param trade_end_time:
|
||||||
|
:type trade_end_time: pd.Timestamp
|
||||||
|
|
||||||
:rtype: list of generated orders
|
:rtype: list of generated orders
|
||||||
"""
|
"""
|
||||||
|
@ -185,7 +200,8 @@ class OrderGenWOInteract(OrderGenerator):
|
||||||
* target_weight_position[stock_id]
|
* target_weight_position[stock_id]
|
||||||
/ trade_exchange.get_close(stock_id, start_time=pred_start_time, end_time=pred_end_time)
|
/ trade_exchange.get_close(stock_id, start_time=pred_start_time, end_time=pred_end_time)
|
||||||
)
|
)
|
||||||
# TODO: Qlib use None to represent trading suspension. So last close price can't be the estimated trading price.
|
# TODO: Qlib use None to represent trading suspension.
|
||||||
|
# So last close price can't be the estimated trading price.
|
||||||
# Maybe a close price with forward fill will be a better solution.
|
# Maybe a close price with forward fill will be a better solution.
|
||||||
elif stock_id in current_stock:
|
elif stock_id in current_stock:
|
||||||
amount_dict[stock_id] = (
|
amount_dict[stock_id] = (
|
||||||
|
|
Загрузка…
Ссылка в новой задаче