openapi: 3.0.1
info:
  title: DigitalAssets
  version: 2.10.0
  contact:
    name: Tradevest GmbH
    email: hello@tradevest.ai
    url: https://tradevest.ai
  description: Commands and queries related to trading of digital assets.
servers:
  - url: https://tvda-api.platform-test.tradevest.ai
    description: Test
security:
  - Bearer: []
tags:
  - name: Orders
    description: Orders
  - name: Documents
    description: Documents
  - name: Assets
    description: Assets
paths:
  /products/{customerProductId}/digital/orders:
    get:
      summary: Get Orders
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalAssetsOrders'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      operationId: get-digital-assets-orders
      x-operation-group: crypto-query
      x-required-permissions: rs/digital-assets/read
      tags:
        - Orders
      parameters:
        - schema:
            type: string
          in: query
          name: cursor
          description: String value used for pagination
        - schema:
            type: integer
            default: 20
            minimum: 1
          in: query
          name: limit
          description: Maximum number of items to return
        - schema:
            type: string
          in: query
          name: externalId
          description: External Id in partner's system. This value has to be unique
        - schema:
            type: string
            format: date-time
          in: query
          name: startCreatedOn
          description: Display orders created on or after this date
        - schema:
            type: string
            format: date-time
          in: query
          name: endCreatedOn
          description: Display orders created on or before this date
        - schema:
            type: array
            items:
              $ref: '#/components/schemas/OrderStatusEnum'
          in: query
          name: status
          description: Order statuses
      description: Get orders
    parameters:
      - schema:
          type: string
          format: uuid
        name: customerProductId
        in: path
        required: true
  /digital/orders/{orderId}:
    get:
      summary: Get Order
      tags:
        - Orders
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalAssetsOrder'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      operationId: get-digital-asset-order
      x-operation-group: crypto-query
      x-required-permissions: rs/digital-assets/read
      parameters:
        - schema:
            type: string
            format: uuid
          name: orderId
          in: path
          required: true
          description: Id of order we're looking for
      description: Get order
  /digital/orders/{orderId}/receipt:
    get:
      summary: Get Order Receipt
      tags:
        - Documents
      responses:
        '200':
          description: OK
          content:
            application/pdf:
              schema:
                type: string
                format: binary
              examples: {}
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      operationId: get-digital-asset-order-receipt
      x-operation-group: crypto-query
      x-required-permissions: rs/digital-assets/read
      parameters:
        - schema:
            type: string
            format: uuid
          name: orderId
          in: path
          required: true
          description: Id of order we're looking for
      description: Get order receipt
  /digital/orders/market:
    post:
      summary: Create Market Order
      tags:
        - Orders
      parameters:
        - schema:
            type: string
            format: uuid
          name: Requestor-ID
          in: header
          required: true
          description: Unique requestor identification in UUID format
          x-requestor-id: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOrderResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      operationId: create-order
      x-operation-group: crypto-command
      x-required-permissions: rs/digital-assets/write
      description: Create order.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderData'
            examples:
              Buy 1 BTC:
                value:
                  cryptoSymbol: BTC
                  tradeSide: BUY
                  quantity: 1
                  quantityType: UNIT
                  externalId: unique-external-id
                  cashCustomerProductId: 714e1ee5-c723-476c-b1db-4d29cd7a0e17
              Buy 1000 eur equivalent of BTC:
                value:
                  cryptoSymbol: BTC
                  tradeSide: BUY
                  quantity: 1000
                  quantityType: AMOUNT
                  externalId: unique-external-id
                  cashCustomerProductId: 714e1ee5-c723-476c-b1db-4d29cd7a0e17
  /digital/assets:
    get:
      summary: Get Assets
      tags:
        - Assets
      operationId: get-all-digital-assets
      x-operation-group: crypto-query
      x-required-permissions: rs/digital-assets/read
      description: Get list of all digital assets.
      parameters:
        - schema:
            type: boolean
          in: query
          name: savingsPlansEligible
          description: Filters the list to only show digital assets eligible for savings plans.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalAssetSymbolDefinitions'
components:
  schemas:
    OrderStatusEnum:
      title: OrderStatusEnum
      type: string
      enum:
        - RECEIVED
        - INVALID
        - PENDING
        - CANCELED
        - REJECTED
        - FILLED
        - CORRECTED
        - SETTLED
    QuantityType:
      type: string
      enum:
        - UNIT
        - AMOUNT
    Quantity:
      type: object
      description: ''
      properties:
        unit:
          type: number
          minimum: 0
          exclusiveMinimum: true
          description: The quantity of a digital asset to buy or sell
        amount:
          type: number
          minimum: 0.01
          multipleOf: 0.01
          description: The cash value to buy or sell a digital asset. This amount is withdrawn in case  of a buy, and is deposited in case a sell.
      required:
        - unit
        - amount
    OrderData:
      title: OrderData
      type: object
      required:
        - cryptoSymbol
        - tradeSide
        - quantityType
        - quantity
        - externalId
        - walletCustomerProductId
        - cashCustomerProductId
      properties:
        cryptoSymbol:
          type: string
        tradeSide:
          $ref: '#/components/schemas/TradeSideEnum'
        quantityType:
          $ref: '#/components/schemas/QuantityType'
        quantity:
          type: number
          minimum: 0
          exclusiveMinimum: true
        externalId:
          type: string
          description: External Id in partner's system. This value has to be unique
        walletCustomerProductId:
          type: string
          format: uuid
          description: Wallet customer product used for the order.
        cashCustomerProductId:
          type: string
          format: uuid
          description: Cash customer product used for the order.
    CreateOrderResult:
      title: CreateOrderResult
      type: object
      required:
        - orderId
        - createdOn
      properties:
        orderId:
          type: string
          format: uuid
        createdOn:
          type: string
          format: date-time
          description: The date denoting when the order's record was initially created.
    DigitalAssetsMarketOrderData:
      title: DigitalAssetsMarketOrderData
      type: object
      properties:
        symbol:
          type: string
        assetType:
          $ref: '#/components/schemas/DigitalAssetTypeEnum'
        quantityType:
          $ref: '#/components/schemas/QuantityType'
        quantity:
          type: number
          minimum: 0
          exclusiveMinimum: true
      required:
        - symbol
        - assetType
        - quantityType
        - quantity
    DigitalAssetsOrderExecutionData:
      title: DigitalAssetsOrderExecutionData
      type: object
      properties:
        quantity:
          type: number
          minimum: 0
        executionPrice:
          description: The execution price refers to the actual price at which a trade or transaction was executed.
          type: number
          minimum: 0
        executionAmount:
          description: The execution amount refers to the total cash amount of a trade. It represents for how much money a particular asset is bought or sold at the execution price when the order is fulfilled.
          type: number
          minimum: 0
        feeDescription:
          description: A description of the fee associated with the order execution.
          type: string
        feeAmount:
          description: The fee amount charged for the order execution.
          type: number
          minimum: 0
      required:
        - quantity
        - executionPrice
        - executionAmount
    DigitalAssetsOrder:
      title: DigitalAssetsOrder
      type: object
      properties:
        status:
          $ref: '#/components/schemas/OrderStatusEnum'
        side:
          $ref: '#/components/schemas/TradeSideEnum'
        orderId:
          type: string
          format: uuid
          description: The identifier of the order.
        walletCustomerProductId:
          type: string
          format: uuid
          description: The identifier of the wallet customer product.
        message:
          type: string
        createdOn:
          type: string
          format: date-time
          description: The timestamp when the order was received.
        modifiedOn:
          type: string
          format: date-time
          readOnly: true
          description: The timestamp when the order has changed the status.
        externalId:
          type: string
          description: External Id in partner's system. This value has to be unique
        orderType:
          $ref: '#/components/schemas/OrderTypeEnum'
        marketOrderData:
          $ref: '#/components/schemas/DigitalAssetsMarketOrderData'
        executionData:
          $ref: '#/components/schemas/DigitalAssetsOrderExecutionData'
        cashCustomerProductId:
          type: string
          format: uuid
          description: Cash customer product used for the order.
      required:
        - orderId
        - createdOn
        - modifiedOn
        - status
        - walletCustomerProductId
        - externalId
        - orderType
        - side
        - cashCustomerProductId
    DigitalAssetsOrders:
      title: Orders
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/DigitalAssetsOrder'
        pagination:
          $ref: '#/components/schemas/Pagination'
      required:
        - data
        - pagination
    OrderTypeEnum:
      title: OrderTypeEnum
      type: string
      enum:
        - MARKET
    DigitalAssetSymbolDefinition:
      title: DigitalAssetSymbolDefinition
      type: object
      description: |
        `availableTo` field describes when the symbol support will be terminated. 
        If it points to some date in past it means the symbol is no longer supported.
      properties:
        symbol:
          type: string
        description:
          type: string
        assetType:
          $ref: '#/components/schemas/DigitalAssetTypeEnum'
        decimalPlaces:
          type: integer
          minimum: 0
        availableFrom:
          type: string
          format: date-time
        availableTo:
          type: string
          format: date-time
        assetRiskScore:
          $ref: '#/components/schemas/AssetRiskScoreEnum'
        savingsPlansEligible:
          type: boolean
          description: Indicates whether the digital asset is eligible for savings plans.
      required:
        - symbol
        - description
        - assetType
        - decimalPlaces
        - availableFrom
        - assetRiskScore
        - savingsPlansEligible
    DigitalAssetSymbolDefinitions:
      title: DigitalAssetSymbolDefinitions
      type: object
      properties:
        data:
          type: array
          description: Array of digital asset symbol definitions.
          items:
            $ref: '#/components/schemas/DigitalAssetSymbolDefinition'
    AssetRiskScoreEnum:
      title: AssetRiskScoreEnum
      description: The risk classification of the asset
      enum:
        - '0'
        - '3'
    TradeSideEnum:
      title: TradeSideEnum
      type: string
      enum:
        - BUY
        - SELL
    DigitalAssetTypeEnum:
      title: DigitalAssetTypeEnum
      type: string
      description: Digital Asset Type
      enum:
        - CRYPTOCURRENCY
        - SECURITYTOKEN
        - eWP
    Pagination:
      title: Pagination
      type: object
      properties:
        cursor:
          type: string
          description: String value used for pagination, which should be set in next page request.
        limit:
          type: integer
          description: Maximum number of returned items
      required:
        - cursor
        - limit
    ErrorDetailsExplanation:
      title: ErrorDetailsExplanation
      type: object
      properties:
        code:
          type: string
          maxLength: 255
        parameter:
          type: string
        message:
          type: string
      required:
        - code
        - message
    ErrorDetails:
      title: ErrorDetails
      type: object
      properties:
        field:
          type: string
          maxLength: 255
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetailsExplanation'
      required:
        - field
    ErrorMessage:
      title: ErrorMessage
      type: object
      properties:
        message:
          type: string
        responseType:
          type: string
        validationString:
          minLength: 1
          type: string
        requestId:
          type: string
        errorCode:
          type: string
          maxLength: 255
        errorDetails:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetails'
      required:
        - message
        - responseType
        - requestId
  securitySchemes:
    Bearer:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oauth2/token
          refreshUrl: ''
          scopes: {}
x-tagGroups:
  - name: Orders
    tags:
      - Orders
  - name: Assets
    tags:
      - Assets
  - name: Order Documents
    tags:
      - Documents
