TradeObservationRequest trade.observation-request@1

Generated at from openvibe-contracts v0.53.0 and openvibe-sdk v0.11.0.

Version
1.0.0
Owner
trade
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/trade/observation-request.v1.json

trade.observation-request@1: the body of POST /api/v1/observations on OpenVibe.Trade (trade.observation.write; services only): one value a source stated for an instrument (symbol or instrument_id). value is the finite decimal as stated; observed_at and retrieved_at are date-times with a zone and not in the future; source_key names the OpenVibe.Sources source and source_ref the statement within it. The same source reference with the same value is answered as it was (200); a different value under the same reference is 409 observation.conflict (a correction needs its own source_ref).

Fields

FieldTypeRequiredDescriptionConstraints
symbolstring
instrument_idstring
metricstringyes
  • pattern ^\s*[A-Za-z][A-Za-z0-9_.:-]{0,79}\s*$
valuestring | numberyes
unitstringyes
  • pattern ^\s*[A-Za-z][A-Za-z0-9/%._-]{0,19}\s*$
currencystring | null
  • pattern ^\s*([A-Z]{3})?\s*$
periodstring | null
  • maxLength 40
observed_atstringyes
retrieved_atstringyes
source_keystringyes
  • pattern ^\s*[a-z0-9][a-z0-9-]{1,63}\s*$
source_refstringyes
  • minLength 1
  • maxLength 300
source_item_idstring | null
  • pattern ^(itm_[0-9A-HJKMNP-TV-Z]{26})?$
source_urlstring | null
  • pattern ^https?://
max_age_secinteger | string | null
  • minimum 60
  • maximum 315360000

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: close
{
  "symbol": "ACME",
  "metric": "close",
  "value": "182.40",
  "unit": "USD",
  "currency": "USD",
  "period": "2026-09-24",
  "observed_at": "2026-09-24T20:00:00Z",
  "retrieved_at": "2026-09-24T21:05:00Z",
  "source_key": "example-quotes",
  "source_ref": "ACME:2026-09-24:close",
  "source_url": "https://quotes.example.com/ACME",
  "max_age_sec": 172800
}
Rejected: no-source-ref
{
  "symbol": "ACME",
  "metric": "close",
  "value": "182.40",
  "unit": "USD",
  "observed_at": "2026-09-24T20:00:00Z",
  "retrieved_at": "2026-09-24T21:05:00Z",
  "source_key": "example-quotes"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('trade.observation-request@1', value);   // { valid, errors: [{ path, message }] }