Skip to content

Commit 94e420f

Browse files
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>
1 parent 2fae407 commit 94e420f

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

examples/run_all_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def run(
253253
default "" indicates that
254254
qlib_uri : str
255255
the uri to install qlib with pip
256-
it could be url on the we or local path (NOTE: the local path must be a absolute path)
256+
it could be URI on the remote or local path (NOTE: the local path must be an absolute path)
257257
exp_folder_name: str
258258
the name of the experiment folder
259259
wait_before_rm_env : bool

qlib/backtest/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def backtest(
244244
benchmark: str
245245
the benchmark for reporting.
246246
account : Union[float, int, Position]
247-
information for describing how to creating the account
247+
information for describing how to create the account
248248
For `float` or `int`:
249249
Using Account with only initial cash
250250
For `Position`:

qlib/backtest/account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def update_current_position(
236236
if not self.current_position.skip_update():
237237
stock_list = self.current_position.get_stock_list()
238238
for code in stock_list:
239-
# if suspend, no new price to be updated, profit is 0
239+
# if suspended, no new price to be updated, profit is 0
240240
if trade_exchange.check_stock_suspended(code, trade_start_time, trade_end_time):
241241
continue
242242
bar_close = cast(float, trade_exchange.get_close(code, trade_start_time, trade_end_time))

qlib/contrib/strategy/order_generator.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ def generate_order_list_from_target_weight_position(
3333
:type target_weight_position: dict
3434
:param risk_degree:
3535
:type risk_degree: float
36-
:param pred_date: the date the score is predicted
37-
:type pred_date: pd.Timestamp
38-
:param trade_date: the date the stock is traded
39-
:type trade_date: pd.Timestamp
36+
:param pred_start_time:
37+
:type pred_start_time: pd.Timestamp
38+
:param pred_end_time:
39+
:type pred_end_time: pd.Timestamp
40+
:param trade_start_time:
41+
:type trade_start_time: pd.Timestamp
42+
:param trade_end_time:
43+
:type trade_end_time: pd.Timestamp
4044
4145
:rtype: list
4246
"""
@@ -72,10 +76,14 @@ def generate_order_list_from_target_weight_position(
7276
:type target_weight_position: dict
7377
:param risk_degree:
7478
:type risk_degree: float
75-
:param pred_date:
76-
:type pred_date: pd.Timestamp
77-
:param trade_date:
78-
:type trade_date: pd.Timestamp
79+
:param pred_start_time:
80+
:type pred_start_time: pd.Timestamp
81+
:param pred_end_time:
82+
:type pred_end_time: pd.Timestamp
83+
:param trade_start_time:
84+
:type trade_start_time: pd.Timestamp
85+
:param trade_end_time:
86+
:type trade_end_time: pd.Timestamp
7987
8088
:rtype: list
8189
"""
@@ -147,9 +155,12 @@ def generate_order_list_from_target_weight_position(
147155
) -> list:
148156
"""generate_order_list_from_target_weight_position
149157
150-
generate order list directly not using the information (e.g. whether can be traded, the accurate trade price) at trade date.
151-
In target weight position, generating order list need to know the price of objective stock in trade date, but we cannot get that
152-
value when do not interact with exchange, so we check the %close price at pred_date or price recorded in current position.
158+
generate order list directly not using the information (e.g. whether can be traded, the accurate trade price)
159+
at trade date.
160+
In target weight position, generating order list need to know the price of objective stock in trade date,
161+
but we cannot get that
162+
value when do not interact with exchange, so we check the %close price at pred_date or price recorded
163+
in current position.
153164
154165
:param current:
155166
:type current: Position
@@ -159,10 +170,14 @@ def generate_order_list_from_target_weight_position(
159170
:type target_weight_position: dict
160171
:param risk_degree:
161172
:type risk_degree: float
162-
:param pred_date:
163-
:type pred_date: pd.Timestamp
164-
:param trade_date:
165-
:type trade_date: pd.Timestamp
173+
:param pred_start_time:
174+
:type pred_start_time: pd.Timestamp
175+
:param pred_end_time:
176+
:type pred_end_time: pd.Timestamp
177+
:param trade_start_time:
178+
:type trade_start_time: pd.Timestamp
179+
:param trade_end_time:
180+
:type trade_end_time: pd.Timestamp
166181
167182
:rtype: list of generated orders
168183
"""
@@ -185,7 +200,8 @@ def generate_order_list_from_target_weight_position(
185200
* target_weight_position[stock_id]
186201
/ trade_exchange.get_close(stock_id, start_time=pred_start_time, end_time=pred_end_time)
187202
)
188-
# TODO: Qlib use None to represent trading suspension. So last close price can't be the estimated trading price.
203+
# TODO: Qlib use None to represent trading suspension.
204+
# So last close price can't be the estimated trading price.
189205
# Maybe a close price with forward fill will be a better solution.
190206
elif stock_id in current_stock:
191207
amount_dict[stock_id] = (

0 commit comments

Comments
 (0)