Add get price data helper
This commit is contained in:
@@ -430,8 +430,14 @@ impl Strategy for DataApiProbeStrategy {
|
||||
.len();
|
||||
let suspended = bool_flags(ctx.is_suspended("000001.SZ", 3));
|
||||
let st_flags = bool_flags(ctx.is_st_stock("000001.SZ", 3));
|
||||
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();
|
||||
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={};range={trading_date_count};prev={prev_date};next={next_date};suspended={suspended};st={st_flags}",
|
||||
"daily={daily_close};previous={previous_close};tick={tick_last};previous_tick={previous_tick_last};current={current_close};instrument={instrument_name};all={};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}",
|
||||
ctx.all_instruments().len()
|
||||
));
|
||||
}
|
||||
@@ -1059,7 +1065,7 @@ fn strategy_context_exposes_rqalpha_style_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=1;range=3;prev=2025-01-03;next=2025-01-06;suspended=0,1,0;st=0,1,0"
|
||||
"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=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"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user