# Trade

## Create Order

> Create a new futures order.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"security":[{"ApiKeyAuth":[]}],"paths":{"/fapi/v1/order":{"post":{"summary":"Create Order","description":"Create a new futures order.","parameters":[{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"volume":{"type":"number"},"price":{"type":"number"},"contractName":{"type":"string"},"type":{"type":"string","enum":["LIMIT","MARKET"]},"side":{"type":"string","enum":["BUY","SELL"]},"open":{"type":"string","enum":["OPEN","CLOSE"]},"positionType":{"type":"number"},"clientOrderId":{"type":"string"},"timeInForce":{"type":"string","enum":["IOC","FOK","POST_ONLY"]}},"required":["volume","price","contractName","type","side","open","positionType"]}}}},"responses":{"200":{"description":"Order successfully created","content":{"application/json":{}}}}}}}}
```

## Create Condition Order

> Create a new condition order.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"security":[{"ApiKeyAuth":[]}],"paths":{"/fapi/v1/conditionOrder":{"post":{"summary":"Create Condition Order","description":"Create a new condition order.","parameters":[{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"volume":{"type":"number"},"triggerType":{"type":"string"},"triggerPrice":{"type":"string"},"positionType":{"type":"number"},"open":{"type":"string"},"side":{"type":"string"},"type":{"type":"string"},"contractName":{"type":"string"},"price":{"type":"number"}},"required":["volume","triggerType","triggerPrice","positionType","open","side","type","contractName"]}}}},"responses":{"200":{"description":"Condition order successfully created","content":{"application/json":{}}}}}}}}
```

## Cancel Order

> Cancel a specific order by ID.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/cancel":{"post":{"summary":"Cancel Order","description":"Cancel a specific order by ID.","parameters":[{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contractName":{"type":"string"},"orderId":{"type":"string","description":"empty means cancel all orders under this contract"}},"required":["contractName"]}}}},"responses":{"200":{"description":"Order cancelled successfully","content":{"application/json":{}}}}}}}}
```

## Cancel All Orders

> Cancel all open orders.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/cancel_all":{"post":{"summary":"Cancel All Orders","description":"Cancel all open orders.","parameters":[{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":false},"responses":{"200":{"description":"All orders cancelled successfully","content":{"application/json":{}}}}}}}}
```

## Get Order Details

> Retrieve details of a specific order.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/order":{"get":{"summary":"Get Order Details","description":"Retrieve details of a specific order.","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contractName":{"type":"string"}},"required":["contractName"]}}}},"responses":{"200":{"description":"Order details retrieved successfully","content":{"application/json":{}}}}}}}}
```

## Get Open Orders

> Retrieve currently open futures orders for a user.\
> \
> \*\*Speed Limit:\*\* Defined by exchange\
> \*\*Security Type:\*\* TRADE

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/openOrders":{"get":{"summary":"Get Open Orders","description":"Retrieve currently open futures orders for a user.\n\n**Speed Limit:** Defined by exchange\n**Security Type:** TRADE","parameters":[{"name":"contractName","in":"query","required":false,"schema":{"type":"string"},"description":"Contract name E.g. USDT1816-BTC-USDT"},{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"},"description":"Signature"},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"},"description":"Your API-key"},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"integer"},"description":"Timestamp"}],"responses":{"200":{"description":"Successfully retrieved open orders.","content":{"application/json":{}}}}}}}}
```

## Get Order History

> Retrieve historical order records for a user.\
> \
> \*\*Security Type:\*\* TRADE

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/orderHistorical":{"post":{"summary":"Get Order History","description":"Retrieve historical order records for a user.\n\n**Security Type:** TRADE","parameters":[{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"},"description":"Signature"},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"},"description":"Your API-key"},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"string"},"description":"Timestamp"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contractName":{"type":"string"},"limit":{"type":"string","default":"100"},"fromId":{"type":"integer"}},"required":["contractName"]}}}},"responses":{"200":{"description":"Successfully retrieved historical orders.","content":{"application/json":{}}}}}}}}
```

## Get Profit History

> Retrieves historical realized profits for a given contract.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/profitHistorical":{"post":{"summary":"Get Profit History","description":"Retrieves historical realized profits for a given contract.","parameters":[{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contractName":{"type":"string"},"limit":{"type":"string"},"fromId":{"type":"integer"}}}}}},"responses":{"200":{"description":"Profit history retrieved successfully","content":{"application/json":{}}}}}}}}
```

## Get Trade History

> Retrieve a list of past trades executed under a contract.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/myTrades":{"get":{"summary":"Get Trade History","description":"Retrieve a list of past trades executed under a contract.","parameters":[{"name":"contractName","in":"query","schema":{"type":"string"},"description":"Contract name E.g. USDT1816-BTC-USDT"},{"name":"limit","in":"query","schema":{"type":"string"},"description":"Lines per page, default 100, max 1000"},{"name":"fromId","in":"query","schema":{"type":"integer"},"description":"Start retrieving from this tradeId"},{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"},"description":"Signature"},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"},"description":"Your API-key"},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"integer"},"description":"Time stamp"}],"responses":{"200":{"description":"Successfully retrieved trade history","content":{"application/json":{}}}}}}}}
```

## Change Position Mode

> Switch between Net Position and Two-way Position modes.

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/edit_user_position_model":{"post":{"summary":"Change Position Mode","description":"Switch between Net Position and Two-way Position modes.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contractName":{"type":"string"},"positionModel":{"type":"integer"}},"required":["contractName","positionModel"]}}}},"responses":{"200":{"description":"Position mode changed successfully.","content":{"application/json":{}}}}}}}}
```

## Change Margin Mode

> Modify the margin mode for a given contract (Cross or Isolated).

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/edit_user_margin_model":{"post":{"summary":"Change Margin Mode","description":"Modify the margin mode for a given contract (Cross or Isolated).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contractName":{"type":"string"},"marginModel":{"type":"integer"}},"required":["contractName","marginModel"]}}}},"responses":{"200":{"description":"Margin mode changed successfully.","content":{"application/json":{}}}}}}}}
```

## Adjust Position Margin

> Adjust the margin for an open futures position.\
> \
> \*\*Weight:\*\* 1

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/edit_position_margin":{"post":{"summary":"Adjust Position Margin","description":"Adjust the margin for an open futures position.\n\n**Weight:** 1","parameters":[{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["positionId","amount"],"properties":{"positionId":{"type":"integer","description":"Position ID"},"amount":{"type":"number","description":"Amount to adjust"}}}}}},"responses":{"200":{"description":"Margin adjustment was successful.","content":{"application/json":{}}}}}}}}
```

## Change Leverage Ratio

> Change the leverage setting for a specific contract.\
> \
> \*\*Weight:\*\* 1

```json
{"openapi":"3.0.0","info":{"title":"Coinlocally Futures Trading API","version":"1.0.0"},"servers":[{"url":"https://futuresopenapi.coinlocally.com"}],"paths":{"/fapi/v1/edit_lever":{"post":{"summary":"Change Leverage Ratio","description":"Change the leverage setting for a specific contract.\n\n**Weight:** 1","parameters":[{"name":"X-CH-SIGN","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-APIKEY","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-CH-TS","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["contractName","nowLevel"],"properties":{"contractName":{"type":"string","description":"Contract name"},"nowLevel":{"type":"integer","description":"New leverage level (e.g., 50)"}}}}}},"responses":{"200":{"description":"Leverage level changed successfully.","content":{"application/json":{}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinlocally.com/futures/trade.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
