Viewing: Portfolio
Portfolio
SAHMK Portfolio provides a structured ledger for transactions, holdings, and performance via dashboard, API, and MCP workflows.
GET/POST /portfolios/
FreeCreate and manage portfolios within your plan limits.
Endpoint
https:/
Parameters
(*) Required
| Parameter | Type | Allowed |
|---|---|---|
| name * | string | portfolio name |
| description | string | optional description |
| workspace | number | optional workspace id |
{
"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/
FreeAppend single or batch transactions to the portfolio ledger (deposit, buy, sell, dividend, fee, withdrawal).
Endpoint
https:/
Parameters
(*) Required
| Parameter | Type | Allowed |
|---|---|---|
| transaction_type | string | depositbuyselldividendfeewithdrawal |
| amount_sar | number | transaction amount in SAR |
| symbol | string | required for buy/sell |
| quantity | number | required for buy/sell |
| unit_price_sar | number | unit price for buy/sell |
| fee_sar | number | optional fee |
| transactions[] | array | batch list of transaction objects (all-or-nothing) |
| batch_idempotency_key | string | 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/
FreeReconcile portfolio holdings to target quantities and average costs with a two-step flow: dry_run preview, then apply.
Endpoint
https:/
Parameters
(*) Required
| Parameter | Type | Allowed |
|---|---|---|
| holdings[] * | array | each item: symbol + quantity + avg_cost_sar |
| scope * | string | fullpartial |
| cash_policy * | string | require_cashauto_fund |
| dry_run | boolean | defaults to true |
| plan_token | string | required when dry_run=false |
| expected_latest_transaction_id | integer | 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_sarandperiod_return_pctfor the requested days window.since_inception_pnl_sarandsince_inception_return_pctfor cumulative portfolio performance.ledger_inconsistentandledger_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.
Last updated on