Template permissions and lifecycle
Templates belong to the authenticated account, not an instrument-specific integration namespace. A template key can therefore affect account templates even when its trading scope is narrower.
Template requests retain the existing full model. They are not PositionRequest objects: templates contain relative grid settings/weights, and no exact linked account plus instrument order execution. Writes are bounded at 64 KiB.
Page through saved templates
GET /v1/templates/list and MCP liftx_templates share the same bounded read. Omit cursor on the first call; limit defaults to 20 and accepts 1–100. Copy next_cursor unchanged into the next call until it is null. It preserves the full timestamp precision and UUID ordering; do not build it from the public timestamp.
413 TEMPLATE_PAGE_TOO_LARGE returns no partial data: reduce limit while retaining the cursor. If one row still exceeds the budget at limit=1, inspect that saved template in the account application. Exact external template reads also enforce the stored size guard. The browser/native session protocol remains unchanged.
Read, edit and save a template
Template field families
- Identity and timestamps:
id,user_id,name,created_at,updated_at. - Product/direction/margin:
instrument_type,position_side, optionalmargin_mode,leverage. - OPEN:
order_grid_enabled, optional count/step/factor,open_price_deltas,open_quantity_percent,open_order_type. - SL/SLx: enable flags, reference/percent settings, supported order type and the selected SLx trigger family.
- TP: enable/rearrangement/grid flags, optional count/step/factor,
tp_pnls,tp_quantity_percent,tp_order_type.
open_quantity_percent/tp_quantity_percent names are different from the position request’s tp_quantity_percents. Do not rename fields by analogy.
Account P&L history
market is reporting selection all, spot or futures; it is not an execution instrument selector. Supply either positive Unix-second before or after, never both. Optional pair_id comes from the reporting pair catalog.
The response contains revision, scope, as_of, points, before, after and selection. Retain its completeness/coverage information. Historical values and current position state answer different questions; an accounting history page is not an execution acknowledgement.
Reporting pairs
next_cursor unchanged while it is nonempty. Pair options are reporting identities drawn from actual trading dimensions, including closed-only pairs. A pair_id is not a canonical executable instrument_id. Do not derive one from the other.
Both account P&L endpoints are link aggregates. Instrument-restricted keys cannot use them. Snapshot admission may return 429; temporary reporting unavailability can return 503 with Retry-After. Back off instead of multiplying polling workers.
Position P&L history
GET /v1/positions/pnl-history?id=… reads an authorized exact position’s canonical history. An optional positive after boundary requests subsequent data. Preserve fixed-point decimals and UTC timestamps. A scoped position_pnl_history stream subscription supplies notifications that tell the client when to read or reset history; it is not a second trading engine.
The response also includes independent timing and pnl_state. Use
timing.opened_at_ms and timing.exited_at_ms for native entry-to-exit holding
duration, with timing.state and revisions governing readiness. Do not substitute
creation, update or operational completion timestamps. Timing can remain ready
when P&L is unavailable. Position pages may carry the same execution_timing;
no extra per-row timing request is needed.
Account analytics
These API/MCP reads reuse the canonical reporting projections and requireread.
Aggregate reads require one authorized exact link and unrestricted instrument
access for that link; exact-position history respects the position’s link and
instrument permissions. Account P&L history and its asset catalog require a
reporting currency. Count and holding-percentage analytics do not. No additional
trading permission or provider connection is used.
For aggregate reads, use the selected
exchange_link_id and its actual
environment. Omit pair_id for All Assets. If a specific reporting pair is
needed, discover it through the matching asset catalog above; it is not an
executable instrument ID. Options support search and bounded opaque cursors.
For Long/Short history, first read the analytics snapshot. Copy its
membership_revision and direction_revision into history’s membership_revision
and revision arguments. Do not use the snapshot’s separate revision field.
Reuse those tokens while paging backward with before, at most 2,000 observations
per page within the rolling year. Zero before ends paging. A stale-revision
failure requires a fresh snapshot and a restart of the needed history, not a
merge with old pages or continuous polling. Closed positions count during their
periods of positive executed Futures exposure; current counts exclude them.
Spot and unfilled positions are excluded. Unknown counts are null; a proven zero
stays zero. A zero/zero ratio is undefined, and long-only exposure has an infinite
long/short ratio. Counts are not notional-weighted or market-wide sentiment.
Heatmap and Holding Time require an explicit user-selected IANA timezone.
from and to are inclusive Gregorian civil dates. Returned boundaries are
half-open UTC instant intervals, including daylight-saving transitions; never
assume a day has 24 hours. For example, the following uses synthetic scope:
liftx_analytics_get_holding_time. Presets are week, month, 3months,
6months, year and custom. Rolling presets include today and forbid
from/to; custom requires both dates. Month arithmetic clamps month ends.
Holding filters closed positions by their final executed exit and requires
verified timing, final P&L and positive executed entry cost. Duration is first
native entry to final exit. pnl_percent is a decimal percentage of entry cost,
not margin. Exact mode returns at most 2,000 positions; larger cohorts return
at most 1,984 count-preserving density groups with observed bounds. Groups are
not individual trades and do not establish exact correlations or averages.
For liftx_analytics_get_order_activity, supply from/to instead of preset, at most 570
dates and through no later than today plus six dates. Count each physical order
once at its first native fill, including partial entry and exit orders. Unfilled
orders and synthetic evidence are excluded. Weekly totals sum available
Monday–Sunday local dates; current week is week-to-date. Use bounded,
nonoverlapping six-month pages and has_earlier when older evidence is needed.
Null counts are not zero; future and nonexistent dates are not activity.
Preserve response state, as_of, revision, scope and exclusions. Loading or
unavailable data cannot establish an empty cohort. Shared admission may return
429 or 503; the MCP result ceiling remains 1 MiB. A capacity failure returns
no truncated dataset: narrow the selection and retain the stated limitations.