Position Tracking
MarketGrid can validate client accounts for order entry and can maintain holding positions in traded Instruments (as well as cash Instruments). It does so through Accounts, ExternalAccounts, and Holdings.
MarketGrid may be configured with account and holdings tracking enabled, partially enabled, or disabled.
Accounts
Orders are entered and trades are executed on behalf of Accounts. Whereas a User represents the credentials used to sign in to the system, an Account represents the ultimate beneficiary of the order or owner of a holding. For example, the User may be a trader at a brokerage, and the Account may represent a client of that brokerage.
Note: The distinction between the User who enters the order and the Account on whose behalf the order is entered is an important detail.
MarketGrid can be configured at the Firm level as to whether Accounts will be checked when orders are entered.
If Account checking is on, every order for the Firm must have an Account supplied with it and that Account must exist in MarketGrid, or the order will be rejected.
If Account checking is off, orders may still be entered with account codes, however those codes are just text that is printed with the trades for the order. In that case, the validity of the account codes is not checked.
When Account checking is off, Holding balances will not be maintained nor checked.
External Accounts and Providers
Within each Account in MarketGrid there may be one or more ExternalAccounts. An ExternalAccount represents a account for whom the authority is outside of MarketGrid: for example, an account with a share registry or a bank. In the data model, Accounts own ExternalAccounts, and ExternalAccounts own Holdings.
Each ExternalAccount is associated with one ExternalAccountProvider, which represents the authority that issued that account (for example, the registry or bank).
In addition to being the authority for Holdings, an ExternalAccountProvider is also the authority for the Instrument that the Holding represents. For example, BHP shares are controlled by the Computershare registry and so an ExternalAccount issued by Computershare would be required to represent a holding of BHP shares in MarketGrid.
Note: Each Account may only be associated with each ExternalAccountProvider at most once. It is an error for an Account to have multiple ExternalAccounts for the same ExternalAccountProvider.
Holdings
Each ExternalAccount may own one or more Holdings. A Holding represents a balance that that ExternalAccount holds of a particular Instrument.
A single Holding record contains all of the fields required to carry out all of the book-keeping for that ExternalAccount and Instrument. This includes the deposited balance, balance available to trade, and pending balances for buys/ sells and deposits/withdrawals.
Encumbrance
While exchanges have historically operated on a T+N settlement model, with some level of settlement risk, emerging markets are increasingly moving to an instant settlement model where all products and cash are fully deposited before trading so as to eliminate settlement risk and enable immediate reselling.
MarketGrid's holdings model is capable of all of the position tracking required to support such a model. However, it is necessary for the registry and banking systems (the ExternalAccountProviders) to support encumbrance of a portion of the balance of each holding that traded in MarketGrid, in order to prevent double spending of cash or double selling of securities. Typically, this is achieved through an API integration with the account provider.
Relationships
The relationship between various tables associated with Accounts and Holdings is shown in the following diagram.
erDiagram
Firm ||--o{ Account : owns
Account ||--o{ ExternalAccount : owns
ExternalAccount ||--|| ExternalAccountProvider : has
ExternalAccount ||--o{ Holding : owns
ExternalAccountProvider ||--o{ Instrument : provides
Instrument ||--o{ Holding : is
Holding fields
The following table shows some of the fields tracked in a Holding record.
| Value | Description |
|---|---|
| Balance | The current balance of the Holding. |
| AvailableBalance | The portion of the balance available to be traded or withdrawn. |
| MinimumBalance | If set, the Balance will not be allowed to fall below this level. |
| PlannedBuy | Current total quantity of outstanding (unmatched) buy orders for the Holding. |
| PlannedSell | Current total quantity of outstanding (unmatched) sell orders for the Holding. |
| UnconfirmedDeposit | Current total quantity of outstanding (unconfirmed) deposits for the Holding. |
| UnconfirmedWithdraw | Current total quantity of outstanding (unconfirmed) withdraws for the Holding. |
Holdings and Cash
In MarketGrid, the terms Holdings and Cash are both used to refer to Holdings in different contexts.
Every Instrument that is traded on MarketGrid trades as an InstrumentMarket – an instance of the Instrument on a particular Market. Associated with an InstrumentMarket is a SettlementCurrency which is simply an instance of another Instrument, the other side of the bargain for trades.
Holdings is used to refer to Instruments that are traded on the Exchange. Cash is used to refer to the consideration or settlement amounts for trades.
Note: In MarketGrid, currencies (such as USD) are represented as Instruments. For a given InstrumentMarket, any Instrument may be the cash Instrument used for settlement of trades in that InstrumentMarket.
Adjustment of Holdings
Holding values may be adjusted either as a result of orders and trades or via HoldingTransactions, which represent deposits and withdrawals to or from ExternalAccounts.
Adjustments for orders and trades
The following table shows the adjustments to each of the holding fields for the Traded Instruments and Cash Instruments for order and trades.
| Event | Value | Traded Instrument Adjustment | Cash Instrument Adjustment |
|---|---|---|---|
| Buy Order | PlannedBuy | + OrderQuantity | |
| PlannedSell | + OrderValue + OrderFee | ||
| AvailableBalance | - OrderValue - OrderFee | ||
| Buy Trade | PlannedBuy | - TradeQuantity | |
| ActualBuy | + TradeQuantity | ||
| PlannedSell | - TradeValue - TradeFee1 | ||
| ActualSell | + TradeValue + TradeFee | ||
| AvailableBalance | + TradeQuantity2 | + AdjustFee3 | |
| Balance | + TradeQuantity | - TradeValue - TradeFee | |
| Cancel Buy Order | PlannedBuy | - OrderBalance | |
| PlannedSell | - OrderBalanceValue - OrderBalanceFee | ||
| AvailableBalance | + OrderBalanceValue + OrderBalanceFee | ||
| Sell Order | PlannedBuy | + OrderValue - OrderFee | |
| PlannedSell | + OrderQuantity | ||
| AvailableBalance | - OrderQuantity | - OrderFee | |
| Sell Trade | Planned Buy | - TradeValue + AdjustFee4 | |
| ActualBuy | + TradeValue + TradeFee | ||
| PlannedSell | - TradeQuantity | ||
| ActualSell | + TradeQuantity | ||
| AvailableBalance | + TradeValue5 + AdjustFee3 | ||
| Balance | - TradeQuantity | + TradeValue - TradeFee | |
| Cancel Sell Order | PlannedBuy | - OrderBalanceValue + OrderBalanceFee | |
| PlannedSell | - OrderBalance | ||
| AvailableBalance | + OrderBalance | + OrderBalanceFee |
Adjustment of fees can be complex. On a trade, the amount of fee returned to
`PlannedSell` is actually the amount of the total `OrderFee` specifically
attributable to that trade, which may be a different amount to TradeFee.
Only if `CanResellToday` is enabled for both the Firm and Instrument
involved.
`AvailableBalance` is adjusted for the difference between the amount of the
total `OrderFee` specifically attributable to the trade and the actual fee
on the trade if the `OrderFee` is greater than the `TradeFee` for that
portion of the order.
`PlannedBuy` is adjusted for the difference between the amount of the total
`OrderFee` specifically attributable to the trade and the actual fee on the
trade.
Only if `CanUseTodaysCash` is enabled for both the Firm and Instrument
involved.
Adjustments for holding transactions
The following table shows the adjustments made to holding fields for deposit and withdrawal transactions.
| Transaction | Value | Transaction Instrument Adjustment | |
|---|---|---|---|
| Unverified Deposit | UnconfirmedDeposit | + DepositQuantity | |
| Confirm Unverified Deposit | UnconfirmedDeposit | - DepositQuantity | |
| ConfirmedDeposit | + DepositQuantity | ||
| AvailableBalance | + DepositQuantity | ||
| Balance | + DepositQuantity | ||
| Cancel Unverified Deposit | UnconfirmedDeposit | - DepositQuantity | |
| Verified Deposit | ConfirmedDeposit | + DepositQuantity | |
| AvailableBalance | + DepositQuantity | ||
| Balance | + DepositQuantity | ||
| Unverified Withdraw | UnconfirmedDeposit | + WithdrawQuantity | |
| Confirm Unverified Withdraw | UnconfirmedDeposit | - WithdrawQuantity | |
| ConfirmedDeposit | + WithdrawQuantity | ||
| AvailableBalance | - WithdrawQuantity | ||
| Balance | - WithdrawQuantity | ||
| Cancel Unverified Withdraw | UnconfirmedDeposit | - WithdrawQuantity | |
| Verified Deposit | ConfirmedDeposit | + WithdrawQuantity | |
| AvailableBalance | - WithdrawQuantity | ||
| Balance | - WithdrawQuantity |