value

package
v0.0.0-...-6378e9d Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildProperties

type BuildProperties struct {
	Commit  string
	Version string
	Date    string
}

buildProperties stores information read from the linker flags associated with the binary created from this code. E.g.

   ```
   {
	      -ldflags -s -w
       -X main.version=100.0.0-SNAPSHOT-057f3fc
       -X main.commit=057f3fc6318d1824148bf91de5ef674fe8b9a504
       -X main.date=2024-01-29T19:14:07Z
       -X main.builtBy=goreleaser
   }
   ```

func (*BuildProperties) Initialize

func (buildProps *BuildProperties) Initialize()

type NumericValue

type NumericValue interface {
	Number() *bn.FloatNumber
}

NumericValue is a data point value which is a number.

The interface must be implemented by using non-pointer receivers.

type OrcfaxCollectorData

type OrcfaxCollectorData struct {
	Timestamp        string              `json:"timestamp"`
	Raw              []OrcfaxRaw         `json:"raw"`
	DataPoints       []string            `json:"data_points"`
	CalculatedValue  string              `json:"calculated_value"`
	Feed             string              `json:"feed"`
	Identity         identity.Identity   `json:"identity"`
	ContentSignature string              `json:"content_signature"`
	Errors           []map[string]string `json:"errors"`
}

OrcfaxCollectorData is the primary payload for an Orcfax message containing the "collected" and "normalized" data.

type OrcfaxMessage

type OrcfaxMessage struct {
	Message             OrcfaxCollectorData `json:"message"`
	NodeID              string              `json:"node_id"`
	ValidationTimestamp string              `json:"validation_timestamp"`
}

OrcfaxMessage wraps the Orcfax data structure.

type OrcfaxRaw

type OrcfaxRaw struct {
	Response         map[string]any `json:"response"`
	RequestURL       string         `json:"request_url"`
	RequestTimestamp string         `json:"request_timestamp"`
	Collector        string         `json:"collector"`
	Error            string         `json:"error"`
}

OrcfaxRaw provides a means of storing raw request/response data from price-pair sources.

type Pair

type Pair struct {
	Base  string
	Quote string
}

Pair represents an asset pair.

func PairFromString

func PairFromString(s string) (p Pair, err error)

PairFromString returns a new Pair for given string. The string must be formatted as "BASE/QUOTE".

func (Pair) Empty

func (p Pair) Empty() bool

Empty returns true if the pair is empty. Pair is considered empty if either base or quote is empty.

func (Pair) Equal

func (p Pair) Equal(c Pair) bool

Equal returns true if the pair is equal to the given pair.

func (Pair) Invert

func (p Pair) Invert() Pair

Invert returns an inverted pair. For example, if the pair is "BTC/USD", then the inverted pair is "USD/BTC".

func (Pair) MarshalText

func (p Pair) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler interface.

func (Pair) String

func (p Pair) String() string

String returns a string representation of the pair.

func (*Pair) UnmarshalText

func (p *Pair) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler interface.

type StaticValue

type StaticValue struct {
	Value *bn.DecFloatPointNumber
}

StaticValue is a numeric value obtained from a static origin.

func (StaticValue) MarshalJSON

func (s StaticValue) MarshalJSON() ([]byte, error)

func (StaticValue) Number

func (s StaticValue) Number() *bn.FloatNumber

Number implements the NumericValue interface.

func (StaticValue) Print

func (s StaticValue) Print() string

Print implements the Value interface.

func (*StaticValue) UnmarshalJSON

func (s *StaticValue) UnmarshalJSON(bytes []byte) error

type Tick

type Tick struct {
	// Pair is an asset pair for which this price is calculated.
	Pair Pair

	// Price is a price for the given asset pair.
	// Depending on the provider implementation, this price can be
	// a last trade price, an average of bid and ask prices, etc.
	//
	// Price is always non-nil if there is no error.
	Price *bn.DecFloatPointNumber

	// Volume24h is a 24h volume for the given asset pair presented in the
	// base currency.
	//
	// May be nil if the provider does not provide volume.
	Volume24h *bn.DecFloatPointNumber
}

Tick contains a price, volume and other information for a given asset pair at a given time.

Before using this data, you should check if it is valid by calling Tick.Validate() method.

func NewTick

func NewTick(pair Pair, price, volume any) Tick

func (Tick) MarshalJSON

func (t Tick) MarshalJSON() ([]byte, error)

func (Tick) Number

func (t Tick) Number() *bn.FloatNumber

Number implements the NumericValue interface.

func (Tick) Print

func (t Tick) Print() string

Print implements the Value interface.

func (*Tick) UnmarshalJSON

func (t *Tick) UnmarshalJSON(data []byte) error

func (Tick) Validate

func (t Tick) Validate() error

Validate returns an error if the tick is invalid.

type ValidatableValue

type ValidatableValue interface {
	Validate() error
}

ValidatableValue is a data point value which can be validated.

The interface must be implemented by using non-pointer receivers.

type Value

type Value interface {
	// Print returns a human-readable representation of the value.
	Print() string
}

Value is a data point value.

A value can be anything, e.g. a number, a string, a struct, etc.

The interface must be implemented by using non-pointer receivers.

Jump to

Keyboard shortcuts

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