pub struct TwapTask {
pub aggregator_pubkey: Option<String>,
pub period: Option<i32>,
pub weight_by_propagation_time: Option<bool>,
pub min_samples: Option<u32>,
pub ending_unix_timestamp: Option<i32>,
pub ending_unix_timestamp_task: Option<CronParseTask>,
}
Expand description
Takes a twap over a set period for a certain aggregator. Aggregators have an optional history buffer account storing the last N accepted results. The TwapTask will iterate over an aggregators history buffer and calculate the time weighted average of the samples within a given time period.
Input: None
Returns: The time weighted average of an aggregator over a given time period.
Example: The 1hr Twap of the SOL/USD Aggregator, requiring at least 60 samples.
{ "twapTask": { "aggregatorPubkey": "GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR", "period": 3600, "minSamples": 60, "weightByPropagationTime": true } }
Fields§
§aggregator_pubkey: Option<String>
/ The target aggregator for the TWAP.
period: Option<i32>
/ Period, in seconds, the twap should account for
weight_by_propagation_time: Option<bool>
/ Weight samples by their propagation time
min_samples: Option<u32>
/ Minimum number of samples in the history to calculate a valid result
ending_unix_timestamp: Option<i32>
/ Ending unix timestamp to collect values up to
ending_unix_timestamp_task: Option<CronParseTask>
/ Execute the task to get the ending unix timestamp
Implementations§
Source§impl TwapTask
impl TwapTask
Sourcepub fn aggregator_pubkey(&self) -> &str
pub fn aggregator_pubkey(&self) -> &str
Returns the value of aggregator_pubkey
, or the default value if aggregator_pubkey
is unset.
Sourcepub fn period(&self) -> i32
pub fn period(&self) -> i32
Returns the value of period
, or the default value if period
is unset.
Sourcepub fn weight_by_propagation_time(&self) -> bool
pub fn weight_by_propagation_time(&self) -> bool
Returns the value of weight_by_propagation_time
, or the default value if weight_by_propagation_time
is unset.
Sourcepub fn min_samples(&self) -> u32
pub fn min_samples(&self) -> u32
Returns the value of min_samples
, or the default value if min_samples
is unset.
Sourcepub fn ending_unix_timestamp(&self) -> i32
pub fn ending_unix_timestamp(&self) -> i32
Returns the value of ending_unix_timestamp
, or the default value if ending_unix_timestamp
is unset.
Trait Implementations§
Source§impl Message for TwapTask
impl Message for TwapTask
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
.