@arcaresearch/sdk
v0.1.133
Published
TypeScript SDK for the Arca platform
Readme
@arcaresearch/sdk (TypeScript)
TypeScript SDK for the Arca platform.
Build
From repo root:
pnpm run sdk:buildOr directly:
cd sdk/typescript
pnpm run buildDev (watch mode)
pnpm run sdk:devClean
pnpm run sdk:cleanRequirements
- Node.js 20+
WebSocket support
The SDK uses WebSocket for real-time operation tracking. Node.js 22+ provides a native global WebSocket; on Node.js 20–21, the SDK automatically falls back to the bundled ws package. No additional setup is needed.
Equity & P&L Charts
Use the chart APIs below. The server is the single source of truth for every point including the open bucket; the SDK never synthesizes a "now" point and never invalidates the cache on a 5%-deviation heuristic. Each point carries an explicit status flag ('sealed' | 'open' | 'carried' | 'incomplete') the renderer is required to honor.
getEquityHistory({ path, from, to, points?, kind?, objectId? })— fetches/objects/aggregate/historyusingtarget/kindand normalizes the current response to the stable SDK shape.getPnlHistory({ path, from, to, points?, anchor?, kind?, objectId? })— fetches/objects/pnl/historyusingtarget/kind; P&L is derived inline by the server from the same snapshot rows. Useanchor: 'equity'to receive flow-adjustedvalueUsd, where deposits/transfers shift the baseline instead of drawing timeline jumps.watchEquityChart({ path, from, to, points?, kind?, objectId?, exchange? })— combinesgetEquityHistorywith live aggregation updates and refetches history after gaps.watchPnlChart({ path, from, to, points?, anchor?, kind?, objectId?, exchange? })— same stream pattern for P&L charts.
Resolution selection is shared with the backend (pickResolution from '@arcaresearch/sdk'); pick a points budget — the server picks the rung. When the chosen rung's retention has been exceeded for the requested window, the response carries resolutionRequested to indicate which rung was promoted to.
Exported types: EquityChartStream, PnlChartStream, EquityHistoryResponse, PnlHistoryResponse, EquityPoint, PnlPoint, EquityChartUpdate, PnlChartUpdate, Resolution.
const chart = await arca.watchEquityChart({
path: '/users/alice/',
from: oneDayAgoIso,
to: nowIso,
points: 500,
});
chart.onUpdate(({ response }) => {
for (const p of response.points) {
// p.status: 'sealed' | 'open' | 'carried' | 'incomplete'
// p.equityUsd: string
}
});