Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add missing parameters to doc string in order_generate
  • Loading branch information
qianyun210603 committed Nov 5, 2022
commit 19747d02aec7e776b73c82e74a1248effc104d60
48 changes: 32 additions & 16 deletions qlib/contrib/strategy/order_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ def generate_order_list_from_target_weight_position(
: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
"""
Expand Down Expand Up @@ -72,10 +76,14 @@ def generate_order_list_from_target_weight_position(
: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
"""
Expand Down Expand Up @@ -147,9 +155,12 @@ def generate_order_list_from_target_weight_position(
) -> 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
Expand All @@ -159,10 +170,14 @@ def generate_order_list_from_target_weight_position(
: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
"""
Expand All @@ -185,7 +200,8 @@ def generate_order_list_from_target_weight_position(
* 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] = (
Expand Down