calculated

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x any) (decimal.Decimal, error)

Abs returns the absolute value of x

func Add

func Add(x, y any) (decimal.Decimal, error)

Add returns the sum of x and y

func Avg

func Avg(x ...any) (decimal.Decimal, error)

Avg returns the average of x elements

func Ceil

func Ceil(x any) (decimal.Decimal, error)

Ceil returns the ceiling of x

func Div

func Div(x, y any) (decimal.Decimal, error)

Div returns the quotient of x and y

func Equal

func Equal(x, y any) (bool, error)

Equal returns true if x and y are equal

func Floor

func Floor(x any) (decimal.Decimal, error)

Floor returns the floor of x

func GreaterThan

func GreaterThan(x, y any) (bool, error)

GreaterThan returns true if x is greater than y

func GreaterThanOrEqual

func GreaterThanOrEqual(x, y any) (bool, error)

GreaterThanOrEqual returns true if x is greater than or equal to y

func IsNegative

func IsNegative(x any) (bool, error)

IsNegative returns true if x is negative

func IsPositive

func IsPositive(x any) (bool, error)

IsPositive returns true if x is positive

func IsZero

func IsZero(x any) (bool, error)

IsZero returns true if x is zero

func LessThan

func LessThan(x, y any) (bool, error)

LessThan returns true if x is less than y

func LessThanOrEqual

func LessThanOrEqual(x, y any) (bool, error)

LessThanOrEqual returns true if x is less than or equal to y

func Ln

func Ln(x any) (decimal.Decimal, error)

Ln returns the natural logarithm of x.

func Log

func Log(x, y any) (decimal.Decimal, error)

Log returns the logarithms of y with base x. This is equivalent to log_x(y).

We use this formula:

             ln(y)
log_x(y)  =  ----
             ln(x)

func Max

func Max(x ...any) (decimal.Decimal, error)

Max returns the maximum of x elements

func Min

func Min(x ...any) (decimal.Decimal, error)

Min returns the minimum of x elements

func Mul

func Mul(x, y any) (decimal.Decimal, error)

Mul returns the product of x and y

func NewEnv

func NewEnv(observationTimestampNanoseconds uint64) environment

NewEnv returns a new environment with the default functions

func ParseDuration

func ParseDuration(x string) (time.Duration, error)

ParseDuration parses a duration string into a time.ParseDuration

func Pow

func Pow(x, y any) (decimal.Decimal, error)

Pow returns x, raised to the power of y

func ProcessCalculatedStreams

func ProcessCalculatedStreams(lggr logger.Logger, channelDefinitions llotypes.ChannelDefinitions, streamAggregates protocol.StreamAggregates, observationTimestampNanoseconds uint64, optsCache *protocol.OptsCache)

ProcessCalculatedStreams evaluates expressions for each channel of the EVMABIEncodeUnpackedExpr format, appending the calculated streams to their channel definitions and writing the evaluated values into streamAggregates. It is version-agnostic: both the v30 and v31 plugins call it with their own outcome/precursor fields.

func ProcessCalculatedStreamsDryRun

func ProcessCalculatedStreamsDryRun(expression string) error

ProcessCalculatedStreamsDryRun processes the calculated streams for the given expression against synthetic inputs and returns an error if it cannot be evaluated. Useful for validating expressions.

func Round

func Round(x any, precision int) (decimal.Decimal, error)

Round returns the rounded value of x to the given precision

func Sqrt

func Sqrt(x any) (decimal.Decimal, error)

Sqrt returns the square root of x. Returns error for negative values.

func Sub

func Sub(x, y any) (decimal.Decimal, error)

Sub returns the difference of x and y

func Truncate

func Truncate(x any, precision int) (decimal.Decimal, error)

Truncate truncates off digits from the number, without rounding.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL