naftiko: 1.0.0-alpha2 info: label: Broker API — Trading description: 'Broker API — Trading. 11 operations. Lead operation: Subscribe to Trade Events (SSE). Self-contained Naftiko capability covering one Alpaca business surface.' tags: - Alpaca - Trading created: '2026-05-19' modified: '2026-05-19' binds: - namespace: env keys: ALPACA_API_KEY: ALPACA_API_KEY capability: consumes: - type: http namespace: broker-trading baseUri: https://broker-api.sandbox.alpaca.markets description: Broker API — Trading business capability. Self-contained, no shared references. resources: - name: v1-events-trades path: /v1/events/trades operations: - name: subscribetotradesse method: GET description: Subscribe to Trade Events (SSE) outputRawFormat: json outputParameters: - name: result type: object value: $. inputParameters: - name: since in: query type: string description: 'Format: YYYY-MM-DD' - name: until in: query type: string description: 'Format: YYYY-MM-DD' - name: since_id in: query type: integer - name: until_id in: query type: integer - name: v1-trading-accounts-account_id-orders path: /v1/trading/accounts/{account_id}/orders operations: - name: getallordersforaccount method: GET description: Retrieves a list of orders for the account, filtered by the supplied query parameters. outputRawFormat: json outputParameters: - name: result type: object value: $. inputParameters: - name: status in: query type: string description: Order status to be queried. open, closed or all. Defaults to open. - name: limit in: query type: integer description: The maximum number of orders in response. Defaults to 50 and max is 500. - name: nested in: query type: boolean description: If true, the result will roll up multi-leg orders under the legs field of primary order. - name: createorderforaccount method: POST description: Create an order for an account. outputRawFormat: json outputParameters: - name: result type: object value: $. inputParameters: - name: body in: body type: object description: Request body (JSON). required: true - name: deleteallordersforaccount method: DELETE description: Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. outputRawFormat: json outputParameters: - name: result type: object value: $. - name: v1-trading-accounts-account_id-orders-order_id path: /v1/trading/accounts/{account_id}/orders/{order_id} operations: - name: getorderforaccount method: GET description: Retrieves a single order for the given order_id. outputRawFormat: json outputParameters: - name: result type: object value: $. - name: replaceorderforaccount method: PATCH description: Replaces a single order with updated parameters outputRawFormat: json outputParameters: - name: result type: object value: $. inputParameters: - name: body in: body type: object description: Request body (JSON). required: true - name: deleteorderforaccount method: DELETE description: Attempts to cancel an open order. outputRawFormat: json outputParameters: - name: result type: object value: $. - name: v1-trading-accounts-account_id-positions path: /v1/trading/accounts/{account_id}/positions operations: - name: getpositionsforaccount method: GET description: List open positions for an account outputRawFormat: json outputParameters: - name: result type: object value: $. - name: closeallpositionsforaccount method: DELETE description: Close All Positions for an Account outputRawFormat: json outputParameters: - name: result type: object value: $. inputParameters: - name: cancel_orders in: query type: boolean description: If true is specified, cancel all open orders before liquidating all positions. - name: v1-trading-accounts-account_id-positions-symbol_or_asset_id path: /v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id} operations: - name: getpositionsforaccountbysymbol method: GET description: Get an Open Position for account by Symbol or AssetId outputRawFormat: json outputParameters: - name: result type: object value: $. - name: closepositionforaccountbysymbol method: DELETE description: Close a Position for an Account outputRawFormat: json outputParameters: - name: result type: object value: $. inputParameters: - name: qty in: query type: string description: Optional the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage - name: percentage in: query type: string description: percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal poin authentication: type: basic username: '{{env.ALPACA_USER}}' password: '{{env.ALPACA_PASS}}' exposes: - type: rest namespace: broker-trading-rest port: 8080 description: REST adapter for Broker API — Trading. One Spectral-compliant resource per consumed operation, prefixed with /v1. resources: - path: /v1/v1/events/trades name: v1-events-trades description: REST surface for v1-events-trades. operations: - method: GET name: subscribetotradesse description: Subscribe to Trade Events (SSE) call: broker-trading.subscribetotradesse with: since: rest.since until: rest.until since_id: rest.since_id until_id: rest.until_id outputParameters: - type: object mapping: $. - path: /v1/v1/trading/accounts/{account-id}/orders name: v1-trading-accounts-account-id-orders description: REST surface for v1-trading-accounts-account_id-orders. operations: - method: GET name: getallordersforaccount description: Retrieves a list of orders for the account, filtered by the supplied query parameters. call: broker-trading.getallordersforaccount with: status: rest.status limit: rest.limit nested: rest.nested outputParameters: - type: object mapping: $. - method: POST name: createorderforaccount description: Create an order for an account. call: broker-trading.createorderforaccount with: body: rest.body outputParameters: - type: object mapping: $. - method: DELETE name: deleteallordersforaccount description: Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. call: broker-trading.deleteallordersforaccount outputParameters: - type: object mapping: $. - path: /v1/v1/trading/accounts/{account-id}/orders/{order-id} name: v1-trading-accounts-account-id-orders-order-id description: REST surface for v1-trading-accounts-account_id-orders-order_id. operations: - method: GET name: getorderforaccount description: Retrieves a single order for the given order_id. call: broker-trading.getorderforaccount outputParameters: - type: object mapping: $. - method: PATCH name: replaceorderforaccount description: Replaces a single order with updated parameters call: broker-trading.replaceorderforaccount with: body: rest.body outputParameters: - type: object mapping: $. - method: DELETE name: deleteorderforaccount description: Attempts to cancel an open order. call: broker-trading.deleteorderforaccount outputParameters: - type: object mapping: $. - path: /v1/v1/trading/accounts/{account-id}/positions name: v1-trading-accounts-account-id-positions description: REST surface for v1-trading-accounts-account_id-positions. operations: - method: GET name: getpositionsforaccount description: List open positions for an account call: broker-trading.getpositionsforaccount outputParameters: - type: object mapping: $. - method: DELETE name: closeallpositionsforaccount description: Close All Positions for an Account call: broker-trading.closeallpositionsforaccount with: cancel_orders: rest.cancel_orders outputParameters: - type: object mapping: $. - path: /v1/v1/trading/accounts/{account-id}/positions/{symbol-or-asset-id} name: v1-trading-accounts-account-id-positions-symbol-or-asset-id description: REST surface for v1-trading-accounts-account_id-positions-symbol_or_asset_id. operations: - method: GET name: getpositionsforaccountbysymbol description: Get an Open Position for account by Symbol or AssetId call: broker-trading.getpositionsforaccountbysymbol outputParameters: - type: object mapping: $. - method: DELETE name: closepositionforaccountbysymbol description: Close a Position for an Account call: broker-trading.closepositionforaccountbysymbol with: qty: rest.qty percentage: rest.percentage outputParameters: - type: object mapping: $. - type: mcp namespace: broker-trading-mcp port: 9090 transport: http description: MCP adapter for Broker API — Trading. One tool per consumed operation, routed inline through this capability's consumes block. tools: - name: subscribe-trade-events-sse description: Subscribe to Trade Events (SSE) hints: readOnly: true destructive: false idempotent: true call: broker-trading.subscribetotradesse with: since: tools.since until: tools.until since_id: tools.since_id until_id: tools.until_id outputParameters: - type: object mapping: $. - name: retrieves-list-orders-account-filtered description: Retrieves a list of orders for the account, filtered by the supplied query parameters. hints: readOnly: true destructive: false idempotent: true call: broker-trading.getallordersforaccount with: status: tools.status limit: tools.limit nested: tools.nested outputParameters: - type: object mapping: $. - name: create-order-account description: Create an order for an account. hints: readOnly: false destructive: false idempotent: false call: broker-trading.createorderforaccount with: body: tools.body outputParameters: - type: object mapping: $. - name: attempts-cancel-all-open-orders description: Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. hints: readOnly: false destructive: true idempotent: true call: broker-trading.deleteallordersforaccount outputParameters: - type: object mapping: $. - name: retrieves-single-order-given-order description: Retrieves a single order for the given order_id. hints: readOnly: true destructive: false idempotent: true call: broker-trading.getorderforaccount outputParameters: - type: object mapping: $. - name: replaces-single-order-updated-parameters description: Replaces a single order with updated parameters hints: readOnly: false destructive: false idempotent: true call: broker-trading.replaceorderforaccount with: body: tools.body outputParameters: - type: object mapping: $. - name: attempts-cancel-open-order description: Attempts to cancel an open order. hints: readOnly: false destructive: true idempotent: true call: broker-trading.deleteorderforaccount outputParameters: - type: object mapping: $. - name: list-open-positions-account description: List open positions for an account hints: readOnly: true destructive: false idempotent: true call: broker-trading.getpositionsforaccount outputParameters: - type: object mapping: $. - name: close-all-positions-account description: Close All Positions for an Account hints: readOnly: false destructive: true idempotent: true call: broker-trading.closeallpositionsforaccount with: cancel_orders: tools.cancel_orders outputParameters: - type: object mapping: $. - name: get-open-position-account-symbol description: Get an Open Position for account by Symbol or AssetId hints: readOnly: true destructive: false idempotent: true call: broker-trading.getpositionsforaccountbysymbol outputParameters: - type: object mapping: $. - name: close-position-account description: Close a Position for an Account hints: readOnly: false destructive: true idempotent: true call: broker-trading.closepositionforaccountbysymbol with: qty: tools.qty percentage: tools.percentage outputParameters: - type: object mapping: $.