Coinlocally Docs
API Document
API Document
  • Introduction
    • API Basic Information
    • HTTP Error Codes
    • General Information
    • Limits
    • Endpoint Security Type
    • Signature Authentication
    • Timing Security
    • SIGNED Endpoint Example
  • Changelog
  • Spot
    • Public
    • Market
    • Trade
    • Account
  • Futures
    • Public
    • Market
    • Trade
    • Account
  • Margin
  • Withdraw
  • WebSocket
    • Spot
    • Futures
  • Official SDK
  • Enums
  • Error
  • FAQ
Powered by GitBook
On this page
  1. Futures

Trade

PreviousMarketNextAccount

Last updated 17 days ago

Cancel All Orders

post

Cancel all open orders.

Header parameters
X-CH-SIGNstringRequired
X-CH-APIKEYstringRequired
X-CH-TSintegerRequired
Body
Responses
200
All orders cancelled successfully
application/json
post
POST /fapi/v1/cancel_all HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: 1
Accept: */*
200

All orders cancelled successfully

{
  "code": "0",
  "msg": "Success",
  "data": null
}

Get Open Orders

get

Retrieve currently open futures orders for a user.

Speed Limit: Defined by exchangeSecurity Type: TRADE

Query parameters
contractNamestringOptional

Contract name E.g. E-BTC-USDT

Header parameters
X-CH-SIGNstringRequired

Signature

X-CH-APIKEYstringRequired

Your API-key

X-CH-TSintegerRequired

Timestamp

Responses
200
Successfully retrieved open orders.
application/json
get
GET /fapi/v1/openOrders HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: 1
Accept: */*
200

Successfully retrieved open orders.

[
  {
    "side": "BUY",
    "executedQty": 0,
    "orderId": 259396989397942270,
    "price": 10000,
    "origQty": 1,
    "avgPrice": 0,
    "transactTime": "1607702400000",
    "action": "OPEN",
    "contractName": "E-BTC-USDT",
    "type": "LIMIT",
    "status": "INIT"
  }
]

Get Trade History

get

Retrieve a list of past trades executed under a contract.

Query parameters
contractNamestringOptional

Contract name E.g. E-BTC-USDT

limitstringOptional

Lines per page, default 100, max 1000

fromIdintegerOptional

Start retrieving from this tradeId

Header parameters
X-CH-SIGNstringRequired

Signature

X-CH-APIKEYstringRequired

Your API-key

X-CH-TSintegerRequired

Time stamp

Responses
200
Successfully retrieved trade history
application/json
get
GET /fapi/v1/myTrades HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: 1
Accept: */*
200

Successfully retrieved trade history

[
  {
    "symbol": "ETHBTC",
    "id": 100211,
    "bidId": 150695552109032480,
    "askId": 150695552109032480,
    "price": "4.00000100",
    "qty": "12.00000000",
    "time": 1499865549590,
    "isBuyer": true,
    "isMaker": false,
    "fee": "0.001"
  }
]
  • POSTCreate Order
  • POSTCreate Condition Order
  • POSTCancel Order
  • POSTCancel All Orders
  • GETGet Order Details
  • GETGet Open Orders
  • POSTGet Order History
  • POSTGet Profit History
  • GETGet Trade History
  • POSTChange Position Mode
  • POSTChange Margin Mode
  • POSTAdjust Position Margin
  • POSTChange Leverage Ratio

Create Order

post

Create a new futures order.

Header parameters
X-CH-TSstringRequired
X-CH-APIKEYstringRequired
X-CH-SIGNstringRequired
Body
volumenumberRequired
pricenumberRequired
contractNamestringRequired
typestring · enumRequiredPossible values:
sidestring · enumRequiredPossible values:
openstring · enumRequiredPossible values:
positionTypenumberRequired
clientOrderIdstringOptional
timeInForcestring · enumOptionalPossible values:
Responses
200
Order successfully created
application/json
post
POST /fapi/v1/order HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-TS: text
X-CH-APIKEY: text
X-CH-SIGN: text
Content-Type: application/json
Accept: */*
Content-Length: 146

