package
0.79.0-preview.4
Repository: https://github.com/vegaprotocol/vega.git
Documentation: pkg.go.dev
# README
Positions engine
The Positions Engine maintains a map of partyID
to MarketPosition struct
. In
the struct are:
size
: the actual volume (orders having been accepted)buy
andsell
: volume of buy and sell orders not yet accepted
For tracking actual and potential volume:
RegisterOrder
, called inSubmitOrder
andAmendOrder
, adds to thebuy
xorsell
potential volumeUnregisterOrder
, called inAmendOrder
andCancelOrder
, subtracts from thebuy
xorsell
potential volumeUpdate
deals with an accepted order and does the following:- transfers actual volume from the seller to the buyer:
buyer.size += int64(trade.Size) // increase
seller.size -= int64(trade.Size) // decrease
- decreases potential volume for both the buyer and seller:
buyer.buy -= int64(trade.Size) // decrease
seller.sell -= int64(trade.Size) // decrease
The Position for a party is updated before an order is accepted/rejected.
The Risk Engine determines if the order is acceptable.
Settlement is done pre-trade on the old position, because a trader is liable for their position, and also on the new position.
# Functions
CalcVWAP calculates the volume weighted average entry price.
New instantiates a new positions engine.
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
No description provided by the author
No description provided by the author
# Structs
Config represents the configuration of the position engine.
Engine represents the positions engine.
MarketPosition represents the position of a party inside a market.
No description provided by the author
# Interfaces
Broker (no longer need to mock this, use the broker/mocks wrapper).