Documentation ¶
Index ¶
- Variables
- type Engine
- func (e *Engine) CalculateLiquidityImpliedVolumes(liquidityObligation *num.Uint, orders []*types.Order, ...)
- func (e *Engine) CalculateLiquidityScore(orders []*types.Order, bestBid, bestAsk num.Decimal, ...) num.Decimal
- func (e *Engine) CalculateUnweightedBuySellLiquidityWithinLPRange(orders []*types.Order, minLpPrice, maxLpPrice *num.Uint) (*num.Uint, *num.Uint)
- func (e *Engine) IsPoTInitialised() bool
- func (e *Engine) OnMinProbabilityOfTradingLPOrdersUpdate(v num.Decimal)
- func (e *Engine) OnProbabilityOfTradingTauScalingUpdate(v num.Decimal)
- func (e *Engine) Payload() *snapshotpb.Payload
- func (e *Engine) Reload(ls *snapshotpb.LiquiditySupplied) error
- func (e *Engine) SetGetStaticPricesFunc(f func() (num.Decimal, num.Decimal, error))
- func (e *Engine) UpdateMarketConfig(riskModel risk.Model, monitor PriceMonitor)
- type LiquidityOrder
- type PriceMonitor
- type RiskModel
- type StateVarEngine
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
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 (*Engine) OnMinProbabilityOfTradingLPOrdersUpdate ¶
func (*Engine) OnProbabilityOfTradingTauScalingUpdate ¶
func (*Engine) Payload ¶
func (e *Engine) Payload() *snapshotpb.Payload
func (*Engine) Reload ¶
func (e *Engine) Reload(ls *snapshotpb.LiquiditySupplied) error
func (*Engine) SetGetStaticPricesFunc ¶
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.