Format related strategy and test files
This commit is contained in:
@@ -252,10 +252,12 @@ fn engine_settles_delisted_position_before_missing_market_snapshot_breaks_run()
|
||||
.any(|fill| fill.reason.contains("delisted_cash_settlement")
|
||||
&& fill.symbol == "000001.SZ")
|
||||
);
|
||||
assert!(result
|
||||
.holdings_summary
|
||||
.iter()
|
||||
.all(|holding| holding.symbol != "000001.SZ"));
|
||||
assert!(
|
||||
result
|
||||
.holdings_summary
|
||||
.iter()
|
||||
.all(|holding| holding.symbol != "000001.SZ")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -477,9 +479,11 @@ fn engine_applies_successor_conversion_before_delisted_cash_settlement() {
|
||||
);
|
||||
|
||||
let result = engine.run().expect("backtest succeeds");
|
||||
assert!(result.equity_curve.iter().any(|point| point
|
||||
.notes
|
||||
.contains("successor_conversion 000001.SZ->000002.SZ")));
|
||||
assert!(result.equity_curve.iter().any(|point| {
|
||||
point
|
||||
.notes
|
||||
.contains("successor_conversion 000001.SZ->000002.SZ")
|
||||
}));
|
||||
assert!(result.fills.iter().all(
|
||||
|fill| !fill.reason.contains("delisted_cash_settlement") || fill.symbol != "000001.SZ"
|
||||
));
|
||||
@@ -489,12 +493,16 @@ fn engine_applies_successor_conversion_before_delisted_cash_settlement() {
|
||||
.find(|holding| holding.symbol == "000002.SZ")
|
||||
.expect("successor holding exists");
|
||||
assert_eq!(successor_holding.quantity, 500);
|
||||
assert!(result
|
||||
.holdings_summary
|
||||
.iter()
|
||||
.all(|holding| holding.symbol != "000001.SZ"));
|
||||
assert!(result.account_events.iter().any(|event| event
|
||||
.note
|
||||
.contains("successor_conversion 000001.SZ->000002.SZ")
|
||||
&& event.note.contains("cash=1000.00")));
|
||||
assert!(
|
||||
result
|
||||
.holdings_summary
|
||||
.iter()
|
||||
.all(|holding| holding.symbol != "000001.SZ")
|
||||
);
|
||||
assert!(result.account_events.iter().any(|event| {
|
||||
event
|
||||
.note
|
||||
.contains("successor_conversion 000001.SZ->000002.SZ")
|
||||
&& event.note.contains("cash=1000.00")
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ impl Strategy for HookProbeStrategy {
|
||||
"hook-probe"
|
||||
}
|
||||
|
||||
fn before_trading(&mut self, ctx: &StrategyContext<'_>) -> Result<(), fidc_core::BacktestError> {
|
||||
fn before_trading(
|
||||
&mut self,
|
||||
ctx: &StrategyContext<'_>,
|
||||
) -> Result<(), fidc_core::BacktestError> {
|
||||
self.log
|
||||
.borrow_mut()
|
||||
.push(format!("before:{}", ctx.execution_date));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn open_auction(
|
||||
&mut self,
|
||||
ctx: &StrategyContext<'_>,
|
||||
) -> Result<(), fidc_core::BacktestError> {
|
||||
fn open_auction(&mut self, ctx: &StrategyContext<'_>) -> Result<(), fidc_core::BacktestError> {
|
||||
self.log
|
||||
.borrow_mut()
|
||||
.push(format!("auction:{}", ctx.execution_date));
|
||||
|
||||
Reference in New Issue
Block a user