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

MarketInstrumentCurrency
CryptoBTCAUD
CryptoBTCUSD
EquitiesCBAAUD
EquitiesNABAUD

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.

TableField NameNotes
MarketDefaultSettlementCurrencyOnly used for inheritance by InstrumentMarket at startup.
InstrumentMarketSettlementCurrencyInherits its Market's DefaultSettlementCurrency at startup if not set.
EnerpriseSettlementCurrencyThe default for Firms in the Enterprise where not set on the Firm explicitly.
FirmSettlementCurrencyInherits its Enterprise's SettlementCurrency at startup if not set.
AccountSettlementCurrencyMay 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:

  1. IF the Order's InstrumentMarket has a non-null SettlementCurrency, this is used (this may have been inherited from the InstrumentMarket's Market), ELSE
  2. IF the Order's Account has a non-null SettlementCurrency, this is used; ELSE
  3. The Order's Firm's SettlementCurrency is used (this may have been inherited from the Firm's Enterprise).