ThirdMomentQuantX

Data store contract

Contents
  1. Entities
  2. Store-wide rules
  3. Documents (IDocumentStore)
  4. Quotes (IMarketDataStore)
  5. Data series (IDataSeriesStore)
  6. Administration (IStoreAdministration)
  7. Example: the bundled SQLite store

Status: contract version 1. The rules below are checked by the conformance kit; the code of each rule (D1, Q2, ...) is the code the kit prints.

QuantX reads and writes its data through four interfaces of the core library, in the namespace QuantX.Storage. A data store implements them; nothing else in QuantX knows how or where the data is kept. This page is the logical data model those interfaces expose and the rules a store must follow. Writing a data store explains how to build and install one.

Entities

Entity Key Content Interface
Quote date, instrument, field one finite number IMarketDataStore
Document version kind, identifier, version schema version, fields (label to text), creation time and author; see Document kinds IDocumentStore
Data series observation series identifier, date one finite number IDataSeriesStore
Admin log entry sequence number time, author, action, target, content before, content after IStoreAdministration
  • Dates are calendar dates without a time, from 1900-01-01 to 2199-12-31, written yyyy-MM-dd (ISO 8601) when a store keeps them as text.
  • Texts are compared ordinally, character by character, case included: B comes before a. Every order below is that order.
  • Numbers are IEEE 754 doubles and must come back to the last bit. A quote is in the library's own units: a rate of 4.75% is 0.0475.
  • Times (createdAt, the log's at) keep their offset from UTC and seven decimal places of seconds.
  • A quote's instrument and field, a document's kind, identifier, labels and author, and a series identifier are non-empty and have no leading or trailing spaces. An instrument and a field never contain |.

Store-wide rules

  • E1. The conformance kit writes, so it runs only on an empty store: no quote, no series, no document and an empty admin log. Without an administration, documents can only be listed by kind, so the kit checks the two kinds it writes (ConformanceDocument, ConformanceOther) and touches no other.
  • All operations are asynchronous and take a cancellation token. A store must accept calls from several threads at once.
  • A store never reads the system clock: the times it records are given to it.
  • A store holds no provider names: a quote never records where it came from.

Documents (IDocumentStore)

Documents are trades, conventions, mappings, volatility grids and any other versioned record. A version is never changed by a save: each change is a new version.

  • D1. The first version of a document is 1; saving any other version of a new document throws InvalidOperationException. A saved version loads back as saved.
  • D2. A new version must be the latest plus one; saving any other throws InvalidOperationException, and saving an existing version again is refused the same way. Loading without a version gives the latest; loading a missing version or document gives null.
  • D3. The history of a document lists every version, oldest first; a missing document has an empty history.
  • D4. Listing a kind gives the latest version of each of its documents, by identifier; a kind without documents gives an empty list.
  • D5. Labels and values come back exactly, including empty values, quotes, backslashes, line breaks and texts of any length, with the schema version, the creation time (with its offset) and the author.

Quotes (IMarketDataStore)

  • Q1. A day's quotes come back by instrument, then field.
  • Q2. Saving a quote that is already stored replaces its value (last saved wins).
  • Q3. A batch that holds the same date and key twice is refused with ArgumentException, and no quote of the batch is saved.
  • Q4. Values come back to the last bit.
  • Q5. A key's series runs between two dates, both included, by date.
  • Q6. Extents give, for each key, the number of quotes and the first and last dates, by instrument, then field.
  • Q7. The keys between two dates, both included, come by date, instrument, then field. The interface has a default implementation that reads day by day; a store should replace it with one query.

Data series (IDataSeriesStore)

  • S1. Observations run between two dates, both included, by date; saving an observation already stored replaces it.
  • S2. An empty identifier, one with a leading or trailing space, or one containing |, is refused with ArgumentException; so is a batch that repeats a date, and nothing of it is saved.
  • S3. Extents give, for each series, the number of observations and the first and last dates, by identifier.
  • S4. Deleting a series removes every observation, returns how many there were and, when the store has an administration, logs the action DeleteDataSeries on the target DataSeries <id> with the deleted dates and values. Deleting a missing series returns 0 and logs nothing.

Administration (IStoreAdministration)

The administration is what the desktop's admin panel uses to browse and correct the store. It is optional: DataStoreConnection.Administration is null for a store without one, and the kit then skips the A checks. The desktop then shows its admin pages as not available for the store. A store that is read-only (DataStoreConnection.IsReadOnly) cannot be imported into: the Import page says so instead of running a provider.

Every edit and deletion is logged in the same transaction, with what it replaced, so that a mistake can be undone by hand. The kit checks that the logged contents hold the values involved, whatever their format. Acting on a missing entry throws InvalidOperationException and changes nothing, the log included.

  • A1. Quote dates come latest first; the count of quotes per date earliest first; document kinds in order.
  • A2. Editing a quote replaces its value and logs EditQuote on <date> <instrument> | <field>, with the old and new values as round-trip numbers.
  • A3. Deleting a quote removes it and logs DeleteQuote with its value.
  • A4. Editing a document version replaces its fields and schema version in place, keeping its version number, creation time and author, and logs EditDocumentVersion on <kind> <id> v<version> with the version before and after.
  • A5. Deleting a version logs DeleteDocumentVersion on <kind> <id> v<version>; deleting a document logs DeleteDocument on <kind> <id> with every version.
  • A6. The log comes latest first, with increasing sequence numbers, and at most the number of entries asked for; a negative number throws ArgumentOutOfRangeException.

The bundled stores write a logged document version as {"version","schemaVersion","createdAt","createdBy","fields"}, a deleted series as [["2026-09-01",4.25],...] and a quote value with the round-trip format; a store should write the same so that the admin log reads alike.

Example: the bundled SQLite store

The SQLite store (schema version 4) keeps the model in five tables:

CREATE TABLE quotes (date TEXT, instrument TEXT, field TEXT, value REAL,
                     PRIMARY KEY (date, instrument, field));
CREATE TABLE documents (kind TEXT, id TEXT, version INTEGER,
                        schema_version INTEGER, body TEXT, created_at TEXT,
                        created_by TEXT, PRIMARY KEY (kind, id, version));
CREATE TABLE series_observations (series TEXT, date TEXT, value REAL,
                                  PRIMARY KEY (series, date));
CREATE TABLE admin_log (sequence INTEGER PRIMARY KEY AUTOINCREMENT, at TEXT,
                        by TEXT, action TEXT, target TEXT, before TEXT,
                        after TEXT);
CREATE TABLE schema_info (version INTEGER);

A document's fields are a JSON object of texts in body; dates and times are ISO 8601 texts. Any other layout is allowed: only the behaviour above is the contract.

Reconnecting Connection paused Could not reconnect Could not resume Session expired

The connection to the server was lost. Trying to restore it. Next attempt in 0s. The connection was paused. It will resume on its own. The server did not answer. Your work is still here. The paused session could not be resumed. The server could not restore this session. Reloading will start a new one.

An unhandled error has occurred. Reload 🗙