supplied

package
v0.67.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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.

View Source
var (
	IncrementFactor = incrementInPct.Div(num.DecimalFromFloat(100)) // we calculate the probability of trading in increments of 0.001 from of the best bid/ask

)

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) CalculateLiquidityImpliedVolumes

func (e *Engine) CalculateLiquidityImpliedVolumes(
	liquidityObligation *num.Uint,
	orders []*types.Order,
	minLpPrice, maxLpPrice *num.Uint,
	buyShapes, sellShapes []*LiquidityOrder,
)

CalculateLiquidityImpliedVolumes updates the LiquidityImpliedSize fields in LiquidityOrderReference so that the liquidity commitment is met. Current market price, liquidity obligation, and orders must be specified. Note that due to integer order size the actual liquidity provided will be more than or equal to the commitment amount.

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) CalculateUnweightedBuySellLiquidityWithinLPRange added in v0.65.0

func (e *Engine) CalculateUnweightedBuySellLiquidityWithinLPRange(orders []*types.Order, minLpPrice, maxLpPrice *num.Uint) (*num.Uint, *num.Uint)

CalculateUnweightedBuySellLiquidityWithinLPRange returns the sum of price x remaining volume for each order within LP range.

func (*Engine) IsPoTInitialised

func (e *Engine) IsPoTInitialised() 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 risk.Model, monitor PriceMonitor)

type LiquidityOrder

type LiquidityOrder struct {
	OrderID string

	Price   *num.Uint
	Details *types.LiquidityOrder

	LiquidityImpliedVolume uint64
}

LiquidityOrder contains information required to compute volume required to fullfil liquidity obligation per set of liquidity provision orders for one side of the order book.

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