切换分钟执行价语义

This commit is contained in:
boris
2026-06-26 09:27:21 +08:00
parent 02e2a20aff
commit 6db480b91d
7 changed files with 48 additions and 33 deletions
+9 -5
View File
@@ -919,14 +919,18 @@ impl Strategy for DataApiProbeStrategy {
let daily_price_count = ctx
.get_price("000001.SZ", d(2025, 1, 3), ctx.execution_date, "1d")
.len();
let tick_price_count = ctx
.get_price("000001.SZ", d(2025, 1, 3), ctx.execution_date, "tick")
.len();
let tick_alias_price_bars =
ctx.get_price("000001.SZ", d(2025, 1, 3), ctx.execution_date, "tick");
let tick_price_count = tick_alias_price_bars.len();
let tick_alias_frequency = tick_alias_price_bars
.first()
.map(|bar| bar.frequency.clone())
.unwrap_or_default();
let instrument_history_count =
ctx.instruments_history(&["000001.SZ", "000002.SZ"]).len();
let active_instrument_count = ctx.active_instruments(&["000001.SZ", "000002.SZ"]).len();
self.snapshots.borrow_mut().push(format!(
"daily={daily_close};previous={previous_close};tick={tick_last};previous_tick={previous_tick_last};current={current_close};instrument={instrument_name};all={};history={instrument_history_count};active={active_instrument_count};range={trading_date_count};prev={prev_date};next={next_date};suspended={suspended};st={st_flags};price_daily={daily_price_count};price_tick={tick_price_count}",
"daily={daily_close};previous={previous_close};minute={tick_last};previous_minute={previous_tick_last};current={current_close};instrument={instrument_name};all={};history={instrument_history_count};active={active_instrument_count};range={trading_date_count};prev={prev_date};next={next_date};suspended={suspended};st={st_flags};price_daily={daily_price_count};price_tick={tick_price_count};tick_alias_frequency={tick_alias_frequency}",
ctx.all_instruments().len()
));
}
@@ -2249,7 +2253,7 @@ fn strategy_context_exposes_engine_native_data_helpers() {
assert_eq!(
snapshots.borrow().as_slice(),
[
"daily=10.10,10.20;previous=10.00,10.10;tick=10.15,10.25;previous_tick=10.15;current=10.20;instrument=Anchor;all=2;history=2;active=1;range=3;prev=2025-01-03;next=2025-01-06;suspended=0,1,0;st=0,1,0;price_daily=2;price_tick=3"
"daily=10.10,10.20;previous=10.00,10.10;minute=10.15,10.25;previous_minute=10.15;current=10.20;instrument=Anchor;all=2;history=2;active=1;range=3;prev=2025-01-03;next=2025-01-06;suspended=0,1,0;st=0,1,0;price_daily=2;price_tick=3;tick_alias_frequency=1m"
]
);
}