Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct { // Meta contains metadata for the model. It should contain information // about the model and its parameters. // // Following keys are reserved: // - models: a list of sub models Meta map[string]any // Models is a list of sub models used to calculate price. Models []Model }
Model is a simplified representation of a model which is used to calculate asset pair prices. The main purpose of this structure is to help the end user to understand how prices are derived and calculated.
This structure is purely informational. The way it is used depends on a specific implementation.
func (Model) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Model) MarshalTrace ¶
MarshalTrace returns a human-readable representation of the model.
type NumericValue ¶
type NumericValue interface {
Number() *bn.FloatNumber
}
NumericValue is a data point value which is a number.
type Point ¶
type Point struct { // Value is the value of the data point. Value Value // Time is the time when the data point was obtained. Time time.Time // SubPoints is a list of sub data points that are used to obtain this // data point. SubPoints []Point // Meta contains metadata for the data point. It may contain additional // information about the data point, such as the origin it was obtained // from, etc. // // Following keys are reserved: // - value: the value of the data point // - time: the time when the data point was obtained // - ticks: a list of sub data points // - error: an error which occurred during obtaining the data point Meta map[string]any // Error is an optional error which occurred during obtaining the price. // If error is not nil, then the price is invalid and should not be used. // // Point may be invalid for other reasons, hence you should always check // the data point for validity by calling Point.Validate() method. Error error }
Point represents a data point. It can represent any value obtained from an origin. It can be a price, a volume, a market cap, etc.
Before using this data, you should check if it is valid by calling Point.Validate() method.
func (Point) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Point) MarshalTrace ¶
MarshalTrace returns a human-readable representation of the tick.
type Provider ¶
type Provider interface { // ModelNames returns a list of supported price models. ModelNames(ctx context.Context) []string // DataPoint returns a data point for the given model. DataPoint(ctx context.Context, model string) (Point, error) // DataPoints returns a map of data points for the given models. DataPoints(ctx context.Context, models ...string) (map[string]Point, error) // Model returns a price model for the given asset pair. Model(ctx context.Context, model string) (Model, error) // Models describes price models which are used to calculate prices. // If no pairs are specified, models for all pairs are returned. Models(ctx context.Context, models ...string) (map[string]Model, error) }
Provider provides prices for asset pairs.
type ValidatableValue ¶
type ValidatableValue interface {
Validate() error
}
ValidatableValue is a data point value which can be validated.