Documentation ¶
Index ¶
- func GetDefaultStrat() *types.LiquidationStrategy
- func GetLegacyStrat() *types.LiquidationStrategy
- type Book
- type Engine
- func (e *Engine) ClearDistressedParties(ctx context.Context, idgen IDGen, closed []events.Margin, mp, mmp *num.Uint) ([]events.MarketPosition, []string, []*types.Trade)
- func (e *Engine) GetNetworkPosition() events.MarketPosition
- func (e *Engine) GetNextCloseoutTS() int64
- func (e *Engine) GetState(key string) ([]byte, []types.StateProvider, error)
- func (e *Engine) Keys() []string
- func (e *Engine) LoadState(ctx context.Context, pl *types.Payload) ([]types.StateProvider, error)
- func (e *Engine) Namespace() types.SnapshotNamespace
- func (e *Engine) OnTick(ctx context.Context, now time.Time, midPrice *num.Uint) (*types.Order, error)
- func (e *Engine) StopSnapshots()
- func (e *Engine) Stopped() bool
- func (e *Engine) Update(cfg *types.LiquidationStrategy)
- func (e *Engine) UpdateMarkPrice(mp *num.Uint)
- func (e *Engine) UpdateNetworkPosition(trades []*types.Trade)
- type IDGen
- type Pos
- func (p *Pos) AverageEntryPrice() *num.Uint
- func (p *Pos) Buy() int64
- func (p *Pos) BuySumProduct() *num.Uint
- func (p *Pos) Party() string
- func (p *Pos) Price() *num.Uint
- func (p *Pos) Sell() int64
- func (p *Pos) SellSumProduct() *num.Uint
- func (p *Pos) Size() int64
- func (p *Pos) VWBuy() *num.Uint
- func (p *Pos) VWSell() *num.Uint
- type Positions
- type PriceMonitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultStrat ¶
func GetDefaultStrat() *types.LiquidationStrategy
GetDefaultStrat is exporeted, expected to be used to update existing proposals on protocol upgrade once that's happened, this code can be removed.
func GetLegacyStrat ¶
func GetLegacyStrat() *types.LiquidationStrategy
GetLegacyStrat is exported, same as defaul. This can be used for protocol upgrade it most closely resebles the old behaviour (network attempts to close out fully, in one go) this can be removed once protocol upgrade has completed.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func New ¶
func New(log *logging.Logger, cfg *types.LiquidationStrategy, mktID string, broker common.Broker, book Book, as common.AuctionState, tSvc common.TimeService, pe Positions, pmon PriceMonitor) *Engine
func (*Engine) ClearDistressedParties ¶
func (e *Engine) ClearDistressedParties(ctx context.Context, idgen IDGen, closed []events.Margin, mp, mmp *num.Uint) ([]events.MarketPosition, []string, []*types.Trade)
ClearDistressedParties transfers the open positions to the network, returns the market position events and party ID's for the market to remove the parties from things like positions engine and collateral.
func (*Engine) GetNetworkPosition ¶
func (e *Engine) GetNetworkPosition() events.MarketPosition
func (*Engine) GetNextCloseoutTS ¶
func (*Engine) GetState ¶
GetState must be thread-safe as it may be called from multiple goroutines concurrently!
func (*Engine) Namespace ¶
func (e *Engine) Namespace() types.SnapshotNamespace
func (*Engine) StopSnapshots ¶
func (e *Engine) StopSnapshots()
func (*Engine) Update ¶
func (e *Engine) Update(cfg *types.LiquidationStrategy)
func (*Engine) UpdateMarkPrice ¶
func (*Engine) UpdateNetworkPosition ¶
type Pos ¶
type Pos struct {
// contains filtered or unexported fields
}
func (*Pos) AverageEntryPrice ¶
func (*Pos) BuySumProduct ¶
func (*Pos) SellSumProduct ¶
type PriceMonitor ¶ added in v0.74.7
type PriceMonitor interface {
GetValidPriceRange() (num.WrappedDecimal, num.WrappedDecimal)
}