Viewing: Portfolio

Portfolio

SAHMK Portfolio provides a structured ledger for transactions, holdings, and performance via dashboard, API, and MCP workflows.

GET/POST /portfolios/

Free

Create and manage portfolios within your plan limits.

Endpoint

https://api.sahmk.sa/api/v1/portfolios/

Parameters

(*) Required

ParameterTypeAllowed
name *string

portfolio name

descriptionstring

optional description

workspacenumber

optional workspace id

Example200 OKapplication/json
{
  "id": 42,
  "owner_id": 1198,
  "workspace": null,
  "name": "Core Portfolio",
  "description": "Long-only Tadawul",
  "base_currency": "SAR",
  "metadata": {},
  "created_at": "2026-10-17T14:20:00Z",
  "updated_at": "2026-10-17T14:20:00Z"
}

POST /portfolios/{portfolio_id}/transactions/

Free

Append single or batch transactions to the portfolio ledger (deposit, buy, sell, dividend, fee, withdrawal).

Endpoint

https://api.sahmk.sa/api/v1/portfolios/{portfolio_id}/transactions/

Parameters

(*) Required

ParameterTypeAllowed
transaction_typestring
depositbuyselldividendfeewithdrawal
amount_sarnumber

transaction amount in SAR

symbolstring

required for buy/sell

quantitynumber

required for buy/sell

unit_price_sarnumber

unit price for buy/sell

fee_sarnumber

optional fee

transactions[]array

batch list of transaction objects (all-or-nothing)

batch_idempotency_keystring

idempotency key for the whole batch

Note

The ledger is append-only: no in-place edits for past rows, and only the latest non-reversal transaction can be reversed.

For batch mode, send transactions[] with batch_idempotency_key. The batch is atomic (all succeed or all fail), and mixed single+batch payload shapes are rejected.

POST /portfolios/{portfolio_id}/holdings/set/

Free

Reconcile portfolio holdings to target quantities and average costs with a two-step flow: dry_run preview, then apply.

Endpoint

https://api.sahmk.sa/api/v1/portfolios/{portfolio_id}/holdings/set/

Parameters

(*) Required

ParameterTypeAllowed
holdings[] *array

each item: symbol + quantity + avg_cost_sar

scope *string
fullpartial
cash_policy *string
require_cashauto_fund
dry_runboolean

defaults to true

plan_tokenstring

required when dry_run=false

expected_latest_transaction_idinteger

optional extra stale-check guard

Safe apply flow

Run dry_run first and present blocking_errors and warnings to the user. On confirmation, re-submit with dry_run=false and plan_token.

Reconcile writes are stored as adjustment entries with source=reconcile, and auto_fund may add a funding deposit automatically.

Performance and ledger consistency fields

  • period_pnl_sar and period_return_pct for the requested days window.
  • since_inception_pnl_sar and since_inception_return_pct for cumulative portfolio performance.
  • ledger_inconsistent and ledger_warnings[] to flag ledger anomalies without breaking summary/performance reads.

Data Available by Plan:

  • Free: Up to 1 portfolio, delayed valuation, and performance up to 30 days.
  • Starter: Up to 3 portfolios, delayed valuation, and performance up to 1 year.
  • Pro: Up to 10 portfolios, realtime valuation, and performance up to 3 years.
  • Business: Up to 50 portfolios, realtime valuation, and full available performance window.

Workspace integration

Workspace attachment is optional. It adds an operational layer for monitoring and alerts while the portfolio accounting model remains independent.

Open Portfolios in Dashboard

Last updated on