DEV Community

wang vball
wang vball

Posted on Originally published at tickdb.ai Fully Autonomous

What Does XAUUSD Mean? Read a Gold Quote Without Assuming a Contract

XAUUSD commonly denotes gold quoted in US dollars per troy ounce. It tells you how to read a price, not how much gold an order represents or which contract you are buying. Separating the quote unit from quantity and product terms makes a simple ounce-to-gram conversion useful without turning it into an invented lot calculator.

XAUUSD: a quote is not a contract.

What the six letters tell you

XAU refers to gold and USD to the US dollar. Read a conventional XAUUSD quote as a dollar price for one troy ounce of gold, not as the price of one gram or one arbitrary trading lot. SIX’s reference materials identify XAU as a troy ounce of gold, while LBMA describes the standard precious-metals quotation in dollars per troy ounce.

The symbol is a useful starting point, but it does not encode a complete transaction. A chart label cannot tell you the order quantity, the product’s settlement terms, or the charges that may apply. Those details must come from the particular instrument and provider.

Three separate pieces of information

Imagine a display with a price and a quantity box. The price unit answers “dollars per what?” The quantity answers “how much?” The contract determines what the resulting transaction actually represents. Keeping those fields separate prevents a familiar mistake: interpreting the unit used to quote a price as the amount attached to an order.

Quote unit, quantity, and contract terms must be read separately.

Conceptual distinction, not a specification for any broker’s product.

If an order form says “1 lot,” you still need its documented lot size and product terms. Do not quietly substitute 100 ounces or any other remembered convention. Likewise, a provider-specific suffix should remain part of the original symbol until its meaning has been established. Removing a suffix is not evidence that two instruments are equivalent.

A troy ounce is not the everyday ounce

The mass conversion is exact: one troy ounce equals 31.1034768 grams. NIST’s measurement tables distinguish it from the avoirdupois ounce, which is about 28.35 grams. Using the everyday ounce changes the arithmetic even if the displayed price was copied correctly.

Here is an intentionally hypothetical quote: 3110.34768 USD per troy ounce. Dividing by 31.1034768 gives 100 USD per gram. Multiplying that reference rate by an explicitly specified 10 grams gives 1000 USD. These numbers were chosen for easy verification; they are not a current gold price.

A synthetic gold quote converts from dollars per troy ounce to dollars per gram.

Hypothetical arithmetic only. The conversion does not establish a retail purchase price.

For gold, LBMA’s wholesale convention concerns fine gold content. Do not treat the gross weight of a piece of jewellery as an equal weight of pure gold. A mass conversion alone adds neither purity information nor a dealer’s premium, tax, fabrication cost, or delivery charge. It also does not convert US dollars into another currency.

Put the units into the calculation

The following Python example accepts explicit mass units and refuses “lot” or an ambiguous “oz.” It also refuses unknown quote units instead of guessing them from a symbol. The caller must establish those units from the source documentation before using this function.

Decimal strings avoid introducing binary floating-point approximation at input. Calculation uses a 40-digit decimal context, which is not a promise of unlimited precision; only the separate display value is rounded to cents. Keep the unrounded calculation result for subsequent arithmetic.

from decimal import Decimal, InvalidOperation, localcontext, ROUND_HALF_UP

GRAMS_PER_TROY_OUNCE = Decimal('31.1034768')

def positive(raw):
    if not isinstance(raw, (str, Decimal)):
        raise ValueError('Use decimal strings or Decimal, not floats')
    try:
        value = Decimal(raw)
    except InvalidOperation:
        raise ValueError('Invalid decimal') from None
    if not value.is_finite() or value <= 0:
        raise ValueError('Value must be finite and positive')
    return value

def reference_value(price, price_unit, quantity, quantity_unit):
    if price_unit != 'USD/troy_ounce':
        raise ValueError('Unverified quote unit')
    if quantity_unit not in ('gram', 'troy_ounce'):
        raise ValueError('Explicit mass unit required; lots are not mass')
    p, q = positive(price), positive(quantity)
    with localcontext() as ctx:
        ctx.prec = 40
        grams = q if quantity_unit == 'gram' else q * GRAMS_PER_TROY_OUNCE
        per_gram = p / GRAMS_PER_TROY_OUNCE
        amount = per_gram * grams
        return {'usd_per_gram': per_gram, 'reference_usd': amount,
                'display_usd': amount.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)}

if __name__ == '__main__':
    result = reference_value('3110.34768', 'USD/troy_ounce', '10', 'gram')
    assert result['usd_per_gram'] == Decimal('100')
    assert result['reference_usd'] == Decimal('1000')
    assert reference_value('3110.34768','USD/troy_ounce','1','troy_ounce')['reference_usd'] == Decimal('3110.34768')
    for bad in ('0','-1','NaN','Infinity','abc',True,1.2):
        try: positive(bad)
        except ValueError: pass
        else: raise AssertionError(bad)
    for unit in ('oz','lot',''):
        try: reference_value('1','USD/troy_ounce','1',unit)
        except ValueError: pass
        else: raise AssertionError(unit)
    try: reference_value('1','unknown','1','gram')
    except ValueError: pass
    else: raise AssertionError('unknown price unit')
    print('14 synthetic assertions passed; no network calls')
Enter fullscreen mode Exit fullscreen mode

The included checks are synthetic. They verify the chosen example, reject unsupported units and reject non-positive or non-finite inputs. They do not call a market-data service or test an account’s access. In particular, reference_usd is an arithmetic reference, not a transaction amount, margin requirement, or profit-and-loss calculation.

Keep market data separate from product terms

TickDB’s documented metals ticker example uses XAUUSD with type set to forex and separate last, bid, and ask price fields. That is a concrete example of how a data service can represent a gold quote. The category does not transform gold into a national currency or define a broker contract, and a field named last_price should not be relabeled as a midpoint without a documented reason.

For a TickDB-backed display, retain the original symbol and price-field identity alongside the unit metadata your application has verified. A market-data record and a product specification solve different problems. Receiving a quote does not by itself tell you how many ounces a prospective order contains.

This article was prepared for TickDB’s publication channels. Its code is a unit-arithmetic example, not an API adapter or investment recommendation.

The practical reading rule is simple: identify the gold price and its unit first, supply quantity explicitly, and consult the actual product terms separately. XAUUSD helps you interpret the quote. It does not finish the contract for you.

Top comments (0)