Add string factor support
This commit is contained in:
@@ -8,8 +8,9 @@ use chrono::{Datelike, Duration, NaiveDate, NaiveDateTime, NaiveTime};
|
||||
|
||||
use crate::cost::ChinaAShareCostModel;
|
||||
use crate::data::{
|
||||
DailyMarketSnapshot, DataSet, DividendRecord, FactorValue, IntradayExecutionQuote, PriceBar,
|
||||
PriceField, SecuritiesMarginRecord, SplitRecord, YieldCurvePoint,
|
||||
DailyMarketSnapshot, DataSet, DividendRecord, FactorTextValue, FactorValue,
|
||||
IntradayExecutionQuote, PriceBar, PriceField, SecuritiesMarginRecord, SplitRecord,
|
||||
YieldCurvePoint,
|
||||
};
|
||||
use crate::engine::BacktestError;
|
||||
use crate::events::{FillEvent, OrderEvent, OrderSide, OrderStatus, ProcessEvent};
|
||||
@@ -630,6 +631,16 @@ impl StrategyContext<'_> {
|
||||
self.data.get_factor(symbol, start, end, field)
|
||||
}
|
||||
|
||||
pub fn get_factor_text(
|
||||
&self,
|
||||
symbol: &str,
|
||||
start: NaiveDate,
|
||||
end: NaiveDate,
|
||||
field: &str,
|
||||
) -> Vec<FactorTextValue> {
|
||||
self.data.get_factor_text(symbol, start, end, field)
|
||||
}
|
||||
|
||||
pub fn get_yield_curve(
|
||||
&self,
|
||||
start: NaiveDate,
|
||||
@@ -738,6 +749,16 @@ impl StrategyContext<'_> {
|
||||
.get_industry(symbol, self.execution_date, source, level)
|
||||
}
|
||||
|
||||
pub fn get_industry_name(
|
||||
&self,
|
||||
symbol: &str,
|
||||
source: &str,
|
||||
level: usize,
|
||||
) -> Option<FactorTextValue> {
|
||||
self.data
|
||||
.get_industry_name(symbol, self.execution_date, source, level)
|
||||
}
|
||||
|
||||
pub fn get_dominant_future(&self, underlying_symbol: &str) -> Option<String> {
|
||||
self.data
|
||||
.get_dominant_future(underlying_symbol, self.execution_date)
|
||||
|
||||
Reference in New Issue
Block a user