mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-13 07:46:53 +08:00
Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy
This commit is contained in:
@@ -194,7 +194,6 @@ class TopkDropoutStrategy(ModelStrategy):
|
||||
start_time=trade_start_time,
|
||||
end_time=trade_end_time,
|
||||
direction=Order.SELL, # 0 for sell, 1 for buy
|
||||
factor=factor,
|
||||
)
|
||||
# is order executable
|
||||
if self.trade_exchange.check_order(sell_order):
|
||||
@@ -231,7 +230,6 @@ class TopkDropoutStrategy(ModelStrategy):
|
||||
start_time=trade_start_time,
|
||||
end_time=trade_end_time,
|
||||
direction=Order.BUY, # 1 for buy
|
||||
factor=factor,
|
||||
)
|
||||
buy_order_list.append(buy_order)
|
||||
return TradeDecisionWO(sell_order_list + buy_order_list, self)
|
||||
|
||||
@@ -63,7 +63,9 @@ class TWAPStrategy(BaseStrategy):
|
||||
stock_id=order.stock_id, start_time=trade_start_time, end_time=trade_end_time
|
||||
):
|
||||
continue
|
||||
_amount_trade_unit = self.trade_exchange.get_amount_of_trade_unit(order.factor)
|
||||
_amount_trade_unit = self.trade_exchange.get_amount_of_trade_unit(stock_id=order.stock_id,
|
||||
start_time=order.start_time,
|
||||
end_time=order.end_time)
|
||||
_order_amount = None
|
||||
# considering trade unit
|
||||
if _amount_trade_unit is None:
|
||||
@@ -99,7 +101,6 @@ class TWAPStrategy(BaseStrategy):
|
||||
start_time=trade_start_time,
|
||||
end_time=trade_end_time,
|
||||
direction=order.direction, # 1 for buy
|
||||
factor=order.factor,
|
||||
)
|
||||
order_list.append(_order)
|
||||
return TradeDecisionWO(order_list=order_list, strategy=self)
|
||||
@@ -168,7 +169,9 @@ class SBBStrategyBase(BaseStrategy):
|
||||
self.trade_trend[order.stock_id] = _pred_trend
|
||||
continue
|
||||
# get amount of one trade unit
|
||||
_amount_trade_unit = self.trade_exchange.get_amount_of_trade_unit(order.factor)
|
||||
_amount_trade_unit = self.trade_exchange.get_amount_of_trade_unit(stock_id=order.stock_id,
|
||||
start_time=order.start_time,
|
||||
end_time=order.end_time)
|
||||
if _pred_trend == self.TREND_MID:
|
||||
_order_amount = None
|
||||
# considering trade unit
|
||||
@@ -201,7 +204,6 @@ class SBBStrategyBase(BaseStrategy):
|
||||
start_time=trade_start_time,
|
||||
end_time=trade_end_time,
|
||||
direction=order.direction,
|
||||
factor=order.factor,
|
||||
)
|
||||
order_list.append(_order)
|
||||
|
||||
@@ -248,7 +250,6 @@ class SBBStrategyBase(BaseStrategy):
|
||||
start_time=trade_start_time,
|
||||
end_time=trade_end_time,
|
||||
direction=order.direction, # 1 for buy
|
||||
factor=order.factor,
|
||||
)
|
||||
order_list.append(_order)
|
||||
else:
|
||||
@@ -267,7 +268,6 @@ class SBBStrategyBase(BaseStrategy):
|
||||
start_time=trade_start_time,
|
||||
end_time=trade_end_time,
|
||||
direction=order.direction, # 1 for buy
|
||||
factor=order.factor,
|
||||
)
|
||||
order_list.append(_order)
|
||||
|
||||
@@ -471,7 +471,9 @@ class ACStrategy(BaseStrategy):
|
||||
|
||||
if sig_sam is None or np.isnan(sig_sam):
|
||||
# no signal, TWAP
|
||||
_amount_trade_unit = self.trade_exchange.get_amount_of_trade_unit(order.factor)
|
||||
_amount_trade_unit = self.trade_exchange.get_amount_of_trade_unit(stock_id=order.stock_id,
|
||||
start_time=order.start_time,
|
||||
end_time=order.end_time)
|
||||
if _amount_trade_unit is None:
|
||||
# divide the order into equal parts, and trade one part
|
||||
_order_amount = self.trade_amount[order.stock_id] / (trade_len - trade_step)
|
||||
@@ -492,7 +494,10 @@ class ACStrategy(BaseStrategy):
|
||||
np.sinh(kappa * (trade_len - trade_step)) - np.sinh(kappa * (trade_len - trade_step - 1))
|
||||
) / np.sinh(kappa * trade_len)
|
||||
_order_amount = order.amount * amount_ratio
|
||||
_order_amount = self.trade_exchange.round_amount_by_trade_unit(_order_amount, order.factor)
|
||||
_order_amount = self.trade_exchange.round_amount_by_trade_unit(_order_amount,
|
||||
stock_id=order.stock_id,
|
||||
start_time=order.start_time,
|
||||
end_time=order.end_time)
|
||||
|
||||
if order.direction == order.SELL:
|
||||
# sell all amount at last
|
||||
|
||||
Reference in New Issue
Block a user