Add tick best-price matching modes
This commit is contained in:
@@ -56,6 +56,9 @@ pub enum MatchingType {
|
||||
CurrentBarClose,
|
||||
NextBarOpen,
|
||||
NextTickLast,
|
||||
NextTickBestOwn,
|
||||
NextTickBestCounterparty,
|
||||
CounterpartyOffer,
|
||||
Vwap,
|
||||
}
|
||||
|
||||
@@ -271,9 +274,51 @@ where
|
||||
quote: &IntradayExecutionQuote,
|
||||
side: OrderSide,
|
||||
) -> Option<f64> {
|
||||
let raw_price = match side {
|
||||
OrderSide::Buy => quote.buy_price(),
|
||||
OrderSide::Sell => quote.sell_price(),
|
||||
let raw_price = match self.matching_type {
|
||||
MatchingType::NextTickBestOwn => match side {
|
||||
OrderSide::Buy => {
|
||||
if quote.bid1.is_finite() && quote.bid1 > 0.0 {
|
||||
Some(quote.bid1)
|
||||
} else {
|
||||
quote
|
||||
.last_price
|
||||
.is_finite()
|
||||
.then_some(quote.last_price)
|
||||
.filter(|price| *price > 0.0)
|
||||
}
|
||||
}
|
||||
OrderSide::Sell => {
|
||||
if quote.ask1.is_finite() && quote.ask1 > 0.0 {
|
||||
Some(quote.ask1)
|
||||
} else {
|
||||
quote
|
||||
.last_price
|
||||
.is_finite()
|
||||
.then_some(quote.last_price)
|
||||
.filter(|price| *price > 0.0)
|
||||
}
|
||||
}
|
||||
},
|
||||
MatchingType::NextTickBestCounterparty | MatchingType::CounterpartyOffer => {
|
||||
match side {
|
||||
OrderSide::Buy => quote.buy_price(),
|
||||
OrderSide::Sell => quote.sell_price(),
|
||||
}
|
||||
}
|
||||
MatchingType::NextTickLast | MatchingType::Vwap => {
|
||||
if quote.last_price.is_finite() && quote.last_price > 0.0 {
|
||||
Some(quote.last_price)
|
||||
} else {
|
||||
match side {
|
||||
OrderSide::Buy => quote.buy_price(),
|
||||
OrderSide::Sell => quote.sell_price(),
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => match side {
|
||||
OrderSide::Buy => quote.buy_price(),
|
||||
OrderSide::Sell => quote.sell_price(),
|
||||
},
|
||||
}?;
|
||||
let execution_price = self.quote_execution_price(snapshot, side, raw_price);
|
||||
if execution_price.is_finite() && execution_price > 0.0 {
|
||||
|
||||
@@ -108,7 +108,7 @@ pub fn built_in_strategy_manual() -> StrategyAiManual {
|
||||
},
|
||||
ManualSection {
|
||||
title: "execution.matching_type / execution.slippage".to_string(),
|
||||
detail: "设置撮合模式和滑点。支持 execution.matching_type(\"next_tick_last\" | \"vwap\" | \"current_bar_close\" | \"next_bar_open\" | \"open_auction\")。其中 vwap 会在盘中执行价链路上聚合多笔成交为单条 VWAP 成交;open_auction 使用当日集合竞价开盘价 day_open 进行撮合,且不额外施加滑点,并按竞价成交量而不是盘口一档流动性限制成交;滑点支持 execution.slippage(\"none\") / execution.slippage(\"price_ratio\", 0.001) / execution.slippage(\"tick_size\", 1)。".to_string(),
|
||||
detail: "设置撮合模式和滑点。支持 execution.matching_type(\"next_tick_last\" | \"next_tick_best_own\" | \"next_tick_best_counterparty\" | \"counterparty_offer\" | \"vwap\" | \"current_bar_close\" | \"next_bar_open\" | \"open_auction\")。其中 next_tick_last 使用 tick 的 last_price;next_tick_best_own / next_tick_best_counterparty 会按 L1 买一卖一近似 rqalpha 的 tick 最优价语义,counterparty_offer 当前也按 L1 对手方报价近似实现;vwap 会在盘中执行价链路上聚合多笔成交为单条 VWAP 成交;open_auction 使用当日集合竞价开盘价 day_open 进行撮合,且不额外施加滑点,并按竞价成交量而不是盘口一档流动性限制成交;滑点支持 execution.slippage(\"none\") / execution.slippage(\"price_ratio\", 0.001) / execution.slippage(\"tick_size\", 1)。".to_string(),
|
||||
},
|
||||
ManualSection {
|
||||
title: "when / unless / else".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user