{
  "volume": 1,
  "price": 1,
  "contractName": "text",
  "type": "LIMIT",
  "side": "BUY",
  "open": "OPEN",
  "positionType": 1,
  "clientOrderId": "text",
  "timeInForce": "IOC"
}
200

Order successfully created

{
  "orderId": 256609229205684220
}

Create Condition Order

post

Create a new condition order.

Header parameters
X-CH-TSstringRequired
X-CH-APIKEYstringRequired
X-CH-SIGNstringRequired
Body
volumenumberRequired
triggerTypestringRequired
triggerPricestringRequired
positionTypenumberRequired
openstringRequired
sidestringRequired
typestringRequired
contractNamestringRequired
pricenumberOptional
Responses
200
Condition order successfully created
application/json
post
POST /fapi/v1/conditionOrder HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-TS: text
X-CH-APIKEY: text
X-CH-SIGN: text
Content-Type: application/json
Accept: */*
Content-Length: 146

{
  "volume": 1,
  "triggerType": "text",
  "triggerPrice": "text",
  "positionType": 1,
  "open": "text",
  "side": "text",
  "type": "text",
  "contractName": "text",
  "price": 1
}
200

Condition order successfully created

{
  "orderId": 256609229205684220
}

Cancel Order

post

Cancel a specific order by ID.

Header parameters
X-CH-SIGNstringRequired
X-CH-APIKEYstringRequired
X-CH-TSintegerRequired
Body
contractNamestringRequired
orderIdstringRequired
Responses
200
Order cancelled successfully
application/json
post
POST /fapi/v1/cancel HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: 1
Content-Type: application/json
Accept: */*
Content-Length: 40

{
  "contractName": "text",
  "orderId": "text"
}
200

Order cancelled successfully

{
  "orderId": 256609229205684220
}

Get Order Details

get

Retrieve details of a specific order.

Body
contractNamestringRequired
Responses
200
Order details retrieved successfully
application/json
get
GET /fapi/v1/order HTTP/1.1
Host: futuresopenapi.coinlocally.com
Content-Type: application/json
Accept: */*
Content-Length: 23

{
  "contractName": "text"
}
200

Order details retrieved successfully

[
  {
    "side": "BUY",
    "executedQty": 0,
    "orderId": 259396989397942270,
    "price": 10000,
    "origQty": 1,
    "avgPrice": 0,
    "transactTime": "1607702400000",
    "action": "OPEN",
    "contractName": "E-BTC-USDT",
    "type": "LIMIT",
    "status": "INIT"
  }
]

Get Order History

post

Retrieve historical order records for a user.

Security Type: TRADE

Header parameters
X-CH-SIGNstringRequired

Signature

X-CH-APIKEYstringRequired

Your API-key

X-CH-TSstringRequired

Timestamp

Body
contractNamestringRequired
limitstringOptionalDefault: 100
fromIdintegerOptional
Responses
200
Successfully retrieved historical orders.
application/json
post
POST /fapi/v1/orderHistorical HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: text
Content-Type: application/json
Accept: */*
Content-Length: 49

{
  "contractName": "text",
  "limit": "text",
  "fromId": 1
}
200

Successfully retrieved historical orders.

[
  {
    "side": "BUY",
    "clientId": "0",
    "ctimeMs": 1632903411000,
    "positionType": 2,
    "orderId": 777293886968070100,
    "avgPrice": 41000,
    "openOrClose": "OPEN",
    "leverageLevel": 26,
    "type": 4,
    "closeTakerFeeRate": 0.00065,
    "volume": 2,
    "openMakerFeeRate": 0.00025,
    "dealVolume": 1,
    "price": 41000,
    "closeMakerFeeRate": 0.00025,
    "contractId": 1,
    "ctime": "2021-09-29T16:16:51",
    "contractName": "E-BTC-USDT",
    "openTakerFeeRate": 0.00065,
    "dealMoney": 4.1,
    "status": 4
  }
]

