Documentation ¶
Index ¶
- Constants
- func ConfidenceInDifference(min, max float64) float64
- type Aggregator
- func (self *Aggregator) ManualValue(oracleName string, reqID int64, ts time.Time) (float64, bool, error)
- func (self *Aggregator) MeanAt(symbol string, at time.Time) (float64, float64, error)
- func (self *Aggregator) MedianAt(symbol string, at time.Time) (float64, float64, error)
- func (self *Aggregator) MedianAtEOD(symbol string, at time.Time) (float64, float64, error)
- func (self *Aggregator) TimeWeightedAvg(symbol string, start time.Time, lookBack time.Duration) (float64, float64, error)
- func (self *Aggregator) VolumWeightedAvg(symbol string, start time.Time, end time.Time, aggrWindow time.Duration) (float64, float64, error)
- type Config
- type IAggregator
Constants ¶
const ComponentName = "aggregator"
Variables ¶
This section is empty.
Functions ¶
func ConfidenceInDifference ¶
ConfidenceInDifference calculates the percentage difference between the max and min and subtract this from 100%. Example: min 1, max 2 Difference is 1 which is 100% so the final confidence is 100-100 equals 0%.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
func New ¶
func New( ctx context.Context, logger log.Logger, cfg Config, tsDB storage.SampleAndChunkQueryable, ) (*Aggregator, error)
func (*Aggregator) ManualValue ¶
func (*Aggregator) MedianAtEOD ¶
func (*Aggregator) TimeWeightedAvg ¶
func (self *Aggregator) TimeWeightedAvg( symbol string, start time.Time, lookBack time.Duration, ) (float64, float64, error)
TimeWeightedAvg returns price and confidence level for a given symbol. Confidence is calculated based on maximum possible samples over the actual samples for a given period. avg(maxPossibleSamplesCount/actualSamplesCount) For example with 1h look back and source interval of 60sec maxPossibleSamplesCount = 36 with actualSamplesCount = 18 this is 50% confidence. The same calculation is done for all source and the final value is the average of all.
Example for 1h. maxDataPointCount is calculated by deviding the seconds in 1h by how often the tracker queries the APIs. avg(count_over_time(trackerIndex_value{symbol="AMPL_USD"}[1h]) / (3.6e+12/trackerIndex_interval)).
func (*Aggregator) VolumWeightedAvg ¶
func (self *Aggregator) VolumWeightedAvg( symbol string, start time.Time, end time.Time, aggrWindow time.Duration, ) (float64, float64, error)
VolumWeightedAvg returns price and confidence level for a given symbol. Confidence is calculated based on maximum possible samples over the actual samples for a given period. avg(maxPossibleSamplesCount/actualSamplesCount) For example with 1h look back and source interval of 60sec maxPossibleSamplesCount = 36 with actualSamplesCount = 18 this is 50% confidence. The same calculation is done for all source and the final value is the average of all. maxDataPointCount is calculated by deviding the seconds in 1h by how often the tracker queries the APIs.
Example for 1h. avg(count_over_time(trackerIndex_value{symbol="AMPL_USD"}[1h]) / (3.6e+12/30s)).
vals are calculated using the official VWAP formula from https://tradingtuitions.com/vwap-trading-strategy-excel-sheet/