Documentation ¶
Index ¶
- Variables
- type Broker
- type Config
- type Engine
- func (e *Engine) AmendLiquidityProvision(ctx context.Context, lpa *types.LiquidityProvisionAmendment, party string, ...) ([]*types.Order, error)
- func (e *Engine) CalculateSuppliedStake() *num.Uint
- func (e *Engine) CanAmend(lps *types.LiquidityProvisionAmendment, party string) error
- func (e *Engine) CancelLiquidityProvision(ctx context.Context, party string) error
- func (e *Engine) ClearLPOrders()
- func (e *Engine) CreateInitialOrders(ctx context.Context, minLpPrice, maxLpPrice *num.Uint, party string, ...) []*types.Order
- func (e *Engine) GetAverageLiquidityScores() map[string]num.Decimal
- func (e *Engine) GetCurrentLiquidityScores(bestBid, bestAsk num.Decimal, minLpPrice, maxLpPrice *num.Uint) (map[string]num.Decimal, num.Decimal)
- func (e *Engine) GetInactiveParties() map[string]struct{}
- func (e *Engine) GetLPShapeCount() uint64
- func (e *Engine) GetPending() []string
- func (e *Engine) GetPotentialShapeOrders(party string, minLpPrice, maxLpPrice *num.Uint, ...) ([]*types.Order, error)
- func (e *Engine) IsLiquidityProvider(party string) bool
- func (e *Engine) IsPending(party string) bool
- func (e *Engine) IsPoTInitialised() bool
- func (e *Engine) LiquidityProvisionByPartyID(partyID string) *types.LiquidityProvision
- func (e *Engine) OnMarketLiquidityProvisionShapesMaxSizeUpdate(v int64) error
- func (e *Engine) OnMaximumLiquidityFeeFactorLevelUpdate(f num.Decimal)
- func (e *Engine) OnMinProbabilityOfTradingLPOrdersUpdate(v num.Decimal)
- func (e *Engine) OnProbabilityOfTradingTauScalingUpdate(v num.Decimal)
- func (e *Engine) OnSuppliedStakeToObligationFactorUpdate(v num.Decimal)
- func (e *Engine) ProvisionsPerParty() ProvisionsPerParty
- func (e *Engine) RejectLiquidityProvision(ctx context.Context, party string) error
- func (e *Engine) RemovePending(party string)
- func (e *Engine) ResetAverageLiquidityScores()
- func (e *Engine) SaveLPOrders()
- func (e *Engine) SetGetStaticPricesFunc(f func() (num.Decimal, num.Decimal, error))
- func (e *Engine) SetShapesReferencesOnLiquidityProvision(ctx context.Context, lp *types.LiquidityProvision, ...) []events.Event
- func (e *Engine) StopLiquidityProvision(ctx context.Context, party string) error
- func (e *Engine) SubmitLiquidityProvision(ctx context.Context, lps *types.LiquidityProvisionSubmission, party string, ...) error
- func (e *Engine) UndeployLPs(ctx context.Context, orders []*types.Order) []*ToCancel
- func (e *Engine) Update(ctx context.Context, minLpPrice, maxLpPrice *num.Uint, repriceFn RepriceOrder) ([]*types.Order, []*ToCancel)
- func (e *Engine) UpdateAverageLiquidityScores(bestBid, bestAsk num.Decimal, minLpPrice, maxLpPrice *num.Uint)
- func (e *Engine) UpdateMarketConfig(model risk.Model, monitor PriceMonitor)
- func (e *Engine) ValidateLiquidityProvisionAmendment(lp *types.LiquidityProvisionAmendment) (err error)
- func (e *Engine) ValidateLiquidityProvisionSubmission(lp *types.LiquidityProvisionSubmission, zeroCommitmentIsValid bool) (err error)
- type IDGen
- type OrderBook
- type Orders
- type PartyOrders
- type PriceMonitor
- type Provisions
- type ProvisionsPerParty
- type RepriceOrder
- type RiskModel
- type SnapshotEngine
- func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *SnapshotEngine) Keys() []string
- func (e *SnapshotEngine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
- func (e *SnapshotEngine) Namespace() types.SnapshotNamespace
- func (e *SnapshotEngine) OnMarketLiquidityProvisionShapesMaxSizeUpdate(v int64) error
- func (e *SnapshotEngine) OnMaximumLiquidityFeeFactorLevelUpdate(f num.Decimal)
- func (e *SnapshotEngine) OnSuppliedStakeToObligationFactorUpdate(v num.Decimal)
- func (e *SnapshotEngine) StopSnapshots()
- func (e *SnapshotEngine) Stopped() bool
- func (e *SnapshotEngine) UpdateMarketConfig(model risk.Model, monitor PriceMonitor)
- type SnapshotablePendingProvisions
- type SnapshotableProvisionsPerParty
- type StateVarEngine
- type TimeService
- type ToCancel
Constants ¶
This section is empty.
Variables ¶
var ( ErrLiquidityProvisionDoesNotExist = errors.New("liquidity provision does not exist") ErrLiquidityProvisionAlreadyExists = errors.New("liquidity provision already exists") ErrCommitmentAmountIsZero = errors.New("commitment amount is zero") ErrEmptyShape = errors.New("liquidity provision contains an empty shape") )
var ErrPartyHaveNoLiquidityProvision = errors.New("party have no liquidity provision")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Level cfgencoding.LogLevel `long:"log-level"`
}
Config represents the configuration of the Liquidity service.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine handles Liquidity provision.
func NewEngine ¶
func NewEngine(config Config, log *logging.Logger, timeService TimeService, broker Broker, riskModel RiskModel, priceMonitor PriceMonitor, orderBook OrderBook, asset string, marketID string, stateVarEngine StateVarEngine, priceFactor *num.Uint, positionFactor num.Decimal, ) *Engine
NewEngine returns a new Liquidity Engine.
func (*Engine) AmendLiquidityProvision ¶
func (*Engine) CalculateSuppliedStake ¶
CalculateSuppliedStake returns the sum of commitment amounts from all the liquidity providers.
func (*Engine) CanAmend ¶
func (e *Engine) CanAmend( lps *types.LiquidityProvisionAmendment, party string, ) error
func (*Engine) CancelLiquidityProvision ¶
CancelLiquidityProvision removes a parties commitment of liquidity Returns the liquidityOrders if any.
func (*Engine) ClearLPOrders ¶ added in v0.62.0
func (e *Engine) ClearLPOrders()
func (*Engine) CreateInitialOrders ¶
func (e *Engine) CreateInitialOrders( ctx context.Context, minLpPrice, maxLpPrice *num.Uint, party string, repriceFn RepriceOrder, ) []*types.Order
CreateInitialOrders returns two slices of orders, one for orders to be created and the other for orders to be updated.
func (*Engine) GetAverageLiquidityScores ¶ added in v0.65.0
func (*Engine) GetCurrentLiquidityScores ¶ added in v0.65.0
func (e *Engine) GetCurrentLiquidityScores(bestBid, bestAsk num.Decimal, minLpPrice, maxLpPrice *num.Uint) (map[string]num.Decimal, num.Decimal)
GetCurrentLiquidityScores returns volume-weighted probability of trading per each LP's deployed orders.
func (*Engine) GetInactiveParties ¶
GetInactiveParties returns a set of all the parties with inactive commitment.
func (*Engine) GetLPShapeCount ¶ added in v0.63.0
GetLPShapeCount returns the total number of LP shapes.
func (*Engine) GetPending ¶
func (*Engine) GetPotentialShapeOrders ¶
func (e *Engine) GetPotentialShapeOrders( party string, minLpPrice, maxLpPrice *num.Uint, lps *types.LiquidityProvisionAmendment, repriceFn RepriceOrder, ) ([]*types.Order, error)
GetPotentialShapeOrders is used to create orders from shape when amending a liquidity provision this allows us to ensure enough funds can be taken from the margin account in orders to submit orders later on.
func (*Engine) IsLiquidityProvider ¶
IsLiquidityProvider returns true if the party hold any liquidity commitmement.
func (*Engine) IsPoTInitialised ¶
func (*Engine) LiquidityProvisionByPartyID ¶
func (e *Engine) LiquidityProvisionByPartyID(partyID string) *types.LiquidityProvision
LiquidityProvisionByPartyID returns the LP associated to a Party if any. If not, it returns nil.
func (*Engine) OnMarketLiquidityProvisionShapesMaxSizeUpdate ¶
func (*Engine) OnMaximumLiquidityFeeFactorLevelUpdate ¶
func (*Engine) OnMinProbabilityOfTradingLPOrdersUpdate ¶
func (*Engine) OnProbabilityOfTradingTauScalingUpdate ¶
func (*Engine) OnSuppliedStakeToObligationFactorUpdate ¶
OnSuppliedStakeToObligationFactorUpdate updates the stake factor.
func (*Engine) ProvisionsPerParty ¶
func (e *Engine) ProvisionsPerParty() ProvisionsPerParty
ProvisionsPerParty returns the registered a map of party-id -> LiquidityProvision.
func (*Engine) RejectLiquidityProvision ¶
RejectLiquidityProvision removes a parties commitment of liquidity.
func (*Engine) RemovePending ¶
func (*Engine) ResetAverageLiquidityScores ¶ added in v0.65.0
func (e *Engine) ResetAverageLiquidityScores()
func (*Engine) SaveLPOrders ¶ added in v0.62.0
func (e *Engine) SaveLPOrders()
SaveLPOrders sets LP orders that have been cancelled from the book but we need to know what they were to recalculate and redeploy.
func (*Engine) SetGetStaticPricesFunc ¶
func (*Engine) SetShapesReferencesOnLiquidityProvision ¶ added in v0.67.0
func (e *Engine) SetShapesReferencesOnLiquidityProvision( ctx context.Context, lp *types.LiquidityProvision, buys []*types.LiquidityOrder, sells []*types.LiquidityOrder, idGen IDGen, ) []events.Event
func (*Engine) StopLiquidityProvision ¶
StopLiquidityProvision removes a parties commitment of liquidity Returns the liquidityOrders if any.
func (*Engine) SubmitLiquidityProvision ¶
func (e *Engine) SubmitLiquidityProvision( ctx context.Context, lps *types.LiquidityProvisionSubmission, party string, idgen IDGen, ) error
SubmitLiquidityProvision handles a new liquidity provision submission. It's used to create, update or delete a LiquidityProvision. The LiquidityProvision is created if submitted for the first time, updated if a previous one was created for the same PartyId or deleted (if exists) when the CommitmentAmount is set to 0.
func (*Engine) UndeployLPs ¶ added in v0.55.0
UndeployLPs is called when a reference price is no longer available. LP orders should all be parked/set to pending and should be redeployed once possible. Pass in updated orders and update internal records first...
func (*Engine) Update ¶
func (e *Engine) Update( ctx context.Context, minLpPrice, maxLpPrice *num.Uint, repriceFn RepriceOrder, ) ([]*types.Order, []*ToCancel)
Update gets the order changes. It keeps track of all LP orders.
func (*Engine) UpdateAverageLiquidityScores ¶ added in v0.65.0
func (*Engine) UpdateMarketConfig ¶
func (e *Engine) UpdateMarketConfig(model risk.Model, monitor PriceMonitor)
func (*Engine) ValidateLiquidityProvisionAmendment ¶
func (e *Engine) ValidateLiquidityProvisionAmendment(lp *types.LiquidityProvisionAmendment) (err error)
func (*Engine) ValidateLiquidityProvisionSubmission ¶
func (e *Engine) ValidateLiquidityProvisionSubmission( lp *types.LiquidityProvisionSubmission, zeroCommitmentIsValid bool, ) (err error)
type Orders ¶
Orders provides convenience functions to a slice of *veaga/proto.Orders.
func (Orders) ByParty ¶
func (ords Orders) ByParty() []PartyOrders
ByParty returns the orders grouped by it's PartyID.
type PartyOrders ¶
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 Provisions ¶ added in v0.55.0
type Provisions []*types.LiquidityProvision
Provisions provides convenience functions to a slice of *vega/proto.LiquidityProvision.
type ProvisionsPerParty ¶
type ProvisionsPerParty map[string]*types.LiquidityProvision
Provisions is a map of parties to *types.LiquidityProvision.
func (ProvisionsPerParty) FeeForTarget ¶
func (l ProvisionsPerParty) FeeForTarget(v *num.Uint) num.Decimal
func (ProvisionsPerParty) Slice ¶
func (l ProvisionsPerParty) Slice() Provisions
Slice returns the parties as a slice.
func (ProvisionsPerParty) TotalStake ¶
func (l ProvisionsPerParty) TotalStake() *num.Uint
TotalStake returns the sum of all CommitmentAmount, which corresponds to the total stake of a market.
type RepriceOrder ¶ added in v0.65.0
type RepriceOrder func( side types.Side, reference types.PeggedReference, offset *num.Uint, ) (*num.Uint, error)
RepriceOrder reprices a pegged order. This function should be injected by the market.
type RiskModel ¶
type RiskModel interface { ProbabilityOfTrading(currentPrice, orderPrice num.Decimal, minPrice, maxPrice num.Decimal, yFrac num.Decimal, isBid, applyMinMax bool) num.Decimal GetProjectionHorizon() num.Decimal }
RiskModel allows calculation of min/max price range and a probability of trading.
type SnapshotEngine ¶
type SnapshotEngine struct { *Engine // contains filtered or unexported fields }
func NewSnapshotEngine ¶
func NewSnapshotEngine(config Config, log *logging.Logger, timeService TimeService, broker Broker, riskModel RiskModel, priceMonitor PriceMonitor, orderBook OrderBook, asset string, market string, stateVarEngine StateVarEngine, priceFactor *num.Uint, positionFactor num.Decimal, ) *SnapshotEngine
func (*SnapshotEngine) GetState ¶
func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)
func (*SnapshotEngine) Keys ¶
func (e *SnapshotEngine) Keys() []string
func (*SnapshotEngine) LoadState ¶
func (e *SnapshotEngine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
func (*SnapshotEngine) Namespace ¶
func (e *SnapshotEngine) Namespace() types.SnapshotNamespace
func (*SnapshotEngine) OnMarketLiquidityProvisionShapesMaxSizeUpdate ¶
func (e *SnapshotEngine) OnMarketLiquidityProvisionShapesMaxSizeUpdate(v int64) error
func (*SnapshotEngine) OnMaximumLiquidityFeeFactorLevelUpdate ¶
func (e *SnapshotEngine) OnMaximumLiquidityFeeFactorLevelUpdate(f num.Decimal)
func (*SnapshotEngine) OnSuppliedStakeToObligationFactorUpdate ¶
func (e *SnapshotEngine) OnSuppliedStakeToObligationFactorUpdate(v num.Decimal)
func (*SnapshotEngine) StopSnapshots ¶
func (e *SnapshotEngine) StopSnapshots()
func (*SnapshotEngine) Stopped ¶
func (e *SnapshotEngine) Stopped() bool
func (*SnapshotEngine) UpdateMarketConfig ¶
func (e *SnapshotEngine) UpdateMarketConfig(model risk.Model, monitor PriceMonitor)
type SnapshotablePendingProvisions ¶
type SnapshotablePendingProvisions struct {
// contains filtered or unexported fields
}
func (*SnapshotablePendingProvisions) Add ¶
func (s *SnapshotablePendingProvisions) Add(key string)
func (*SnapshotablePendingProvisions) Delete ¶
func (s *SnapshotablePendingProvisions) Delete(key string)
func (*SnapshotablePendingProvisions) Exists ¶
func (s *SnapshotablePendingProvisions) Exists(key string) bool
type SnapshotableProvisionsPerParty ¶
type SnapshotableProvisionsPerParty struct {
ProvisionsPerParty
}
func (*SnapshotableProvisionsPerParty) Delete ¶
func (s *SnapshotableProvisionsPerParty) Delete(key string)
func (*SnapshotableProvisionsPerParty) Get ¶
func (s *SnapshotableProvisionsPerParty) Get(key string) (*types.LiquidityProvision, bool)
func (*SnapshotableProvisionsPerParty) Set ¶
func (s *SnapshotableProvisionsPerParty) Set(key string, p *types.LiquidityProvision)
type StateVarEngine ¶
type TimeService ¶
TimeService provide the time of the vega node using the tm time.
Directories ¶
Path | Synopsis |
---|---|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |