Add open auction matching mode
This commit is contained in:
@@ -81,6 +81,7 @@ pub enum DataSetError {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PriceField {
|
||||
DayOpen,
|
||||
Open,
|
||||
Close,
|
||||
Last,
|
||||
@@ -115,6 +116,7 @@ pub struct DailyMarketSnapshot {
|
||||
impl DailyMarketSnapshot {
|
||||
pub fn price(&self, field: PriceField) -> f64 {
|
||||
match field {
|
||||
PriceField::DayOpen => self.day_open,
|
||||
PriceField::Open => self.open,
|
||||
PriceField::Close => self.close,
|
||||
PriceField::Last => self.last_price,
|
||||
@@ -488,6 +490,7 @@ impl SymbolPriceSeries {
|
||||
|
||||
fn values_for(&self, field: PriceField) -> &[f64] {
|
||||
match field {
|
||||
PriceField::DayOpen => &self.opens,
|
||||
PriceField::Open => &self.opens,
|
||||
PriceField::Close => &self.closes,
|
||||
PriceField::Last => &self.last_prices,
|
||||
@@ -504,6 +507,7 @@ impl SymbolPriceSeries {
|
||||
|
||||
fn prefix_for(&self, field: PriceField) -> &[f64] {
|
||||
match field {
|
||||
PriceField::DayOpen => &self.open_prefix,
|
||||
PriceField::Open => &self.open_prefix,
|
||||
PriceField::Close => &self.close_prefix,
|
||||
PriceField::Last => &self.last_prefix,
|
||||
@@ -561,7 +565,7 @@ impl BenchmarkPriceSeries {
|
||||
}
|
||||
let start = end - lookback;
|
||||
let prefix = match field {
|
||||
PriceField::Open => &self.open_prefix,
|
||||
PriceField::DayOpen | PriceField::Open => &self.open_prefix,
|
||||
PriceField::Close | PriceField::Last => &self.close_prefix,
|
||||
};
|
||||
let sum = prefix[end] - prefix[start];
|
||||
@@ -959,6 +963,9 @@ impl DataSet {
|
||||
.market_series_by_symbol
|
||||
.get(symbol)
|
||||
.and_then(|series| series.decision_volume_rolling_average(date, lookback)),
|
||||
"day_open" | "dayopen" => {
|
||||
self.market_moving_average(date, symbol, lookback, PriceField::DayOpen)
|
||||
}
|
||||
"open" => self.market_moving_average(date, symbol, lookback, PriceField::Open),
|
||||
"last" | "last_price" => {
|
||||
self.market_moving_average(date, symbol, lookback, PriceField::Last)
|
||||
|
||||
Reference in New Issue
Block a user