1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-17 17:34:35 +08:00

Reformat code with black.

This commit is contained in:
Charles Young
2021-02-22 10:29:29 +08:00
parent b8647c13c7
commit 2f9d45e03a
56 changed files with 218 additions and 713 deletions

View File

@@ -57,10 +57,7 @@ class SoftTopkStrategy(WeightStrategyBase):
final_stock_weight[stock_id] -= sw
if self.buy_method == "first_fill":
for stock_id in buy_signal_stocks:
add_weight = min(
max(1 / self.topk - final_stock_weight.get(stock_id, 0), 0.0),
sold_stock_weight,
)
add_weight = min(max(1 / self.topk - final_stock_weight.get(stock_id, 0), 0.0), sold_stock_weight,)
final_stock_weight[stock_id] = final_stock_weight.get(stock_id, 0.0) + add_weight
sold_stock_weight -= add_weight
elif self.buy_method == "average_fill":

View File

@@ -102,14 +102,10 @@ class OrderGenWInteract(OrderGenerator):
# strategy 1 : generate amount_position by weight_position
# Use API in Exchange()
target_amount_dict = trade_exchange.generate_amount_position_from_weight_position(
weight_position=target_weight_position,
cash=current_tradable_value,
trade_date=trade_date,
weight_position=target_weight_position, cash=current_tradable_value, trade_date=trade_date,
)
order_list = trade_exchange.generate_order_for_target_amount_position(
target_position=target_amount_dict,
current_position=current_amount_dict,
trade_date=trade_date,
target_position=target_amount_dict, current_position=current_amount_dict, trade_date=trade_date,
)
return order_list
@@ -164,8 +160,6 @@ class OrderGenWOInteract(OrderGenerator):
else:
continue
order_list = trade_exchange.generate_order_for_target_amount_position(
target_position=amount_dict,
current_position=current.get_stock_amount_dict(),
trade_date=trade_date,
target_position=amount_dict, current_position=current.get_stock_amount_dict(), trade_date=trade_date,
)
return order_list