################################################################################
##
## tradias GmbH API Dictionary of Schemas and Fields
##

openapi: 3.1.0
info:
  title: tradias GmbH API Dictionary
  description: Dictionary of Schemas and Fields for tradias GmbH API
  version: v2.2.4

components:
  schemas:
    instrument_category_type:
      title: Instrument Category
      description:
        The category of the instrument
      type: string
      enum:
        - spot
        - mini_future
      example: spot

    position_type:
      title: Position Type
      description: Indicates whether the derivative position is LONG or SHORT
      type: string
      enum:
        - LONG
        - SHORT

    payout_type_type:
      title: Payout Type
      description: Indicates whether the derivative payout type is DELIVERY or CASH
      type: string
      enum:
        - DELIVERY
        - CASH

    residual_value_method_type:
      title: Residual Value Calculation Method Type
      description: Indicates the method used to calculate the residual value of a derivative
      type: string
      enum:
        - ONE_SHOT
        - TWAP
        - NOTIONAL

    instrument_type:
      type: string
      description: >-
        Identifier for an instrument.<br>
        It consists of the asset codes of the two legs and an optional asset tenor. If the tenor is
        not given the default tenor "SP" (spot) is used.<br>
        Format: (base-leg) "-" (quote_leg) ["/" (tenor) ]
      pattern: "^([A-Z][A-Z0-9]{0,4})-([A-Z][A-Z0-9]{0,4})(/(SP))?$"
      maxLength: 15
      example: "BTC-EUR/SP"

    asset_code_type:
      type: string
      description: Identifier of a leg of an instrument
      pattern: "^([A-Z0-9]{1,10})$"
      minLength: 1
      maxLength: 10
      example: "BTC"

    asset_tenor_type:
      type: string
      description:
        Identifier of a tenor.<br>
        The following tenors are supported
          * SP = Spot<br>
        Note - Currently not used
      pattern: "^(SP)$"
      maxLength: 2
      example: "SP"

    asset_name_type:
      type: string
      description: Name of a leg of an instrument
      pattern: "^[A-Za-z0-9]{1,15}$"
      maxLength: 15
      example: "Bitcoin"

    asset_precision_type:
      type: integer
      minimum: 0
      maximum: 50
      description:
        The number of digits after the decimal point which are allowed for a quantity.
      example: 8

    asset_type:
      title: Asset
      type: object
      required:
        - name
        - code
        - precision
      additionalProperties: false
      properties:
        name:
          $ref: "dict.yml#/components/schemas/asset_name_type"
        code:
          $ref: "dict.yml#/components/schemas/asset_code_type"
        precision:
          $ref: "dict.yml#/components/schemas/asset_precision_type"
      description:
        An asset describes a crypto or fiat asset. It consists of a name (readable name of the
        asset), a code representing the asset and of a precision, which defines the number of digits
        after the decimal point which can be used for quantities in this asset.
      example:
        name: "Bitcoin"
        code: "BTC"
        precision: 8

    address_type:
        title: Fiat Account Number or Crypto Wallet Key
        maxLength: 500
        type: string
        description:
          An address to transfer either Fiat money or crypto assets to or from. It is either (for
          Fiat money) an account number (IBAN) or (for crypto assets) an wallet key. In the case
          of tradias as recipient or sender the value "TRADIAS" will be used.

    checked_address_type:
      title: Checked Fiat Account Number or Crypto Wallet Key
      type: object
      required:
        - address
        - valid
      additionalProperties: false
      properties:
        address:
          $ref: "dict.yml#/components/schemas/address_type"
        valid:
          title: Address Valid
          type: boolean
          description:
            This field indicates if the address has been checked and is valid.

    quantity_type:
      title: Quantity
      type: string
      pattern: "^[0-9]{0,19}(\\.[0-9]{1,50})?$"
      maxLength: 70
      description:
        The quantity of a leg.
      example: "1.25867895"

    price_type:
      title: Price
      type: string
      pattern: "^[0-9]{0,19}(\\.[0-9]{1,50})?$"
      maxLength: 70
      description:
        The price of a quantity of 1.0 of leg_1 expressed in a leg_2 quantity.<br><br>
        For example the instrument "BTC-EUR" the leg_1 is "BTC" and the leg_2 is "EUR". A price of
        "23768.63953056" means that 23,768.63953956 EUR is the price for one BTC.
      example: "23768.63953056"

    fiat_amount_type:
      title: Amount of a Fiat Currency
      type: number
      minimum: 0
      maximum: 999999999999999
      multipleOf: 0.001
      description:
        A positive Fiat Currency amount with 15 digits number and 3 digits
        decimal fraction. It does not allow negative values.
      example: 47118.15

    fraction_type:
      title: Fraction Type
      type: number
      minimum: 0
      maximum: 999
      multipleOf: 0.0001
      description:
        The fraction expresses a relation of two numeric values. It is the actual
        value divided by the maximal value.
      example: 0.7115

    precision_type:
      title: Precision Type
      type: number
      minimum: 0
      maximum: 99
      multipleOf: 1
      description:
        The precision type defines the number of digits a quantity or an amount can have.
      example: 4

    timestamp_type:
      title: Timestamp
      type: string
      pattern: "^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{6})Z$"
      description:
        Timestamp in UTC Timezone using the following format "%Y-%m-%dT%H:%M:%S.%fZ"
      example: "1970-01-01T00:00:00.000000Z"

    side_type:
      title: Side (Buy / Sell)
      description: |
        The side of the order, seen from the perspective of the API user.
          * **BUY** The user sending the order is buying assets
          * **SELL** The user sending the order is selling his assets
      type: string
      enum:
        - BUY
        - SELL
      example: BUY

    unique_req_type:
      title: Unique Request Id
      description:
        The unique request id is generated by the API user. It is used
        to detect that a request has already processed. If the unique
        request id has already been used then the request will not
        be executed. Instead an error will be (DuplicateReq) reported.
      type: string
      pattern: "^[A-Za-z0-9#_-]{1,100}$"
      minLength: 1
      maxLength: 100
      example: "7ac33648-ae4b-11ed-b2f9-81a12bb57b04"

    external_ref_type:
      title: External Reference or Id
      description:
        This field is used by the API user to pass an reference or id to the
        tradias system which is used in the tradias system to to act as an
        reference or id to the transaction in the API users system.
      type: string
      pattern: "^[A-Za-z0-9#_-]{1,100}$"
      minLength: 1
      maxLength: 100
      example: "c8d16891-b669-11ed-bc43-f1002b6e6125"

    internal_ref_type:
      title: Internal Reference or Id
      description:
        This field is used by tradias to pass an reference or id to the
        API User. It is used in the tradias system to to act as an
        reference or id to an object (Order, Trade, ...).
      type: string
      pattern: "^[A-Za-z0-9#_-]{1,36}$"
      minLength: 1
      maxLength: 36
      example: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"

    user_data_type:
      title: User Data Array
      description:
        This object is an array used by the API user to pass data to the tradias
        system which will be returned back to the API user together with the
        responses related to the transaction. It can be used by the API user to
        identify an transaction in a later response.
      type: array
      minItems: 1
      maxItems: 100
      items:
        type: object
        required:
          - tag
          - value
        additionalProperties: false
        properties:
          tag:
            type: string
            pattern: "^[A-Za-z0-9-_]{1,16}$"
            minLength: 1
            maxLength: 16
          value:
            type: string
            pattern: "^.{1,100}$"
            minLength: 1
            maxLength: 100
      example:
        - tag: "Correlation-Id"
          value: "7ac33648-ae4b-11ed-b2f9-81a12bb57b04"
        - tag: "TX-Id"
          value: "18955839"

    req_header_type:
      title: Request Header
      type: object
      description:
        This request header is part of any request creating or modifying an
        object (order, bulk-order, settlement, ...). It consists of two parts,
        an request id which will be checked on the tradias side for uniqueness,
        and an array of user data (tag value). Both parts are option as the
        complete request header is.<br><br>
        The request id can be used by the API user to allow, that if a request
        does not answer properly, to sent the request again. If the first one
        has been processed, then the second one will be rejected with a 409
        error and the API user knows that the first request has been processed.
        If the first request did not make it the second one will be processed
        normally.<br><br>
        The second part is an array of values tagged by a short tag. This data
        provided by the API user will be returned with the response of the
        request and if a possible will be added to the object the request
        relates to and later returned with all responses relating to the object.
      additionalProperties: false
      properties:
        req_id:
          $ref: "dict.yml#/components/schemas/unique_req_type"
        user_data:
          $ref: "dict.yml#/components/schemas/user_data_type"
      example:
        req_id: "ca57eead-b699-11ed-b3ff-cc17d418c9e0"
        user_data:
          - tag: "Correlation-Id"
            value: "c8d16891-b669-11ed-bc43-f1002b6e6125"
          - tag: "TX-Id"
            value: "18955457"

    sequence_type:
      title: Sequence Number
      description: Sequence number of an order, trade or any other event.
        A sequence number is assigned to the object (e.g. order) when it is received. All sequence
        number are unique and increasing. There may be gaps in the sequence numbers assigned!
        The sequence number can ba used sort objects in the way they have been received/happened.
        If the maximum is reached the sequence numbers continue with 0.
      type: integer
      minimum: 0
      maximum: 999999999999999
      example: 47110815

    transaction_ref_type:
      title: Transaction Reference or Id
      description:
        This field is used by the API user to pass an reference or id of a Transaction. It is either
        the reference field of an FIAT money transaction or in case of a crypto asset transfer the
        hash or id of the blockchain transaction.
      type: string
      pattern: "^[A-Za-z0-9#_-]{1,100}$"
      minLength: 1
      maxLength: 100
      example: "a38ca981-b669-11ed-bc43-cb132b8d1265"

    transaction_ref_type_type:
      title: Transaction Reference Type
      description:
        Type of the reference of a transaction
      type: string
      enum:
        - on_chain_transaction_id
        - sepa_reference
        - sepa_description
        - sepa_end_to_end_id

    channel_type:
      title: Channel
      description: Name of the websocket channel
      type: string
      enum:
        - orders
        - prices
        - trades
        - rfqs

    channel_status_type:
      title: Channel Status
      description: Status of the websocket channel
      type: string
      enum:
        - ACTIVE
        - CLOSED

    heartbeat_interval_type:
      title: Heartbeat Interval (Seconds)
      description:
        This optional field defines if the tradias Server sends heartbeat messages to the
        channel or not. The value specifies the interval of the heartbeat messages in
        seconds. The maximum is 600 seconds (10 minutes). A value of 0 switches the
        heartbeat message generation off. Zero is the default which means by default
        there are no heartbeat messages.
      type: integer
      minimum: 0
      maximum: 600
      default: 0

    subscription_id_type:
        title: Subscription Id
        description:
          This field is used by the API user as a unique id of a subscription of a channel.
        type: string
        pattern: "^[A-Za-z0-9#_-]{1,100}$"
        minLength: 1
        maxLength: 100
        example: "a38ca981-b669-11ed-bc43-cb132b8d1265"

    header_type:
      title: Message Header
      description:
        Header used for all websocket messages
      type: object
      required:
        - channel
        - timestamp
      additionalProperties: false
      properties:
        channel:
          $ref: "dict.yml#/components/schemas/channel_type"
        timestamp:
          $ref: "dict.yml#/components/schemas/timestamp_type"

    derivative_status_type:
      title: Derivative Lifecycle Status
      type: string
      enum:
        - DRAFT
        - ACTIVE
        - SOLDOUT
        - KNOCKOUT
        - BUYBACK
        - EXPIRED
        - ERROR
      description: |
        The status of a price subscription
          * **DRAFT**\: New instrument not yet active
          * **ACTIVE**\: The instrument is active and tradable
          * **SOLDOUT**\: The instrument is sold out and can only bought back
          * **KNOCKOUT**\: The instrument has been knocked out
          * **BUYBACK**\: The instrument is in buyback mode
          * **EXPIRED**\: The instrument is expired
          * **ERROR**\: Error on the instrument

    price_status_type:
      title: Price Status
      type: string
      enum:
        - ACTUAL
        - PARTIAL
        - SOLDOUT
        - KNOCKOUT
        - BUYBACK
        - UNAVAILABLE
        - ERROR
      description: |
        The status of a price subscription
          * **ACTUAL**\: There is an actual price
          * **PARTIAL**\: There is a reduced set of price levels
          * **SOLDOUT**\: The price is sold out
          * **KNOCKOUT**\: The price has been knocked out
          * **BUYBACK**\: The price is in buyback mode
          * **UNAVAILABLE**\: There is actually no price
          * **ERROR**\: No price available. The subscription failed

    order_type_type:
      title: Order Type
      type: string
      enum:
        - MARKET
        - LIMIT
        - BULK_MARKET
      default: MARKET
      description: |
        There are different order types. Currently only the following order types are supported
          * **MARKET**\: This is a *fill or kill* (FOK) market order (no limit). *Fill or kill* means
            that the order is executed *all or nothing* (AON) and *immediate or cancel* (IOC).
          * **LIMIT**\: This is a *fill or kill* (FOK) limit order. *Fill or kill* means
            that the order is executed *all or nothing* (AON) and *immediate or cancel* (IOC).
          * **BULK_MARKET**\: An order which is part of a bulk order. It is executed immediately
            after the bulk order has been confirmed.
      example: MARKET

    time_in_force_type:
      title: Time in Force Type
      type: string
      enum:
        - IOC
        - FOK
      description: |
        An order will stay in force for a defined time. Currently only the following types
        are supported:
          * **IOC**\: This is a *Immediate or Cancel* (IOC) order. The order is is either executed
            immediately completely or not at all and instead canceled.
          * **FOK**\: This is a *Fill or Kill* (FOK) order. The order is is either executed
            immediately completely or not at all and instead canceled.
      example: FOK

    bulk_order_status_type:
      title: Bulk Order Status
      type: string
      enum:
        - RECEIVED
        - received
        - REJECTED
        - rejected
        - CONFIRMED
        - confirmed
        - DONE
        - done
      description:
        The status of a new bulk order is "RECEIVED". BULK_MARKET orders will be executed
        immediately an becomes then either "REJECTED" if it could not be executed or "CONFIRMED"
        "DONE" if it got executed.
      example: RECEIVED

    order_status_type:
      title: Order Status
      type: string
      enum:
        - UNSPECIFIED
        - RECEIVED
        - CONFIRMED
        - DUPLICATE
        - REJECTED
        - OPEN
        - UPDATED
        - CANCELLED
        - EXPIRED
        - DONE
      description:
        Orders have a live cycle. The state an order is in that live cycle expressed by its state.
        The above values are states an order can have in its live cycle. Initially the order is
        RECEIVED. DUPLICATE, REJECTED, EXPIRED, CANCELLED and DONE are terminal states which will
        not change any more. UNSPECIFIED means the state is unknown.
      example: DONE

    rejection_reason_type:
      title: Order Rejection Reason
      type: string
      enum:
        - UNSPECIFIED
        - INVALID_REQUEST
        - RATE_LIMIT_EXCEEDED
      description:
        When an order can not be executed this field describes why this happened.
        UNSPECIFIED means the state is unknown.
      example: INVALID_REQUEST

    rfq_type_type:
      title: RFQ Type
      type: string
      enum:
        - SINGLE
        - STREAMING
      description: |
        There are different quote request (RFQ) types. The following quote request types are
        supported:
          * **SINGLE**\: This is a quote request which sends only one quote out. If the quote
            expires or gets executed the quote request ends.
          * **STREAMING**\: This is a quote requests which sends a continuous stream of quotes
            until the quote request gets canceled.
      example: STREAMING

    trade_leg_status_type:
      title: Trade Leg Status
      type: string
      enum:
        - UNSPECIFIED
        - PENDING
        - SETTLED

    order_amount_type:
      title: Order Amount
      type: object
      minProperties: 1
      maxProperties: 1
      additionalProperties: false
      properties:
        leg_1_amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        leg_2_amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
      description:
        You can specify the amount of an instrument to buy or sell either in the leg_1 or in the
        leg_2 quantity.<br><br>
        If you for example want to buy BTC-EUR you can either define the amount to buy in BTC by
        specifying the leg_1_amount, or you can specify the amount to spend in EUR by defining the
        leg_2_amount.<br><br>
        Only one of the two legs can be used for a single order!
      example:
        leg_1_amount: "1.25"

    market_order_type:
      title: Market Order Data
      type: object
      required:
        - order_ref
        - instrument
        - side
        - amount
      additionalProperties: false
      properties:
        order_ref:
          $ref: "dict.yml#/components/schemas/external_ref_type"
        instrument:
          $ref: "dict.yml#/components/schemas/instrument_type"
        side:
          $ref: "dict.yml#/components/schemas/side_type"
        amount:
          $ref: "dict.yml#/components/schemas/order_amount_type"
        counter_leg_precision:
          $ref: "dict.yml#/components/schemas/precision_type"
        req_header:
          $ref: "dict.yml#/components/schemas/req_header_type"
      description:
        This schema represents all information needed for an MARKET order
      example:
        order_ref: "18955839"
        instrument: "BTC-EUR"
        side: "BUY"
        amount:
          leg_1_amount: "2.5"
        counter_leg_precision: 4
        req_header:
          user_data:
            - tag: "Correlation-Id"
              value: "7ac33648-ae4b-11ed-b2f9-81a12bb57b04"
            - tag: "TX-Id"
              value: "18955839"

    order_data_type:
      title: Order Data
      type: object
      required:
        - instrument
        - order_type
        - side
        - amount
        - order_status
      additionalProperties: false
      properties:
        instrument:
          $ref: "dict.yml#/components/schemas/instrument_type"
        order_type:
          $ref: "dict.yml#/components/schemas/order_type_type"
        side:
          $ref: "dict.yml#/components/schemas/side_type"
        amount:
          $ref: "dict.yml#/components/schemas/order_amount_type"
        order_status:
          $ref: "dict.yml#/components/schemas/order_status_type"
      description:
        This schema represents all information of an order
      example:
        instrument: "BTC-EUR"
        order_type: MARKET
        side: "BUY"
        amount:
          leg_1_amount: "2.5"
        order_status: DONE

    trade_order_data_type:
      title: Order Data
      type: object
      required:
        - instrument
        - order_type
        - side
        - amount
        - arrived_at
        - order_status
      additionalProperties: false
      properties:
        instrument:
          $ref: "dict.yml#/components/schemas/instrument_type"
        order_type:
          $ref: "dict.yml#/components/schemas/order_type_type"
        side:
          $ref: "dict.yml#/components/schemas/side_type"
        amount:
          $ref: "dict.yml#/components/schemas/order_amount_type"
        arrived_at:
          $ref: "dict.yml#/components/schemas/timestamp_type"
        order_status:
          $ref: "dict.yml#/components/schemas/order_status_type"
      description:
        This schema represents all information of an order
      example:
        instrument: "BTC-EUR"
        order_type: MARKET
        side: "BUY"
        amount:
          leg_1_amount: "2.5"
        arrived_at: "1970-01-01T00:00:00.000000Z"
        order_status: DONE

    bulk_execution_type:
      title: Bulk Order Execution
      type: object
      required:
        - order_id
        - instrument
        - order_type
        - side
        - amount
        - client_order_id
        - client_order_id_1
        - client_order_id_2
        - event
        - trade_id
        - confirmed_price
        - total_amount
        - executed_at
        - unique_client_order_id
      additionalProperties: false
      properties:
        order_id:
          $ref: "dict.yml#/components/schemas/internal_ref_type"
        instrument:
          $ref: "dict.yml#/components/schemas/instrument_type"
        order_type:
          $ref: "dict.yml#/components/schemas/order_type_type"
        side:
          $ref: "dict.yml#/components/schemas/side_type"
        amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        client_order_id:
          $ref: "dict.yml#/components/schemas/external_ref_type"
        client_order_id_1:
          $ref: "dict.yml#/components/schemas/external_ref_type"
        client_order_id_2:
          $ref: "dict.yml#/components/schemas/external_ref_type"
        event:
          type: string
          enum:
            - orders
        trade_id:
          $ref: "dict.yml#/components/schemas/internal_ref_type"
        confirmed_price:
          $ref: "dict.yml#/components/schemas/price_type"
        total_amount:
          description:
            The amount of the second leg of the trade.
            Given in units of currency the leg 2.
          $ref: "dict.yml#/components/schemas/quantity_type"
        executed_at:
          $ref: "dict.yml#/components/schemas/timestamp_type"
        unique_client_order_id:
          $ref: "dict.yml#/components/schemas/external_ref_type"

    execution_type:
      title: Order Execution
      type: object
      required:
        - trade_id
        - leg_1_executed_amount
        - leg_2_executed_amount
        - execution_price
        - executed_at
        - leg_1_status
        - leg_2_status
      additionalProperties: false
      properties:
        trade_id:
          $ref: "dict.yml#/components/schemas/internal_ref_type"
        leg_1_executed_amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        leg_2_executed_amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        execution_price:
          $ref: "dict.yml#/components/schemas/price_type"
        executed_at:
          $ref: "dict.yml#/components/schemas/timestamp_type"
        leg_1_status:
          $ref: "dict.yml#/components/schemas/trade_leg_status_type"
        leg_2_status:
          $ref: "dict.yml#/components/schemas/trade_leg_status_type"

    trade_type:
      title: Trade Data
      type: object
      required:
        - leg_1_executed_amount
        - leg_2_executed_amount
        - execution_price
        - executed_at
      additionalProperties: false
      properties:
        leg_1_executed_amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        leg_2_executed_amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        execution_price:
          $ref: "dict.yml#/components/schemas/price_type"
        executed_at:
          $ref: "dict.yml#/components/schemas/timestamp_type"
        leg_1_status:
          $ref: "dict.yml#/components/schemas/trade_leg_status_type"
        leg_2_status:
          $ref: "dict.yml#/components/schemas/trade_leg_status_type"

    settlement_status_type:
      title: Settlement Status
      type: string
      enum:
        - RECEIVED
        - received
        - REJECTED
        - rejected
        - CONFIRMED
        - confirmed
        - PARTIALLY
        - partially
        - SETTLED
        - settled
      description:
        Status of a settlement. In case the trades in the settlement request are ok and result in
        the correct amounts, the value will be CONFIRMED. The value switches to "PARTIALLY", once
        the transaction has been made and to SETTLED if all transactions have been successfully
        executed. In case if there is a problem with the settlement its status will be REJECTED.
        When the settlement request has just been sent the status will be RECEIVED.<br><br>
        This status is also been used to reflect the status of each amount (transaction) of a
        settlement. In this case the state PARTIALLY will not been used.

    direction_type:
      title: Direction (SEND / RECEIVE)
      description:
        The direction of a transaction, seen from the perspective of the API user.
          * **SEND** The user sending money or assets to tradias
          * **RECEIVE** The user receiving money or assets from tradias
      type: string
      enum:
        - SEND
        - RECEIVE
      example: t

    transaction_type:
      title: Transaction
      required:
        - tx_id
        - reference_type
        - reference
        - amount
      type: object
      additionalProperties: false
      properties:
        tx_id:
          summary: Transaction Id
          description: A tradias id of the transaction
          $ref: "dict.yml#/components/schemas/internal_ref_type"
        reference_type:
          $ref: "dict.yml#/components/schemas/transaction_ref_type_type"
        reference:
          summary: Reference
          $ref: "dict.yml#/components/schemas/transaction_ref_type"
        amount:
          summary: Amount transferred
          $ref: "dict.yml#/components/schemas/quantity_type"
      example:
        tx_id: "265a2482-bf2f-11ed-8f96-eac8fe84d40c"
        reference_type: ON_CHAIN_TX_ID
        reference: "1b82e950aebfd74ab6508538f2138cf4ab0b904a9a3c93ad2df209e5f78d1ea9"
        amount: "1.76"

    settlement_amount_type:
      title: Settlement Amount
      type: object
      required:
        - settlement_request_amount_id
        - currency
        - from_address
        - to_address
        - amount
        - expected_amount
        - status
      additionalProperties: false
      properties:
          settlement_request_amount_id:
            summary: Settlement Request Amount Id
            description:
              Server-side generated unique identifier of the settlement request
              amount
            $ref: "dict.yml#/components/schemas/internal_ref_type"
          currency:
            $ref: "dict.yml#/components/schemas/asset_code_type"
            description: The currency to which the request amount applies
          from_address:
            summary: From Address
            $ref: "dict.yml#/components/schemas/address_type"
          to_address:
            summary: To Address
            $ref: "dict.yml#/components/schemas/address_type"
          amount:
            summary: Amount to be transferred
            $ref: "dict.yml#/components/schemas/quantity_type"
          expected_amount:
            summary: Expected Amount
            description:
              The amount expected by tradias as a result of the trades passed in
              the corresponding trade list. In order for settlement to go forward,
              this expected_amount has to agree with the amount field.
            $ref: "dict.yml#/components/schemas/quantity_type"
          status:
            summary: Status
            description:
              Settlement status of the respective settlement request amount.
              In case amount of the settlement request matches with the amount
              tradias has calculated the value will be "CONFIRMED" and the value
              switches to "SETTLED", once the transaction has been done.
              In case tradias receives the amount, the status change will happen
              upon receipt of the amount, in the case tradias sends the amount,
              the status change happens upon the sending of the amount.
            $ref: "dict.yml#/components/schemas/settlement_status_type"
          transactions:
            title: Transactions
            description:
              A list of transactions that have been made and associated with this
              settlement request amount
            type: array
            items:
              $ref: "dict.yml#/components/schemas/transaction_type"
      example:
        settlement_request_amount_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
        currency: "BTC"
        from_address: "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"
        to_address: "TRADIAS"
        amount: "1.23"
        expected_amount: "1.23"
        status: "PARTIALLY"
        transactions:
          - tx_id: "265a2482-bf2f-11ed-8f96-eac8fe84d40c"
            reference_type: ON_CHAIN_TX_ID
            reference: "1b82e950aebfd74ab6508538f2138cf4ab0b904a9a3c93ad2df209e5f78d1ea9"
            amount: "1.00"

    transaction_item_type:
      type: object
      required:
        - transaction_id
        - amount
        - reference
        - reference_type
        - timestamp
        - from_address
        - to_address
        - currency
        - settlement_requests
      properties:
        transaction_id:
          $ref: "dict.yml#/components/schemas/internal_ref_type"
        amount:
          $ref: "dict.yml#/components/schemas/quantity_type"
        reference:
          $ref: "dict.yml#/components/schemas/transaction_ref_type"
        reference_type:
          $ref: "dict.yml#/components/schemas/transaction_ref_type_type"
        timestamp:
          $ref: "dict.yml#/components/schemas/timestamp_type"
        from_address:
          $ref: "dict.yml#/components/schemas/address_type"
        to_address:
          $ref: "dict.yml#/components/schemas/address_type"
        currency:
          $ref: "dict.yml#/components/schemas/asset_code_type"
        settlement_requests:
          type: array
          minItems: 0
          maxItems: 99
          uniqueItems: true
          items:
            $ref: 'dict.yml#/components/schemas/settlement_request_reference_type'

    settlement_request_reference_type:
      type: object
      required:
        - settlement_request_id
        - client_settlement_request_id
        - settlement_request_amounts
      properties:
        settlement_request_id:
          $ref: "dict.yml#/components/schemas/internal_ref_type"
        client_settlement_request_id:
          $ref: "dict.yml#/components/schemas/external_ref_type"
        settlement_request_amounts:
          type: array
          minItems: 0
          maxItems: 99
          uniqueItems: true
          items:
            title: List of Transactions
            type: object
            required:
              - settlement_request_amount_id
              - amount
            additionalProperties: false
            properties:
              settlement_request_amount_id:
                $ref: "dict.yml#/components/schemas/internal_ref_type"
              amount:
                $ref: "dict.yml#/components/schemas/quantity_type"

    pagination_type:
      type: object
      required:
        - skip
        - limit
        - total_count
      properties:
        skip:
          description: The number used in the skip parameter (the starting index)
          $ref: 'dict.yml#/components/schemas/pagination_skip_type'
        limit:
          description: The number used in the limit parameter (the ending index)
          $ref: 'dict.yml#/components/schemas/pagination_limit_type'
        total_count:
          description: The total count of items matching the filter criteria.
          $ref: 'dict.yml#/components/schemas/total_count_type'

    pagination_limit_type:
      title: Pagination - Page Limit
      type: integer
      minimum: 10
      maximum: 9999
      default: 100
      description:
        This is the number of result rows are returned per page. If not specified 100 is assumed.
      example: 200

    pagination_skip_type:
      title: Pagination - Page to Skip
      type: integer
      minimum: 0
      maximum: 9999
      default: 0
      description:
        The number of pages to skip. 0 is the first page (no skip). A page has the size of the
        limit field.
      example: 76

    total_count_type:
      type: integer
      minimum: 0
      maximum: 9999999
      description:
        The total count of items matching the filter criteria.

    error_type:
      title: Error Code
      type: string
      enum:
        - Unauthorized
        - InternalServerError
        - Conflict
        - UnprocessableEntity
        - DuplicateReq
        - InvalidOrder
        - MixedOrders
        - InvalidAmount
        - AmountTooLow
        - AmountTooAccurate
        - AmountTooHigh
        - NoPriceStream
        - RiskCheck
        - DuplicateOrderRef
        - NotFound
        - Forbidden
        - ERROR_DUPLICATE
        - ready
        - not ready
      description:
        All error codes returned by this API have a unique code, classifying the error messages.
      example: "NotFound"

    error_text_type:
      title: Error Text
      type: string
      pattern: "^.{1,1000}$"
      maxLength: 1000
      description: Text describing the Error
      example: "The bulk order with the given id could not be found."

    internal_error_type:
      title: Internal Error Type (for 4xx Results)
      type: object
      required:
        - error
        - timestamp
      additionalProperties: false
      properties:
        error:
          $ref: "dict.yml#/components/schemas/error_type"
        timestamp:
          $ref: "dict.yml#/components/schemas/timestamp_type"
      description:
        This schema defines the json message returned in case of an API error.
      example:
        error: "Unauthorized"
        timestamp: "2023-01-20T14:31:10.012123Z"

    internal_error_description_type:
      title: Internal Error Type with error description (for 4xx Results)
      type: object
      required:
        - error
        - error_text
        - timestamp
      additionalProperties: false
      properties:
        error:
          $ref: "dict.yml#/components/schemas/error_type"
        error_text:
          $ref: "dict.yml#/components/schemas/error_text_type"
        timestamp:
          $ref: "dict.yml#/components/schemas/timestamp_type"
      description:
        This schema defines the json message returned in case of an API error.
      example:
        error: "InternalServerError"
        error_text:
          "Internal Server Error"
        timestamp: "2023-01-20T14:31:10.012123Z"

    trade_rejection_reason_type:
      title: Rejection Reason
      type: string
      enum:
        - Timeout
        - UnknownOrder
      description:
        All rejection reasons returned by this API have a unique code, classifying the rejection
        messages.
      example: "Timeout"

    trade_rejection_status_type:
      title: Rejection Status
      type: string
      enum:
        - Received
        - NotPossible
      description:
        All rejection states returned by this API have a unique code, classifying the rejection
        error.
      example: "Received"


