supplied

package
v0.78.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OffsetIncrement          = uint32(1000) // the increment of offsets in the offset slice - 1/PriceIncrementFactor as integer
	OffsetIncrementAsDecimal = num.DecimalFromInt64(int64(OffsetIncrement))
	OffsetOneDecimal         = OffsetIncrementAsDecimal.Mul(OffsetIncrementAsDecimal)             // an offset of 100%
	PriceIncrementFactor     = num.DecimalOne().Div(num.DecimalFromInt64(int64(OffsetIncrement))) // we calculate the probability of trading in increments of 0.001 from of the best bid/ask

)
View Source
var (
	ErrNoValidOrders = errors.New("no valid orders to cover the liquidity obligation with")
)

ErrNoValidOrders informs that there weren't any valid orders to cover the liquidity obligation with. This could happen when for a given side (buy or sell) limit orders don't supply enough liquidity and there aren't any valid pegged orders (all the prives are invalid) to cover it with.

Functions

This section is empty.

Types

type Engine

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

Engine provides functionality related to supplied liquidity.

func NewEngine

func NewEngine(riskModel RiskModel, priceMonitor PriceMonitor, asset, marketID string, stateVarEngine StateVarEngine, log *logging.Logger, positionFactor num.Decimal) *Engine

NewEngine returns a reference to a new supplied liquidity calculation engine.

func (*Engine) CalculateLiquidityScore added in v0.65.0

func (e *Engine) CalculateLiquidityScore(
	orders []*types.Order,
	bestBid, bestAsk num.Decimal,
	minLpPrice, maxLpPrice *num.Uint,
) num.Decimal

CalculateLiquidityScore returns the current liquidity scores (volume-weighted probability of trading).

func (*Engine) IsProbabilityOfTradingInitialised added in v0.73.0

func (e *Engine) IsProbabilityOfTradingInitialised() bool

func (*Engine) OnMinProbabilityOfTradingLPOrdersUpdate

func (e *Engine) OnMinProbabilityOfTradingLPOrdersUpdate(v num.Decimal)

func (*Engine) OnProbabilityOfTradingTauScalingUpdate

func (e *Engine) OnProbabilityOfTradingTauScalingUpdate(v num.Decimal)

func (*Engine) Payload

func (e *Engine) Payload() *snapshotpb.Payload

func (*Engine) Reload

func (e *Engine) Reload(ls *snapshotpb.LiquiditySupplied) error

func (*Engine) SetGetStaticPricesFunc

func (e *Engine) SetGetStaticPricesFunc(f func() (num.Decimal, num.Decimal, error))

func (*Engine) UpdateMarketConfig

func (e *Engine) UpdateMarketConfig(riskModel RiskModel, monitor PriceMonitor)

type PriceMonitor

type PriceMonitor interface {
	GetValidPriceRange() (num.WrappedDecimal, num.WrappedDecimal)
}

PriceMonitor provides the range of valid prices, that is prices that wouldn't trade the current trading mode

type RiskModel

type RiskModel interface {
	ProbabilityOfTrading(currentPrice, orderPrice, minPrice, maxPrice num.Decimal, yearFraction num.Decimal, isBid, applyMinMax bool) num.Decimal
	GetProjectionHorizon() num.Decimal
}

RiskModel allows calculation of min/max price range and a probability of trading.

type StateVarEngine

type StateVarEngine interface {
	RegisterStateVariable(asset, market, name string, converter statevar.Converter, startCalculation func(string, statevar.FinaliseCalculation), trigger []statevar.EventType, result func(context.Context, statevar.StateVariableResult) error) error
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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