Currencies
There are a number of currency-related fields in MarketGrid that determine how Orders are quoted, Trades are priced and Trades are settled.
Definition of a Currency
A Currency is just an instance of a MarketGrid Instrument. Currencies are used as the “settlement side” of a Trade, or for a currency pair InstrumentMarket (such as USD-AUD) as the traded and settlement currency. Currencies are also used in the calculation of Fees and Limits.
InstrumentMarket
InstrumentMarket Currency
Each InstrumentMarket is uniquely defined by three fields:
- Market - The Market on which the InstrumentMarket is traded
- Instrument - The Instrument being traded
- Currency - The Currency (Instrument) in which the Instrument is quoted (as distinct from settled)
For example, consider the following simple Market, Instrument and InstrumentMarket tables:
Market
| Market |
|---|
| Crypto |
| Equities |
Instrument
| Instrument |
|---|
| AUD |
| USD |
| BTC |
| CBA |
| NAB |
InstrumentMarket
| Market | Instrument | Currency |
|---|---|---|
| Crypto | BTC | AUD |
| Crypto | BTC | USD |
| Equities | CBA | AUD |
| Equities | NAB | AUD |
Note that there are two BTC InstrumentMarkets on the Crypto Market but that they trade in different Currencies (AUD and USD) so they are distinct.
The Equities Market is for Australian shares only, so we only have a single instance of each of the equity Instruments on that Market.
Prices for a given InstrumentMarket are entered and displayed in the Currency for the InstrumentMarket.
InstrumentMarket Currency Definition
An InstrumentMarket's Currency may be defined directly on the InstrumentMarket in the Currency field, or it may be left unset (null), in which case it will be inherited from its Market's DefaultCurrency field at startup.
In the example above, for the Crypto Market, since each InstrumentMarket may have a different Currency (we are quoting currency pairs), the Currency field on each InstrumentMarket would be set explicitly. However, for the Equities Market in the example, we are only quoting Australian shares and all are quoted in the same currency (in this case AUD) so the Currency value could be inherited from the Market.
SettlementCurrency
Distinct from how an InstrumentMarket is quoted (which is defined by its Currency), trades in each InstrumentMarket may be settled using the same or a different currency, known as the SettlementCurrency. In fact, the two sides of a Trade (the buy side and the sell side) may be settled using different settlement currencies if required.
SettlementCurrency is a foreign key to a row in the Instrument table. It may be set on a number of MarketGrid tables as described below.
| Table | Field Name | Notes |
|---|---|---|
| Market | DefaultSettlementCurrency | Only used for inheritance by InstrumentMarket at startup. |
| InstrumentMarket | SettlementCurrency | Inherits its Market's DefaultSettlementCurrency at startup if not set. |
| Enerprise | SettlementCurrency | The default for Firms in the Enterprise where not set on the Firm explicitly. |
| Firm | SettlementCurrency | Inherits its Enterprise's SettlementCurrency at startup if not set. |
| Account | SettlementCurrency | May be not set (NULL). |
Determining an Order's Settlement Currency
For each Order (and any Trades executed against that Order), the SettlementCurrency is determined as follows:
- IF the Order's InstrumentMarket has a non-null
SettlementCurrency, this is used (this may have been inherited from the InstrumentMarket's Market), ELSE - IF the Order's Account has a non-null
SettlementCurrency, this is used; ELSE - The Order's Firm's
SettlementCurrencyis used (this may have been inherited from the Firm's Enterprise).