Type system
Ptolemy uses a type-based schema system. Instrument types and market types define the custom attributes available on each record. This allows you to model any financial instrument or venue without losing schema clarity.
Types and field definitions
Every instrument belongs to exactly one instrument type (e.g. equity, bond, etf). The type determines which custom fields are available on the instrument — this is called the Entity-Attribute-Value (EAV) model.
Each type has one or more field definitions. A field definition specifies:
Data types
Field values are stored and returned as strings regardless of data type, to avoid precision loss on numeric values. Your application is responsible for parsing them to the appropriate native type.
number field values as strings in your code — never as JavaScript number or Python float. Use a dedicated decimal library to avoid floating-point precision loss on financial data.Field values in practice
When creating or updating an instrument, pass field values as a flat key-value object using the field_values property. Keys are field_key values; values are strings (or the appropriate native type).
The response always includes an extra_fields_snapshot — a JSONB snapshot of all current field values for that instrument, updated automatically whenever field values change.
Extras: unstructured metadata
Each instrument (and market) also supports an extras field — a free-form JSON object for unstructured data that doesn’t belong in the typed schema. Use extras for third-party IDs, internal references, or any data you want to store but don’t need to filter on.
Read-only types
Type schemas (instrument types, market types, time series types) and their field definitions are read-only for robot users. Only human users with the Editor or Admin role can create or modify type schemas via the dashboard or API.
This design ensures that production robot integrations don’t accidentally alter the schema used by other systems. Schema changes require a deliberate human action.