Documentation ¶
Index ¶
- Variables
- type AuctionState
- type Engine
- func (e *Engine) Changed() bool
- func (e *Engine) CheckPrice(ctx context.Context, as AuctionState, trades []*types.Trade, persistent bool) bool
- func (e *Engine) GetCurrentBounds() []*types.PriceMonitoringBounds
- func (e *Engine) GetHorizonYearFractions() []num.Decimal
- func (e *Engine) GetState() *types.PriceMonitor
- func (e *Engine) GetValidPriceRange() (num.WrappedDecimal, num.WrappedDecimal)
- func (e *Engine) Initialised() bool
- func (e *Engine) IsBoundFactorsInitialised() bool
- func (e *Engine) OnTimeUpdate(now time.Time)
- func (e *Engine) SetMinDuration(d time.Duration)
- func (e *Engine) UpdateSettings(riskModel risk.Model, settings *types.PriceMonitoringSettings)
- type RangeProvider
- type StateVarEngine
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilRangeProvider signals that nil was supplied in place of RangeProvider. ErrNilRangeProvider = errors.New("nil RangeProvider") // 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") // ErrExpiresAtNotSet indicates price monitoring auction is endless somehow. ErrExpiresAtNotSet = errors.New("price monitoring auction with no end time") // ErrNilPriceMonitoringSettings signals that nil was supplied in place of PriceMonitoringSettings. ErrNilPriceMonitoringSettings = errors.New("nil PriceMonitoringSettings") )
Functions ¶
This section is empty.
Types ¶
type AuctionState ¶
type AuctionState interface { // What is the current trading mode of the market, is it in auction Mode() types.MarketTradingMode InAuction() bool // What type of auction are we dealing with IsOpeningAuction() bool IsLiquidityAuction() bool IsPriceAuction() bool IsPriceExtension() bool IsLiquidityExtension() bool IsFBA() bool // is it the start/end of the auction CanLeave() bool AuctionStart() bool // start a price-related auction, extend a current auction, or end it StartPriceAuction(t time.Time, d *types.AuctionDuration) ExtendAuctionPrice(delta types.AuctionDuration) SetReadyToLeave() // get parameters for current auction Start() time.Time Duration() types.AuctionDuration // currently not used - might be useful when extending an auction ExpiresAt() *time.Time }
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 NewMonitor ¶
func NewMonitor(asset, mktID string, riskModel RangeProvider, auctionState AuctionState, settings *types.PriceMonitoringSettings, stateVarEngine StateVarEngine, log *logging.Logger) (*Engine, error)
NewMonitor returns a new instance of PriceMonitoring.
func NewMonitorFromSnapshot ¶
func NewMonitorFromSnapshot( marketID string, asset string, pm *types.PriceMonitor, settings *types.PriceMonitoringSettings, riskModel RangeProvider, auctionState AuctionState, stateVarEngine StateVarEngine, log *logging.Logger, ) (*Engine, error)
func (*Engine) CheckPrice ¶
func (e *Engine) CheckPrice(ctx context.Context, as AuctionState, trades []*types.Trade, persistent bool) bool
CheckPrice checks how current price, volume and time should impact the auction state and modifies it accordingly: start auction, end auction, extend ongoing auction, "true" gets returned if non-persistent order should be rejected.
func (*Engine) GetCurrentBounds ¶
func (e *Engine) GetCurrentBounds() []*types.PriceMonitoringBounds
GetCurrentBounds returns a list of valid price ranges per price monitoring trigger. Note these are subject to change as the time progresses.
func (*Engine) GetHorizonYearFractions ¶
GetHorizonYearFractions returns horizons of all the triggers specified, expressed as year fraction, sorted in ascending order.
func (*Engine) GetState ¶
func (e *Engine) GetState() *types.PriceMonitor
func (*Engine) GetValidPriceRange ¶
func (e *Engine) GetValidPriceRange() (num.WrappedDecimal, num.WrappedDecimal)
GetValidPriceRange returns the range of prices that won't trigger the price monitoring auction.
func (*Engine) Initialised ¶
Initialised returns true if the engine already saw at least one price.
func (*Engine) IsBoundFactorsInitialised ¶
func (*Engine) OnTimeUpdate ¶
func (*Engine) SetMinDuration ¶
func (*Engine) UpdateSettings ¶
func (e *Engine) UpdateSettings(riskModel risk.Model, settings *types.PriceMonitoringSettings)
type RangeProvider ¶
type RangeProvider interface {
PriceRange(price, yearFraction, probability num.Decimal) (num.Decimal, num.Decimal)
}
RangeProvider provides the minimum and maximum future price corresponding to the current price level, horizon expressed as year fraction (e.g. 0.5 for 6 months) and probability level (e.g. 0.95 for 95%).
type StateVarEngine ¶
type StateVarEngine interface {
RegisterStateVariable(asset, market, name string, converter statevar.Converter, startCalculation func(string, statevar.FinaliseCalculation), trigger []statevar.StateVarEventType, result func(context.Context, statevar.StateVariableResult) error) error
}