> For the complete documentation index, see [llms.txt](https://docs.elven.com/v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elven.com/v3/openapi/import-trade.md).

# Import Trade

### API Overview

This API enables the batch import of trade records into the system, supporting the import of multiple data entries in a single request.

* **Request Method：**`POST`
* **Request URL：**`https://openapi.elven.com/open/v3/transaction/trade`

### Request Headers

<table><thead><tr><th width="202">Parameter Name</th><th width="90">Type</th><th width="100">Required</th><th>Description</th></tr></thead><tbody><tr><td>elven-api-key</td><td>String</td><td>Yes</td><td>The API key assigned to you</td></tr><tr><td>elven-api-sign</td><td>String</td><td>Yes</td><td>Request signature, used to verify the legitimacy of the request</td></tr><tr><td>elven-api-timestamp</td><td>String</td><td>Yes</td><td>Request timestamp, in milliseconds</td></tr></tbody></table>

[View Details](/v3/openapi/obtaining-api-authorization.md)

### Request Parameters

#### Body Parameters (JSON Format)

<table><thead><tr><th width="207">Parameter Name</th><th width="91">Type</th><th width="98">Required</th><th>Description</th></tr></thead><tbody><tr><td>entityAccountId</td><td>String</td><td>Yes</td><td>The primary key of the account.</td></tr><tr><td>sourceId</td><td>String</td><td>Yes</td><td>The primary key of the source.</td></tr><tr><td>timezone</td><td>String</td><td>No</td><td>Time Zone: If left empty, it will default to the entity’s time zone.<a href="/pages/y9OhaBGBcaBxDW62Inyh">View Details</a></td></tr><tr><td>list</td><td>Array</td><td>Yes</td><td>Transaction record list, containing multiple transaction objects, with a maximum of 1000 records supported per request.</td></tr></tbody></table>

**Elements in the List**

<table><thead><tr><th width="178">Parameter Name</th><th width="95">Type</th><th width="102">Required</th><th>Description</th></tr></thead><tbody><tr><td>datetime</td><td>String</td><td>Yes</td><td>Transaction time in the format <code>YYYY-MM-DD HH:mm:ss</code></td></tr><tr><td>tradeID</td><td>String</td><td>No</td><td>Transaction hash or unique identifier.</td></tr><tr><td>type</td><td>String</td><td>Yes</td><td>Transaction type.</td></tr><tr><td>positionSide</td><td>String</td><td>No</td><td>Future position direction (valid values: LONG/SHORT). Required only when <code>type</code> is <code>FUTURE_OPEN</code> or <code>FUTURE_CLOSE</code>.</td></tr><tr><td>baseAsset</td><td>String</td><td>Yes</td><td>Name of the base asset (maximum 200 characters).</td></tr><tr><td>baseAmount</td><td>Number</td><td>Yes</td><td>Amount of the base asset.</td></tr><tr><td>counterAsset</td><td>String</td><td>Yes</td><td>Name of the counter asset (case-sensitive).</td></tr><tr><td>counterAmount</td><td>Number</td><td>Yes</td><td>Amount of the counter asset.</td></tr><tr><td>feeAsset</td><td>String</td><td>No</td><td>Name of the fee asset.</td></tr><tr><td>feeAmount</td><td>Number</td><td>No</td><td>Amount of the fee.</td></tr><tr><td>memo</td><td>String</td><td>No</td><td>Additional information or notes for the transaction.</td></tr></tbody></table>

#### **Type Parameter Description**

| Transaction Type  | Description      |
| ----------------- | ---------------- |
| FUTURE\_OPEN      | Open Position    |
| FUTURE\_CLOSE     | Close Position   |
| OPTION\_BUY       | Option Purchase  |
| OPTION\_SELL      | Option Sale      |
| OPTION\_EXERCISE  | Option Exercise  |
| SPOT\_BUY         | Spot Purchase    |
| SPOT\_SELL        | Spot Sale        |
| FOREIGN\_EXCHANGE | Foreign Exchange |
| SWAP              | Swap             |

***

#### **PositionSide Parameter Description**

| Type          | Is positionSide required? |
| ------------- | ------------------------- |
| FUTURE\_OPEN  | Required                  |
| FUTURE\_CLOSE | Required                  |
| Other Types   | Must be left empty        |

#### Example Request

```json
{
    "entityAccountId": "QfgBd6vH2ptevhqZjNTn06MiJOFUXGcD",
    "sourceId": "RHFjsy6UIgM1rdxvefXVsJy8L3NOhBmQ",
    "timezone": "UTC",
    "list": [
        {
            "datetime": "2023-11-01 11:13:00",
            "tradeID": "12341",
            "type": "FUTURE_OPEN",
            "positionSide": "LONG",
            "baseAsset": "Binance-ETHUSDT-PERP1",
            "baseAmount": 0.0081,
            "counterAsset": "USDT",
            "counterAmount": 16.793,
            "feeAsset": "USDT",
            "feeAmount": 0.01,
            "memo": ""
        },
        {
            "datetime": "2023-11-01 11:13:00",
            "tradeID": "12342",
            "type": "FUTURE_CLOSE",
            "positionSide": "LONG",
            "baseAsset": "Binance-ETHUSDT-PERP1",
            "baseAmount": 1.0081,
            "counterAsset": "USDT",
            "counterAmount": 17.793,
            "feeAsset": "USDT",
            "feeAmount": 1.01,
            "memo": ""
        }
    ]
}

```

### Response Parameters

<table><thead><tr><th width="204">Parameter Name</th><th width="141"> Type</th><th>Description</th></tr></thead><tbody><tr><td>success</td><td>String</td><td>Request status (e.g., <code>success</code>).</td></tr><tr><td>data</td><td>Boolean</td><td>Request result (e.g., <code>true</code> indicates success).</td></tr></tbody></table>

#### Example Response

```json
{
    "status": "success",
    "data": true
}
```

### **Notes**

* **Asynchronous Processing:**  This API only imports the transaction data into a pre-processing database. The system processes the data asynchronously, and the imported transactions will appear in the user's transaction list after processing is complete.
* **Record Limit:**  Each request supports importing up to 1000 transaction records. For larger datasets, split them into multiple requests.
* **Data Integrity:**  Ensure the transaction data is complete and accurate to avoid import errors.
* **Datetime Format**: The `datetime` field must strictly follow the format `YYYY-MM-DD HH:mm:ss`. Parsing errors may occur if the format is incorrect.