####################################################################################################
##
## Responses
##
  responses:

    response_get_orders_type:
      description: Get Orders
      content:
        application/json:
          schema:
            title: Get Orders Response
            type: object
            required:
              - orders
              - more
            additionalProperties: false
            properties:
              orders:
                title: List of Orders
                type: array
                minItems: 1
                maxItems: 9999
                items:
                  title: Order Details
                  description:
                    If there are now orders found based on the query criteria
                    the orders array will be empty.
                  type: object
                  required:
                    - order_id
                    - seq_number
                    - arrived_at
                    - order
                    - executions
                  additionalProperties: false
                  properties:
                    order_id:
                      $ref: "dict.yml#/components/schemas/internal_ref_type"
                    seq_number:
                      $ref: "dict.yml#/components/schemas/sequence_type"
                    order_ref:
                      $ref: "dict.yml#/components/schemas/external_ref_type"
                    req_header:
                      $ref: "dict.yml#/components/schemas/req_header_type"
                    arrived_at:
                      summary: Timestamp when the order arrived at the tradias system
                      $ref: "dict.yml#/components/schemas/timestamp_type"
                    order:
                      title: List of Order (only one entry)
                      type: array
                      minItems: 1
                      maxItems: 1
                      items:
                        $ref: "dict.yml#/components/schemas/order_data_type"
                    executions:
                      title: List of Executions
                      type: array
                      minItems: 0
                      maxItems: 999
                      items:
                        $ref: "dict.yml#/components/schemas/execution_type"
              more:
                title: Flag if there are more hits after the ones in this response
                type: boolean
          example:
            orders:
              - order_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
                seq_number: 47110815
                order_ref: "18955839"
                req_header:
                  req_id: "ca57eead-b699-11ed-b3ff-cc17d418c9e0"
                  user_data:
                    - tag: "Correlation-Id"
                      value: "c8d16891-b669-11ed-bc43-f1002b6e6125"
                    - tag: "TX-Id"
                      value: "18955457"
                arrived_at: "1970-01-01T00:00:00.000000Z"
                order:
                  - instrument: "BTC-EUR"
                    order_type: "MARKET"
                    side: "BUY"
                    amount:
                      leg_1_amount: "2.5"
                    order_status: "DONE"
                executions:
                  - trade_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
                    leg_1_executed_amount: "1.25867895"
                    leg_2_executed_amount: "1.25867895"
                    execution_price: "23768.63953056"
                    executed_at: "1970-01-01T00:00:00.000000Z"
                    leg_1_status: PENDING
                    leg_2_status: SETTLED
            more: false

    response_get_trades_type:
      description: Get Trades
      content:
        application/json:
          schema:
            title: Get Trades Response
            type: object
            required:
              - trades
              - more
            additionalProperties: false
            properties:
              trades:
                title: List of Trades
                type: array
                minItems: 1
                maxItems: 9999
                items:
                  title: Trade Details
                  type: object
                  required:
                    - trade_id
                    - seq_number
                    - order_id
                    - order
                    - executions
                  additionalProperties: false
                  properties:
                    trade_id:
                      $ref: "dict.yml#/components/schemas/internal_ref_type"
                    seq_number:
                      $ref: "dict.yml#/components/schemas/sequence_type"
                    order_id:
                      $ref: "dict.yml#/components/schemas/internal_ref_type"
                    order_ref:
                      $ref: "dict.yml#/components/schemas/external_ref_type"
                    req_header:
                      $ref: "dict.yml#/components/schemas/req_header_type"
                    order:
                      title: List of Order (only one entry)
                      type: array
                      minItems: 1
                      maxItems: 1
                      items:
                        $ref: "dict.yml#/components/schemas/trade_order_data_type"
                    executions:
                      title: List of Executions
                      type: array
                      minItems: 0
                      maxItems: 999
                      items:
                        $ref: "dict.yml#/components/schemas/trade_type"
              more:
                title: Flag if there are more hits after the ones in this response
                type: boolean
          example:
            trades:
              - trade_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
                seq_number: 47110815
                order_id: "73f2e419-e4ac-4db2-84ab-81a12ad43d54"
                order_ref: "18955839"
                req_header:
                  req_id: "ca57eead-b699-11ed-b3ff-cc17d418c9e0"
                  user_data:
                    - tag: "Correlation-Id"
                      value: "c8d16891-b669-11ed-bc43-f1002b6e6125"
                    - tag: "TX-Id"
                      value: "18955457"
                order:
                  - instrument: "BTC-EUR"
                    order_type: "MARKET"
                    side: "BUY"
                    amount:
                      leg_1_amount: "2.5"
                    arrived_at: "1970-01-01T00:00:00.000000Z"
                    order_status: "DONE"
                executions:
                  - leg_1_executed_amount: "1.25867895"
                    leg_2_executed_amount: "1.25867895"
                    execution_price: "23768.63953056"
                    executed_at: "1970-01-01T00:00:00.000000Z"
                    leg_1_status: PENDING
                    leg_2_status: SETTLED
            more: false

    response_settlement_status_short_type:
      description: Settlement Status Response - Short Version
      content:
        application/json:
          schema:
            title: Settlement Request Response
            type: object
            required:
              - status
              - settlement_request_id
              - client_settlement_request_id
              - timestamp
            additionalProperties: false
            properties:
              status:
                $ref: "dict.yml#/components/schemas/settlement_status_type"
              settlement_request_id:
                $ref: "dict.yml#/components/schemas/internal_ref_type"
              client_settlement_request_id:
                $ref: "dict.yml#/components/schemas/external_ref_type"
              timestamp:
                $ref: "dict.yml#/components/schemas/timestamp_type"
          example:
            status: "received"
            settlement_request_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
            client_settlement_request_id: "c8d16891-b669-11ed-bc43-f1002b6e6125"
            timestamp: "1970-01-01T00:00:00.000000Z"

    transactions_response_type:
      description: Transaction Response
      content:
        application/json:
          schema:
            type: object
            required:
              - transaction_history
              - pagination
            properties:
              transaction_history:
                type: array
                minItems: 0
                maxItems: 99999
                items:
                  $ref: 'dict.yml#/components/schemas/transaction_item_type'
              pagination:
                $ref: 'dict.yml#/components/schemas/pagination_type'
          example:
            transaction_history:
              - transaction_id: "edf129a7-d152-4510-8aa3-c3b84b7b1dcc"
                amount: "123.45678901"
                reference: "f1611cb7afcd42e70e38ad1867bbb47debd3223eb1db8e4cd865805040614cb7"
                reference_type: "on_chain_transaction_id"
                timestamp: "2023-01-20T14:31:10.012123Z"
                from_address: "qqtdrq99rqjj06p9sy2js55y3mhnt6d4jyjfnfpwjl"
                to_address: "qrk7qvx540x9p2ytm9jh8a0cx9zqvqwu0s2updmfeu"
                currency: "BCH"
                settlement_requests:
                  - settlement_request_id: "17bdfeda-d76e-415f-bb8c-9e581513830e"
                    client_settlement_request_id: "some_settlement_request_id"
                    settlement_request_amounts:
                      - settlement_request_amount_id: "f9078f72-25b7-4eed-b9c9-437ee70ffd59"
                        amount: "100.45678901"
            pagination:
              skip: 0
              limit: 99
              total_count: 467

    map_transaction_response_type:
      description: Map Transaction Response
      content:
        application/json:
          schema:
            type: object
            required:
              - timestamp
            properties:
              timestamp:
                $ref: "dict.yml#/components/schemas/timestamp_type"
          example:
            timestamp: "2023-01-20T14:31:10.012123Z"

    response_400_type:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: "dict.yml#/components/schemas/internal_error_type"
          example:
            error: "Unauthorized"
            timestamp: "2023-01-20T14:31:10.012123Z"

    response_401_type:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: "dict.yml#/components/schemas/internal_error_type"
          example:
            error: "Unauthorized"
            timestamp: "2023-01-20T14:31:10.012123Z"

    response_403_type:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: "dict.yml#/components/schemas/internal_error_type"
          example:
            timestamp: "2023-01-20T14:31:10.012123Z"
            error: "Forbidden"

    response_404_type:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: "dict.yml#/components/schemas/internal_error_type"
          example:
            error: "NotFound"
            timestamp: "2023-01-20T14:31:10.012123Z"

    response_409_type:
      description: Request Error
      content:
        application/json:
          schema:
            title: Request Error
            type: object
            required:
              - error
              - timestamp
              - settlement_request_id
              - client_settlement_request_id
            additionalProperties: false
            properties:
              error:
                $ref: "dict.yml#/components/schemas/error_text_type"
              timestamp:
                $ref: "dict.yml#/components/schemas/timestamp_type"
              settlement_request_id:
                $ref: "dict.yml#/components/schemas/internal_ref_type"
              client_settlement_request_id:
                $ref: "dict.yml#/components/schemas/external_ref_type"
          example:
            error: "The req_id has been already processed"
            timestamp: "2023-01-20T14:31:10.012123Z"
            settlement_request_id: "75ccdf76-ae4b-11ed-85ee-81a12bb57b04"
            client_settlement_request_id: "c8d16891-b669-11ed-bc43-f1002b6e6125"

    response_422_type:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            type: object
            required:
              - error
              - timestamp
            properties:
              error:
                $ref: "dict.yml#/components/schemas/error_text_type"
              timestamp:
                $ref: "dict.yml#/components/schemas/timestamp_type"
          example:
            error: "The request is not processable"
            timestamp: "2023-01-20T14:31:10.012123Z"

    response_500_type:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: "dict.yml#/components/schemas/internal_error_description_type"
          example:
            error: "InternalServerError"
            error_text: "Internal Server Error"
            timestamp: "2023-01-20T14:31:10.012123Z"

    default_response_type:
      description: Default Response
      content:
        text/plain:
          schema:
            type: string
            pattern: "^.{1,1000}$"
            maxLength: 1000