Get Profit History

post

Retrieves historical realized profits for a given contract.

Header parameters
X-CH-SIGNstringRequired
X-CH-APIKEYstringRequired
X-CH-TSstringRequired
Body
contractNamestringOptional
limitstringOptional
fromIdintegerOptional
Responses
200
Profit history retrieved successfully
application/json
post
POST /fapi/v1/profitHistorical HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: text
Content-Type: application/json
Accept: */*
Content-Length: 49

{
  "contractName": "text",
  "limit": "text",
  "fromId": 1
}
200

Profit history retrieved successfully

[
  {
    "side": "SELL",
    "positionType": 2,
    "tradeFee": -5.23575,
    "realizedAmount": 0,
    "leverageLevel": 26,
    "openPrice": 44500,
    "settleProfit": 0,
    "mtime": 1632882739000,
    "shareAmount": 0,
    "openEndPrice": 44500,
    "closeProfit": -45,
    "volume": 900,
    "contractId": 1,
    "historyRealizedAmount": -50.23575,
    "ctime": 1632882691000,
    "id": 8764,
    "capitalFee": 0
  }
]

Change Position Mode

post

Switch between Net Position and Two-way Position modes.

Body
contractNamestringRequiredExample: E-BTC-USDT
positionModelintegerRequiredExample: 1
Responses
200
Position mode changed successfully.
application/json
post
POST /fapi/v1/edit_user_position_model HTTP/1.1
Host: futuresopenapi.coinlocally.com
Content-Type: application/json
Accept: */*
Content-Length: 47

{
  "contractName": "E-BTC-USDT",
  "positionModel": 1
}
200

Position mode changed successfully.

{
  "code": "0",
  "msg": "Success",
  "data": null
}

Change Margin Mode

post

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

Body
contractNamestringRequiredExample: E-BTC-USDT
marginModelintegerRequiredExample: 1
Responses
200
Margin mode changed successfully.
application/json
post
POST /fapi/v1/edit_user_margin_model HTTP/1.1
Host: futuresopenapi.coinlocally.com
Content-Type: application/json
Accept: */*
Content-Length: 45

{
  "contractName": "E-BTC-USDT",
  "marginModel": 1
}
200

Margin mode changed successfully.

{
  "code": "0",
  "msg": "Success",
  "data": null
}

Adjust Position Margin

post

Adjust the margin for an open futures position.

Weight: 1

Header parameters
X-CH-SIGNstringRequired
X-CH-APIKEYstringRequired
X-CH-TSintegerRequired
Body
positionIdintegerRequired

Position ID

amountnumberRequired

Amount to adjust

Responses
200
Margin adjustment was successful.
application/json
post
POST /fapi/v1/edit_position_margin HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: 1
Content-Type: application/json
Accept: */*
Content-Length: 27

{
  "positionId": 1,
  "amount": 1
}
200

Margin adjustment was successful.

{
  "code": "0",
  "msg": "Success",
  "data": null
}

Change Leverage Ratio

post

Change the leverage setting for a specific contract.

Weight: 1

Header parameters
X-CH-SIGNstringRequired
X-CH-APIKEYstringRequired
X-CH-TSintegerRequired
Body
contractNamestringRequired

Contract name

nowLevelintegerRequired

New leverage level (e.g., 50)

Responses
200
Leverage level changed successfully.
application/json
post
POST /fapi/v1/edit_lever HTTP/1.1
Host: futuresopenapi.coinlocally.com
X-CH-SIGN: text
X-CH-APIKEY: text
X-CH-TS: 1
Content-Type: application/json
Accept: */*
Content-Length: 36

{
  "contractName": "text",
  "nowLevel": 1
}
200

Leverage level changed successfully.

{
  "code": "0",
  "msg": "Success",
  "data": null
}