Documentation ¶
Index ¶
- Variables
- type Broker
- type Config
- type Engine
- func (e *Engine) AddTrade(trade *types.Trade)
- func (e *Engine) HasPosition(party string) bool
- func (e *Engine) HasTraded() bool
- func (e *Engine) ReloadConf(cfg Config)
- func (e *Engine) RemoveDistressed(ctx context.Context, evts []events.Margin)
- func (e *Engine) Settle(t time.Time, assetDecimals uint32) ([]*types.Transfer, error)
- func (e *Engine) SettleMTM(ctx context.Context, markPrice *num.Uint, positions []events.MarketPosition) []events.Transfer
- func (e *Engine) Update(positions []events.MarketPosition)
- func (e *Engine) UpdateProduct(product products.Product)
- type MarketPosition
- type Product
- type SnapshotEngine
- func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *SnapshotEngine) Keys() []string
- func (e *SnapshotEngine) LoadState(_ context.Context, payload *types.Payload) ([]types.StateProvider, error)
- func (e *SnapshotEngine) Namespace() types.SnapshotNamespace
- func (e *SnapshotEngine) StopSnapshots()
- func (e *SnapshotEngine) Stopped() bool
- type TimeService
Constants ¶
This section is empty.
Variables ¶
var ErrPartyDoesNotMatch = errors.New("event party and position party do not match")
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config represent the configuration of the settlement engine.
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 { Config // contains filtered or unexported fields }
Engine - the main type (of course).
func New ¶
func New(log *logging.Logger, conf Config, product Product, market string, timeService TimeService, broker Broker, positionFactor num.Decimal) *Engine
New instantiates a new instance of the settlement engine.
func (*Engine) AddTrade ¶
AddTrade - this call is required to get the correct MTM settlement values each change in position has to be calculated using the exact price of the trade.
func (*Engine) HasPosition ¶ added in v0.63.0
func (*Engine) ReloadConf ¶
ReloadConf update the internal configuration of the settlement engined.
func (*Engine) RemoveDistressed ¶
RemoveDistressed - remove whatever settlement data we have for distressed parties they are being closed out, and shouldn't be part of any MTM settlement or closing settlement.
func (*Engine) Update ¶
func (e *Engine) Update(positions []events.MarketPosition)
Update merely adds positions to the settlement engine, and won't be useful for a MTM settlement this function is mainly used for testing, and should be used with extreme caution as a result perhaps the tests should be refactored to use the Settle call to create positions first.
func (*Engine) UpdateProduct ¶
type MarketPosition ¶
type MarketPosition interface { Party() string Size() int64 Buy() int64 Sell() int64 Price() *num.Uint VWBuy() *num.Uint VWSell() *num.Uint ClearPotentials() }
MarketPosition ...
type Product ¶
type Product interface { Settle(*num.Uint, uint32, num.Decimal) (*types.FinancialAmount, bool, error) GetAsset() string }
Product ...
type SnapshotEngine ¶ added in v0.63.0
type SnapshotEngine struct { *Engine // contains filtered or unexported fields }
func NewSnapshotEngine ¶ added in v0.63.0
func NewSnapshotEngine(log *logging.Logger, conf Config, product Product, market string, timeService TimeService, broker Broker, positionFactor num.Decimal) *SnapshotEngine
func (*SnapshotEngine) GetState ¶ added in v0.63.0
func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)
func (*SnapshotEngine) Keys ¶ added in v0.63.0
func (e *SnapshotEngine) Keys() []string
func (*SnapshotEngine) LoadState ¶ added in v0.63.0
func (e *SnapshotEngine) LoadState(_ context.Context, payload *types.Payload) ([]types.StateProvider, error)
func (*SnapshotEngine) Namespace ¶ added in v0.63.0
func (e *SnapshotEngine) Namespace() types.SnapshotNamespace
func (*SnapshotEngine) StopSnapshots ¶ added in v0.63.0
func (e *SnapshotEngine) StopSnapshots()
StopSnapshots is called when the engines respective market no longer exists. We need to stop taking snapshots and communicate to the snapshot engine to remove us as a provider.
func (*SnapshotEngine) Stopped ¶ added in v0.63.0
func (e *SnapshotEngine) Stopped() bool