Documentation ¶
Index ¶
- Variables
- type Engine
- func (e *Engine) GetTargetStake(now time.Time) *num.Uint
- func (e *Engine) RecordTotalStake(ts uint64, now time.Time) error
- func (e *Engine) UpdateParameters(parameters types.TargetStakeParameters)
- func (e *Engine) UpdateScalingFactor(sFactor num.Decimal) error
- func (e *Engine) UpdateTimeWindow(tWindow time.Duration)
- type SnapshotEngine
- func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *SnapshotEngine) GetTargetStake(now time.Time) *num.Uint
- func (e *SnapshotEngine) Keys() []string
- func (e *SnapshotEngine) LoadState(_ context.Context, payload *types.Payload) ([]types.StateProvider, error)
- func (e *SnapshotEngine) Namespace() types.SnapshotNamespace
- func (e *SnapshotEngine) RecordTotalStake(oi uint64, now time.Time) error
- func (e *SnapshotEngine) StopSnapshots()
- func (e *SnapshotEngine) Stopped() bool
- func (e *SnapshotEngine) UpdateParameters(parameters types.TargetStakeParameters)
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 ¶
GetTargetStake returns target stake based current time.
func (*Engine) RecordTotalStake ¶
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 ¶
UpdateScalingFactor updates the scaling factor used in target stake calculation if it's non-negative and returns an error otherwise.
func (*Engine) UpdateTimeWindow ¶
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)
Click to show internal directories.
Click to hide internal directories.