{"id":"fx-cross-rate-compute","version":"1.0.0","description":"Derive a cross exchange rate and its inverse from two quoted rates that share one currency, at a stated scale.","supported_operations":["cross rate from two exchange rates","derive GBP/JPY from USD/JPY and GBP/USD","triangulate currency rate via euro","DEM to FRF from euro conversion rates","inverse exchange rate rounded to 6 decimals","what is the EUR/GBP rate if I know USD/EUR and USD/GBP","synthetic cross rate calculation","derive the rate between two currencies through a common pivot"],"unsupported_operations":["fetching live or historical exchange rates","converting an amount of money between currencies","chains of more than two quotes","bid/ask spreads or fees"],"semantics":["Quote convention: {base: X, quote: Y, rate: r} means 1 X = r Y (EUR/USD 1.0843: 1 EUR = 1.0843 USD). Currency codes are opaque strings matching ^[A-Z0-9]{3,5}$ (upper-case only, no case folding, no ISO lookup), so historic and non-ISO codes (DEM, FRF, USDT) are accepted. rates holds exactly 2 quotes; each rate is a positive decimal (zero is invalid_input, reason rate_zero); base equal to quote is invalid_input (reason same_currency).","The two quotes must share exactly one currency, reported as via; no shared currency or the same pair twice is invalid_input with reason no_common_currency. The target must be exactly the two non-shared currencies in either order, else invalid_input with reason target_mismatch.","Computed on exact rationals. If p(X) is the amount of the shared currency worth 1 X (r for a quote X/shared, 1/r for shared/X), then for target {base T, quote U} rate = p(T)/p(U) and inverse_rate = p(U)/p(T). Example: EUR/DEM 1.95583 and EUR/FRF 6.55957 give DEM/FRF 3.353855 at scale 6.","rate and inverse_rate are each rounded once from the exact rational at scale (0..20) with the given mode; the inverse is not derived from the rounded rate. Both are fixed-scale strings and may round to zero. exact is true iff neither needed rounding.","The ten rounding modes: half_even, half_up (ties away from zero), half_down, half_ceiling, half_floor, up, down, ceiling, floor, and unnecessary (if either value is inexact the call is not_computable, reason rounding_necessary).","A rate string over 62 characters is limit_exceeded, checked before the syntax; more than 60 digits or 40 fraction digits is invalid_input. base and quote in the output echo the target; the tool holds no rate data and has no clock or network.","Disclaimer: arithmetic calculation only; not financial, tax, legal, or investment advice."],"limits":{"max_decimal_chars":62,"max_decimal_digits":60,"max_fraction_digits":40,"max_scale":20,"quotes":2},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["rates","target","scale","rounding"],"properties":{"rates":{"type":"array","minItems":2,"maxItems":2,"description":"Exactly two quotes that share exactly one currency. Each says: 1 base = rate quote.","items":{"type":"object","additionalProperties":false,"required":["base","quote","rate"],"properties":{"base":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$","description":"Currency code, opaque 3-5 upper-case letters or digits (ISO or otherwise; not looked up)."},"quote":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$"},"rate":{"type":"string","minLength":1,"maxLength":62,"pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Positive decimal: units of quote per 1 base."}}}},"target":{"type":"object","additionalProperties":false,"required":["base","quote"],"properties":{"base":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$"},"quote":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$"}},"description":"The requested pair: 1 base = ? quote. Must be the two currencies that are NOT shared by the given quotes (either order)."},"scale":{"type":"integer","minimum":0,"maximum":20,"description":"Fraction digits of the output rates."},"rounding":{"type":"string","enum":["half_even","half_up","half_down","half_ceiling","half_floor","up","down","ceiling","floor","unnecessary"]}}},"output_schema":{"type":"object","additionalProperties":false,"required":["base","quote","rate","inverse_rate","via","exact"],"properties":{"base":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$"},"quote":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$"},"rate":{"type":"string","minLength":1,"maxLength":400,"pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Units of `quote` per 1 `base`, fixed scale."},"inverse_rate":{"type":"string","minLength":1,"maxLength":400,"pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Units of `base` per 1 `quote`, computed from the exact rational (not by inverting the rounded rate), fixed scale."},"via":{"type":"string","minLength":3,"maxLength":5,"pattern":"^[A-Z0-9]{3,5}$","description":"The shared (pivot) currency."},"exact":{"type":"boolean","description":"true iff neither rate needed rounding."}}},"examples":[{"input":{"rates":[{"base":"EUR","quote":"DEM","rate":"1.95583"},{"base":"EUR","quote":"FRF","rate":"6.55957"}],"target":{"base":"DEM","quote":"FRF"},"scale":6,"rounding":"half_even"},"output":{"base":"DEM","quote":"FRF","rate":"3.353855","inverse_rate":"0.298164","via":"EUR","exact":false}},{"input":{"rates":[{"base":"USD","quote":"JPY","rate":"155.2"},{"base":"GBP","quote":"USD","rate":"1.27"}],"target":{"base":"GBP","quote":"JPY"},"scale":4,"rounding":"half_up"},"output":{"base":"GBP","quote":"JPY","rate":"197.1040","inverse_rate":"0.0051","via":"USD","exact":false}}],"execute_url":"/v1/tools/fx-cross-rate-compute/versions/1.0.0/execute"}