Skip to content

Currency Lifecycle

A currency is the one master-data object every service references by symbol. The admin console is the only place it is created, edited or deleted, and the three legs cross two SOAs: admin → webservice → findata. This page follows each leg: which calls are made, in what order, under what conditions, and what is left untouched.

The object

Currency in glacez-lib-model. _id is a Mongo ObjectId; symbol is the platform-wide key every other document stores. endTimestamp is the delist marker — null means active; cmcRank, tags and iconUri are display-only. Delisting is a pricing flag, not a lifecycle state: it changes which rows the price and revision queries select, and nothing else.

A ticker is not an asset, and a provider re-assigns dead ones. startTimestamp is CoinMarketCap's listing date for the symbol, so compare it with the first stored OHLCV row before dating a series: a symbol whose history starts years before its current listing is two coins under one ticker (AION, MM and TCT each merged an old and a new one), and dating it delisted would freeze the old coin's history under the new coin's name. The stored series is also a cache of a provider, not the provider — the last day with volume on our own rows disagreed with the provider's aggregate on 14 of 24 symbols and produced impossible daily volumes — so a last-trading day comes from a provider's candles (volume > 0, Binance's klines as the identity anchor since it keeps serving delisted pairs) and endTimestamp is the midnight after it.

Create — POST /resources/currencies

admin → webservice → findata POST /v2/currencies. findata validates: symbol [A-Z0-9]+ after trim/upper, name and iconUri non-empty, timestamps inside [2016-01-01, 2100-01-01], start ≤ end, symbol not already taken. A violation answers 400.

Then, when glacez.findata.population.enabled is true (prod and ctlq; false in dev), findata performs a synchronous priceFeed.dailyCandles(symbol, 30, now) — Gate, then Binance, then KuCoin, then Kraken — inside the request. A slow venue hangs the Save button; an unlisted symbol saves a currency with no history, silently.

Update — PUT /resources/currencies/{id}

Hop Call
admin CurrencyFormPanel.save() — a symbol change is confirmed first, with the counts from GET /resources/currencies/{id}/references — → persist() → PUT /resources/currencies/{id}
webservice CurrencyService.updateCurrency — normalizes the symbol, one getCurrencyById for oldCurrency, the migration below when the symbol changed
webservice → findata PUT /v2/currencies/{id}
findata getCurrencyById twice (resource + service), findBySymbol conflict check, save, then the OHLCV re-key

Conditions: 400 for the same validation as create, plus a symbol that is not [A-Z0-9]+ after trim and upper — webservice normalizes btc to BTC, and the console's own field pattern refuses the lower-case value so it never travels; 500 for a missing id (findata throws NoSuchElementException, a RuntimeException, so it never reaches a 404); an empty tag set is a silent no-op — findata keeps the stored tags.

Previous symbols are writable, under validation. The alias list decides which venue records convert into this currency, so findata refuses an alias that is the currency's own symbol, another currency's symbol, a blank or a duplicate, and it evicts the currency cache on write so a new alias is live at once instead of after the five-minute timer. A submitted list replaces the stored one — that is how an operator adds one the hardcoded seed never knew (EXRD → XRD) and drops one a rename appended — while a caller that omits the field entirely leaves the list to the renames.

A symbol rename rewrites the reference set, then the currency document carries the new symbol first. The order is the whole point: the platform has no id join, so every document stores the symbol string, and a dependent document must never name a symbol Currency does not have yet. findata's PUT lands first, then webservice migrates five legs, each idempotent and queried by the old symbol:

Leg Document Field
orders order (closed and limit) pair.source, pair.target
transfers transfer currency
strategies strategy coinName
action pairs action pair.source, pair.target
notes note coinName
events event (order status, ROI, transfer status) pair.source, pair.target, instrument

A failing leg reverts: the same legs run with the symbols swapped, then the old currency document is written back, and the call answers 406 naming the leg. A refused rename leaves nothing behind, so the operator retries the same save. The transient inside a run — references still on the old symbol while the currency already carries the new one — costs an unvalued row, never a lost one.

findata's leg moves the three documents it keys by the symbol — the whole OHLCV series, then the halving events, then the news articles — and writes the currency document last, so an interruption leaves the stored symbol on its old value and the same call retried converges. Each step reads by the old symbol, so a re-run picks up what a failure missed instead of duplicating it; a target symbol that already carries candles is overwritten where the timestamps collide and the run says so in a warning. Because this leg is symmetric, the webservice revert above works by simply writing the old document back. Changing startTimestamp fetches no history; changing endTimestamp only changes which rows the price and revision queries select.

