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:
qianyun210603 2022-11-07 23:37:18 +08:00 коммит произвёл GitHub
Родитель 2fae407b19
Коммит 94e420f755
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 35 добавлений и 19 удалений

Просмотреть файл

@ -253,7 +253,7 @@ class ModelRunner:
default "" indicates that
qlib_uri : str
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
the name of the experiment folder
wait_before_rm_env : bool

Просмотреть файл

@ -244,7 +244,7 @@ def backtest(
benchmark: str
the benchmark for reporting.
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`:
Using Account with only initial cash
For `Position`:

Просмотреть файл

@ -236,7 +236,7 @@ class Account:
if not self.current_position.skip_update():
stock_list = self.current_position.get_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):
continue
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
:param risk_degree:
:type risk_degree: float
:param pred_date: the date the score is predicted
:type pred_date: pd.Timestamp
:param trade_date: the date the stock is traded
:type trade_date: pd.Timestamp
:param pred_start_time:
:type pred_start_time: pd.Timestamp
:param pred_end_time:
: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
"""
@ -72,10 +76,14 @@ class OrderGenWInteract(OrderGenerator):
:type target_weight_position: dict
:param risk_degree:
:type risk_degree: float
:param pred_date:
:type pred_date: pd.Timestamp
:param trade_date:
:type trade_date: pd.Timestamp
:param pred_start_time:
:type pred_start_time: pd.Timestamp
:param pred_end_time:
: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
"""
@ -147,9 +155,12 @@ class OrderGenWOInteract(OrderGenerator):
) -> list:
"""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.
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.
generate order list directly not using the information (e.g. whether can be traded, the accurate trade price)
at trade date.
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:
:type current: Position
@ -159,10 +170,14 @@ class OrderGenWOInteract(OrderGenerator):
:type target_weight_position: dict
:param risk_degree:
:type risk_degree: float
:param pred_date:
:type pred_date: pd.Timestamp
:param trade_date:
:type trade_date: pd.Timestamp
:param pred_start_time:
:type pred_start_time: pd.Timestamp
:param pred_end_time:
: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
"""
@ -185,7 +200,8 @@ class OrderGenWOInteract(OrderGenerator):
* target_weight_position[stock_id]
/ 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.
elif stock_id in current_stock:
amount_dict[stock_id] = (