spot

package
v0.75.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeSequence signals that time sequence is not in a non-decreasing order.
	ErrTimeSequence = errors.New("received a time that's before the last received time")
	// ErrNegativeScalingFactor indicates that a negative scaling factor was supplied to the engine.
	ErrNegativeScalingFactor = errors.New("scaling factor can't be negative")
)

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine allows tracking price changes and verifying them against the theoretical levels implied by the RangeProvider (risk model).

func NewEngine

func NewEngine(parameters types.TargetStakeParameters, marketID string, positionFactor num.Decimal) *Engine

NewEngine returns a new instance of target stake calculation Engine.

func (*Engine) GetTargetStake

func (e *Engine) GetTargetStake(now time.Time) *num.Uint

GetTargetStake returns target stake based current time.

func (*Engine) RecordTotalStake

func (e *Engine) RecordTotalStake(ts uint64, now time.Time) error

RecordTotalStake records open interest history so that target stake can be calculated.

func (*Engine) UpdateParameters

func (e *Engine) UpdateParameters(parameters types.TargetStakeParameters)

func (*Engine) UpdateScalingFactor

func (e *Engine) UpdateScalingFactor(sFactor num.Decimal) error

UpdateScalingFactor updates the scaling factor used in target stake calculation if it's non-negative and returns an error otherwise.

func (*Engine) UpdateTimeWindow

func (e *Engine) UpdateTimeWindow(tWindow time.Duration)

UpdateTimeWindow updates the time windows used in target stake calculation.

type SnapshotEngine

type SnapshotEngine struct {
	*Engine
	// contains filtered or unexported fields
}

func NewSnapshotEngine

func NewSnapshotEngine(
	parameters types.TargetStakeParameters,
	marketID string,
	positionFactor num.Decimal,
) *SnapshotEngine

func (*SnapshotEngine) GetState

func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)

func (*SnapshotEngine) GetTargetStake

func (e *SnapshotEngine) GetTargetStake(now time.Time) *num.Uint

func (*SnapshotEngine) Keys

func (e *SnapshotEngine) Keys() []string

func (*SnapshotEngine) LoadState

func (e *SnapshotEngine) LoadState(_ context.Context, payload *types.Payload) ([]types.StateProvider, error)

func (*SnapshotEngine) Namespace

func (e *SnapshotEngine) Namespace() types.SnapshotNamespace

func (*SnapshotEngine) RecordTotalStake

func (e *SnapshotEngine) RecordTotalStake(oi uint64, now time.Time) error

func (*SnapshotEngine) StopSnapshots

func (e *SnapshotEngine) StopSnapshots()

func (*SnapshotEngine) Stopped

func (e *SnapshotEngine) Stopped() bool

func (*SnapshotEngine) UpdateParameters

func (e *SnapshotEngine) UpdateParameters(parameters types.TargetStakeParameters)

Jump to

Keyboard shortcuts

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