A rename now teaches the record import the old ticker itself. Venues keep reporting the ticker a coin was listed under, and core converts only records whose pair or instrument is in Currency. findata's update appends the old symbol to Currency.previousSymbols, and the reconciler resolves a record through those aliases before that Currency check, so a rename needs no code change and no release. A record the venue reports under the old ticker keeps reconciling, and a record that arrived before the rename converts on the next run: nothing is lost, it waits in recordOrder / recordTransfer until it lands. Renaming back to a previous symbol takes it off the list again. Mechanics and the rebrands already recorded: Transaction lifecycle § Producer 4. The records themselves are never rewritten — the rename re-keys the platform's own documents, and every reader resolves a record's symbol on read, balance and earn rows included, so a row keeps the venue's ticker by design (ADR-006).

A transaction's fee names its instrument too, and the rename's legs do not rewrite it. Transaction.fee is a quoted value keyed by the ticker the venue charged the fee in, so an order whose pair the rename migrated can still carry fee.values.MATIC; the price series, re-keyed with the currency, has no MATIC row left to value it. That is a reader's job, not a migration's: the fee total resolves the key through Currency.previousSymbols (plus the seed map) before asking for a close, so a fee stored under the old ticker is valued under the current one, on its own day, and the total is not short by it.

Delete — DELETE /resources/currencies/{id}

Hop Call
admin CurrencyFormPanel.delete() → DELETE /resources/currencies/{id}
webservice → findata getCurrencyById(id)
webservice local GET /currencies/{id}/references — four counts against this service's own repositories
webservice → findata DELETE /v2/currencies/{id}
findata OHLCV series → halving events → the currency document

The guard is the references endpoint: orders (limit + closed, source + target), transfers, strategies and notes. Any non-zero count answers 406 and nothing is deleted. The admin asks the same endpoint before confirming, so the button and the guard cannot drift.

Balance records (RecordSpot, RecordEarn) are not part of the guard: they are exchange-synced snapshots, and exchanges keep listing a delisted coin with a zero balance for years. Counting them would make a dead currency undeletable for a position nobody holds.

The order of writes keeps the point of no return last: the OHLCV series goes first, then the halving events, then the currency document. A failure at any step leaves the currency in place and the request retryable — there is no state where a currency is gone but its history survives. The news articles naming the symbol are left alone: they are history about a coin, not a document that only exists because of it, and a rename is the case that moves them. The delete is irreversible: re-adding the currency re-populates only population.days (30) days.

deleteAllCurrencies is gone from both contracts — a bulk wipe of master data that skipped the OHLCV series and had no caller but tests.

What is not touched

The rename migrates the reference set above. These keep a dangling symbol on rename and on delete:

Document Field On rename On delete
RecordSpot / RecordEarn / RecordBalance balances.symbol / earns.instrument not migrated dangling — an exchange snapshot, not a position the guard protects
ExchangeInfo.pairInfos pair source/target not migrated dangling — the exchange's catalogue, not ours to prune
ConnexionSnapshot / PortfolioSnapshot instrument keys not migrated dangling — history, not a position
Simulation / SimulationTransaction action and transaction pairs not migrated dangling — a past backtest, a per-day fact

Downstream effect of a delete

portfolio builds its price request from getAllCurrencies(). A deleted symbol drops out of the request; PricesProcessor.getPricesSafely returns null and the position is silently skipped — it keeps its total, loses market value and ROI, and leaves one line in the error list. The guard exists so this cannot happen to a position a user still holds.

A balance record still naming the deleted symbol is the expected residue: it costs a skipped price for a zero position, and the exchange keeps reporting it regardless of what the platform's master data says.

Cache fan-out

Seven currencies caches: admin, webservice, findata, portfolio, core, worker and simulator, each with its own 5-minute evictor. A write evicts the first three; the other four are stale for up to 5 minutes. This corrects the "evicts all three on the way back" reading in services/webapp-admin — the three are the whole path, not the whole platform.

Error surface

Status Cause
400 validation: symbol shape, name, iconUri, timestamps, duplicate symbol
406 the delete guard (anything a user holds or configured still references the symbol), or a rename leg that failed and was reverted — the message names the leg
404 a missing currency, by id or by symbol — both lookups raise the platform's NotFound, and the advice that maps it exists at both hops (findata's handler, then webservice's handleNotFound, which also carries FeignException.NotFound so the callee's 404 is not flattened into a 500)