# Sell-to-cover orders

Selling securities to cover outstanding fees is one of the most commonly used cash collection strategies at Upvest. It has the advantage that it does not depend on the user's cash balance, so the chances of collecting the fee are much higher.

If the ‘sell-to-cover’ method is chosen, it is important that the client has a legal licence from the user to initiate such orders. This should not be a matter for portfolio managers, but if you do not have this licence, you must have the relevant points in the General Terms and Conditions (standing order).

## Process flow

In this cash collection scenario, the workflow runs through the following steps after the fee collection has been triggered:

Sell-to-cover orders
Sell-to-cover orders are created and executed on the next working day after the fee collection is created; order events are then issued accordingly.

- Upvest sells the securities with the largest position to cover the outstanding fee.
- Orders that are created to cover fees can be recognised by the `initiation_flow` value in the order event: `SELL_TO_COVER_FEES`.
- Since in most cases the amount received from a sell order is taxed, Upvest adds a 10% buffer to the order. The amount to be sold is calculated as [fee amount]*1.1.


Order events
A sell-to-cover order triggers the same events as any other order, including a PDF report event.


Positions update
Positions are updated; cash and securities transaction events are triggered. 
If, after the execution of a sell order to cover the fees, the cash received is not sufficient to cover the fees (this can happen due to high taxes or unexpected price fluctuations), another sell order is triggered for a residual amount with an increased buffer of 20%.


Fee collection
Once the sell order to cover the fee has been settled, the fee is collected and the fee collection and cash transaction events are triggered.

The remaining unused cash can be withdrawn shortly after the fee has been deducted.

## Sell-to-cover order example

A sell-to-cover order is placed with the following request:

**POST** [`/orders`](/api/orders/place_order)

Example request

```json
{
"id": "8962b496-8d42-4560-bfab-10490dd1a721",
"created_at": "2021-07-21T14:10:00.00Z",
"type": "ORDER.NEW",
"object": {
    "id": "eb5ba93f-5dfe-4bf1-8571-4da0caacc80c",
    "created_at": "2021-07-21T14:10:00.00Z",
    "updated_at": "2021-07-21T14:10:00.00Z",
    "user_id": "2dedfeb0-58cd-44f2-ae08-0e41fe0413d9",
    "account_id": "689f7566-2ca3-4007-b99d-e501be8c7783",
    "cash_amount": "22.00",
    "currency": "EUR",
    "side": "BUY",
    "instrument_id": "IE00B27YCP72",
    "instrument_id_type": "ISIN",
    "order_type": "MARKET",
    "quantity": "1.2",
    "user_instrument_fit_acknowledgement": true,
    "limit_price": "",
    "stop_price": "",
    "status": "NEW",
    "fee": "",
    "executions": [],
    "client_reference": "",
    "initiation_flow": "SELL_TO_COVER_FEES"
},
"webhook_id": "9df39835-be87-4243-9018-f2500b39cee6"
}
```

Example response

```json
{
    "id": "6ffa6b16-2380-4e7a-88b2-ae625c8eef99",
    "bank_reference": "f2f0ef23-c68d-42c1-a744-8c86f471954b"
}
```

## Tracking sell to cover orders and their residuals for fees

When using sell to cover orders for fee collection, Upvest includes a default 10% buffer to cover potential taxes and additional fees.

This only applies to clients that use Upvest to withhold taxes.

Once all orders execute and settle, you may have a residual amount remaining from the order execution. You can then either allow the end user to withdraw the residual amount or reinvest into the instrument that was sold to cover the fee.

To identify and track the sell to cover orders triggered by a specific fee collection, you can use the [Fee collection events webhook](/api/fees/fee_collection_event). When the event type equals the `FEE_COLLECTION.FINALISED` status, the webhook provides information on each sell to cover order including each order `id` and the `residual_amount` for each order.

The same information is available in the output of the [Fee collection endpoint](/api/fees/list_fee_collections).

### Sell-to-cover finalized example

Fee Collection Finalized

```json
{
    "id": "38fc59d0-fc42-46ef-9512-824773219b2e",
    "created_at": "2023-08-19T13:06:57.820371265Z",
    "type": "FEE_COLLECTION.FINALISED",
    "webhook_id": "1b097e06-8a14-4181-b72a-de0972a3c57b",
    "object": {
      "account_group_id": "999f7566-2ca3-4007-b99d-e501be8c7222",
      "account_id": "689f7566-2ca3-4007-b99d-e501be8c7783",
      "collection_amount": "12.41",
      "created_at": "2022-11-30T14:16:22Z",
      "currency": "EUR",
      "id": "d77e6924-9bb7-4db0-addc-404442258f4b",
      "period_start": "2022-11-01",
      "period_end": "2022-11-30",
      "processed_amount": {
        "cash_balance": "0",
        "sell_to_cover": "0",
        "total_residual_amount": "0.12"
      },
      "sell_to_cover_orders": [
        {
          "id": "1d0e329b-9c01-4dde-9883-5638d6319925",
          "residual_amount": "0.00"
        },
        {
          "id":"8317dc2a-4073-437b-b27d-2c52f1e4c8b2",
          "residual_amount": "0.12"
        }
      ],
      "calculation_breakdown": [
        {
          "fee_model_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "subperiod_start": "2022-11-01",
          "subperiod_end": "2022-11-30",
          "subtotal_amount": "12.41",
          "components": [
            {
              "type": "SERVICE",
              "amount": "10.00"
            },
            {
              "type": "PLATFORM",
              "amount": "2.41"
            }
          ]
        }
      ],
      "status": "FINALISED",
      "type": "SERVICE_FEE",
      "updated_at": "2022-11-30T14:16:22Z"
    }
  }
```