Documentation ¶
Index ¶
- Variables
- type Broker
- type Config
- type Engine
- func (e *Engine) AddPosition(party string, evt events.MarketPosition)
- func (e *Engine) AddTrade(trade *types.Trade)
- 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 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) AddPosition ¶
func (e *Engine) AddPosition(party string, evt events.MarketPosition)
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) 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 ...