Skip to content

Record portfolio event

Records a trade, cash movement or note in a portfolio.

Needs the portfolio:write scope.

Call

  • Tool: record_portfolio_event
  • Scope: portfolio:write
  • Writes, and may change or remove what is there.
  • Acts on a store.

Arguments

Name Type Required Description
store string No The store to act on.
product object Yes
idempotency_key string or null No The recorder’s own key for the event: a repeat answers the event it recorded.
type "file" or "buy" or "sell" or "deposit" or "withdraw" or "dividend" or "comment" or "watch" or "unwatch" Yes
price integer or null No Per share, in minor units. Left empty on a buy, a sell, a dividend, a watch or a comment naming a symbol, it takes the symbol’s latest price when a fresh quote has one, which the answer carries.
symbol string or string or null No
symbol_type "stock" or "crypto" or "stock" or "crypto" or null No
file_ids array of string No For a file event, the assets its holding delivers.
currency string or null No What the amounts are in, so a stale send is refused: the portfolio’s own; a comment’s price may name another.
note string or null or string No
notify boolean or null No For a trade, notify every customer with access to the portfolio, in their notifications and by browser push; left out, it notifies nobody.
shares integer No
amount null or integer No
{
  "type": "object",
  "properties": {
    "store": {
      "type": "string",
      "description": "The store to act on."
    },
    "product": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "slug": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          "required": [
            "slug"
          ],
          "additionalProperties": false
        }
      ]
    },
    "idempotency_key": {
      "description": "The recorder's own key for the event: a repeat answers the event it recorded.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        {
          "type": "null"
        }
      ]
    },
    "type": {
      "anyOf": [
        {
          "type": "string",
          "const": "file"
        },
        {
          "type": "string",
          "const": "buy"
        },
        {
          "type": "string",
          "const": "sell"
        },
        {
          "type": "string",
          "const": "deposit"
        },
        {
          "type": "string",
          "const": "withdraw"
        },
        {
          "type": "string",
          "const": "dividend"
        },
        {
          "type": "string",
          "const": "comment"
        },
        {
          "type": "string",
          "const": "watch"
        },
        {
          "type": "string",
          "const": "unwatch"
        }
      ]
    },
    "price": {
      "description": "Per share, in minor units. Left empty on a buy, a sell, a dividend, a watch or a comment naming a symbol, it takes the symbol's latest price when a fresh quote has one, which the answer carries.",
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "symbol": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            {
              "type": "null"
            }
          ]
        }
      ]
    },
    "symbol_type": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "stock",
            "crypto"
          ]
        },
        {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "stock",
                "crypto"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      ]
    },
    "file_ids": {
      "description": "For a file event, the assets its holding delivers.",
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64
      },
      "minItems": 1,
      "maxItems": 100
    },
    "currency": {
      "description": "What the amounts are in, so a stale send is refused: the portfolio's own; a comment's price may name another.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 3,
          "maxLength": 3
        },
        {
          "type": "null"
        }
      ]
    },
    "note": {
      "anyOf": [
        {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 2000
            },
            {
              "type": "null"
            }
          ]
        },
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      ]
    },
    "notify": {
      "description": "For a trade, notify every customer with access to the portfolio, in their notifications and by browser push; left out, it notifies nobody.",
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "shares": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "amount": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      ]
    }
  },
  "required": [
    "product",
    "type"
  ],
  "additionalProperties": false
}

Answer

Name Type Required Description
id string Yes
portfolio_id string Yes
symbol string or null Yes
type string Yes
shares number or null Yes
price number or null Yes
amount number or null Yes
note string or null Yes
effective_date string or null Yes
symbol_type string or null Yes
currency string Yes
exponent number or null Yes
price_currency string Yes
price_exponent number or null Yes
allocation number or null Yes
allocation_change number or null Yes
ratio object or null Yes
occurred_at string or null Yes
recorded_at string or null Yes
metadata object Yes

The answer’s full shape is on its API reference page.

Errors

A refused call is a tool error. Its structuredContent holds a code and its context, except for client-fault. This tool may answer:

  • invalid: an argument is malformed; context.path names it.
  • invalid at ["store"]: store is missing while the connection reaches more than one store, or names a store it doesn’t reach.
  • not_found: nothing matches a reference given.
  • conflict: the call clashes with the current state; context names the field and, where it helps, its current value, and for a from, live, expect or version that no longer matches, the argument (path) and what it takes (reason).
  • not_permitted: this connection may not make this call. When context.reason is limit, too many calls: retry_after says when to try again.
  • internal or unavailable: the call failed inside Sherpo, and the write may have landed. If you sent an idempotency_key, send it again with the same arguments: the event already recorded comes back. The key belongs to the portfolio: on the same portfolio with other arguments it is a conflict at event, and current names the event recorded. Without one, read the state back before trying again.
  • client-fault: the server failed around the call. core_answer ok means the write landed, so don’t send it again. When reached_core is false, nothing happened and the call may be made again. Otherwise, if you sent an idempotency_key, send it again with the same arguments: the event already recorded comes back. The key belongs to the portfolio: on the same portfolio with other arguments it is a conflict at event, and current names the event recorded. Without one, read the state back before trying again.
  • HTTP 403 with insufficient_scope: the connection lacks the scope this tool needs.
  • HTTP 401 with invalid_token: the access token expired or the connection ended. Refresh the token, and connect again if the refresh fails or the new token is refused too.

Any other code may come back too, such as a conflict when the state changed under the call. When the answer was already streaming, a 401 or 403 comes back as a tool error with only its text. See Errors for every code and its context.

Type to search…

↑↓ navigate↵ selectEsc close