补充next open开盘执行回归测试
This commit is contained in:
@@ -4211,6 +4211,34 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct AuctionBuyWhenDecisionDateStrategy {
|
||||||
|
decision_date: NaiveDate,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Strategy for AuctionBuyWhenDecisionDateStrategy {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"auction_buy_when_decision_date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn open_auction(
|
||||||
|
&mut self,
|
||||||
|
ctx: &StrategyContext<'_>,
|
||||||
|
) -> Result<StrategyDecision, super::BacktestError> {
|
||||||
|
if ctx.decision_date == self.decision_date && ctx.portfolio.position(SYMBOL).is_none() {
|
||||||
|
return Ok(StrategyDecision {
|
||||||
|
order_intents: vec![OrderIntent::Shares {
|
||||||
|
symbol: SYMBOL.to_string(),
|
||||||
|
quantity: 100,
|
||||||
|
reason: "auction_test_buy".to_string(),
|
||||||
|
}],
|
||||||
|
..StrategyDecision::default()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(StrategyDecision::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct ScheduledBuyStrategy {
|
struct ScheduledBuyStrategy {
|
||||||
rule: ScheduleRule,
|
rule: ScheduleRule,
|
||||||
@@ -4915,7 +4943,7 @@ mod tests {
|
|||||||
|
|
||||||
let result = BacktestEngine::new(
|
let result = BacktestEngine::new(
|
||||||
dataset,
|
dataset,
|
||||||
BuyWhenDecisionDateStrategy {
|
AuctionBuyWhenDecisionDateStrategy {
|
||||||
decision_date: second,
|
decision_date: second,
|
||||||
},
|
},
|
||||||
broker,
|
broker,
|
||||||
|
|||||||
Reference in New Issue
Block a user