mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-14 00:06:58 +08:00
Format code with the latest version of black.
This commit is contained in:
@@ -57,7 +57,10 @@ 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":
|
||||
|
||||
@@ -102,10 +102,14 @@ 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
|
||||
|
||||
@@ -160,6 +164,8 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user