Add get price data helper
This commit is contained in:
@@ -7,7 +7,7 @@ use std::sync::OnceLock;
|
||||
use chrono::{Datelike, Duration, NaiveDate, NaiveDateTime, NaiveTime};
|
||||
|
||||
use crate::cost::ChinaAShareCostModel;
|
||||
use crate::data::{DailyMarketSnapshot, DataSet, IntradayExecutionQuote, PriceField};
|
||||
use crate::data::{DailyMarketSnapshot, DataSet, IntradayExecutionQuote, PriceBar, PriceField};
|
||||
use crate::engine::BacktestError;
|
||||
use crate::events::{OrderSide, ProcessEvent};
|
||||
use crate::instrument::Instrument;
|
||||
@@ -295,6 +295,16 @@ impl StrategyContext<'_> {
|
||||
.is_st_stock_flags(self.execution_date, symbol, count)
|
||||
}
|
||||
|
||||
pub fn get_price(
|
||||
&self,
|
||||
symbol: &str,
|
||||
start: NaiveDate,
|
||||
end: NaiveDate,
|
||||
frequency: &str,
|
||||
) -> Vec<PriceBar> {
|
||||
self.data.get_price(symbol, start, end, frequency)
|
||||
}
|
||||
|
||||
pub fn has_subscriptions(&self) -> bool {
|
||||
!self.subscriptions.is_empty()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user