CoinW
Coinw (Spot): CoinW spot trading through CoinW's command-style spot API (api.coinw.com); everything is REST polling, with no market data or order push. Private endpoints need an API key (Access Key and Secret Key). Spot only, with no simulated trading; use Futures_Coinw for perpetual contracts.
Futures_Coinw (Futures): CoinW USDⓈ-margined perpetual contracts (USDT and USDC margin), through the CoinW futures API (/v1/perpum on api.coinw.com); everything is REST polling, with no market data or order push. Private endpoints need an API key (Access Key and Secret Key). Perpetual contracts only, with no coin-margined or delivery contracts and no simulated trading.
Names and Configuration
exchange.GetName() | Type |
|---|---|
Coinw | Spot |
Futures_Coinw | Futures |
| Field | Required |
| - | - |
| Access Key | Yes |
| Secret Key | Yes |
Trading Pairs and Contract Codes
Coinw (Spot)
Pair examples: BTC_USDT, ETH_USDT
Trading pairs are written BTC_USDT, the same as CoinW's native spot code (upper case). This exchange object trades spot only; symbols with a contract suffix are rejected; use Futures_Coinw for perpetual contracts.
Futures_Coinw (Futures)
Pair examples: BTC_USDT, BTC_USDC
The quote currency selects the margin currency: BTC_USDT is USDT-margined, BTC_USDC is USDC-margined; other quote currencies are rejected. Native contract names are BTCUSDT and BTCUSDC.
| Contract code | Description |
|---|---|
swap | Perpetual contract. |
CoinW lists perpetual contracts only; other contract codes are rejected. Order amounts are in contracts; the coin amount per contract is CtVal in exchange.GetMarkets().
Exchange-specific IO Commands
Coinw (Spot)
| Command | Arguments | Description | Returns |
|---|---|---|---|
api | method, path, params[, raw] | Call a CoinW spot private endpoint directly, always signed. (more below the table) | The exchange's whole response (not just data); an error is raised when the response code is not 200. |
The rest of the longer descriptions in the table:
api: CoinW spot dispatches bycommand, which must be given inparams(e.g.exchange.IO("api", "POST", "/api/v1/private", "command=returnBalances")); it is an error when missing.paramsis an object or a string like"a=1&b=2"; a non-emptyrawreplacesparamsentirely.
For the common commands base and currency see exchange.IO.
Futures_Coinw (Futures)
| Command | Arguments | Description | Returns |
|---|---|---|---|
cross | bool | Cross (true) / isolated (false) margin, an account-level setting sent to the exchange; the exchange rejects it with an error (code 9042) while positions are open. | The value set. |
For the common commands api, base and currency see exchange.IO.
Common Usage
Call spot private endpoints by command (Coinw only)
javascript
function main() {
// command goes in params ("a=1&b=2" string or object); the whole reply (code 200)
// is returned
var r = exchange.IO("api", "POST", "/api/v1/private", "command=returnBalances")
Log(r.data)
var params = {command: "returnOpenOrders", currencyPair: "BTC_USDT"}
var orders = exchange.IO("api", "POST", "/api/v1/private", params)
Log(orders.data)
}
Function Support
Coinw (Spot)
Not supported (the call fails with an error and returns null): exchange.ModifyOrder, exchange.CreateConditionOrder, exchange.ModifyConditionOrder, exchange.CancelConditionOrder, exchange.GetConditionOrder, exchange.GetConditionOrders, exchange.GetHistoryConditionOrders.
Served through a fallback:
exchange.GetRecords: Native periods are 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 1d, 1w; other periods are synthesized by the docker.
Futures_Coinw (Futures)
Not supported (the call fails with an error and returns null): exchange.ModifyOrder, exchange.ModifyConditionOrder.
Served through a fallback:
exchange.GetRecords: Native periods are 1m, 3m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M; other periods are synthesized by the docker. At most 300 bars per call.
Margin, Account and Simulation
Futures_Coinw (Futures)
Margin mode: Switch the account between cross and isolated margin with exchange.IO("cross", bool); until it is switched, the current mode is queried before each order and sent with it. CoinW has no endpoint for setting leverage: exchange.SetMarginLevel() only records the leverage (a fraction is truncated, and a value below 1 after truncation is rejected), which is then sent with every order (conditional orders included) of that contract; without it orders use 10x. leverage in an order's extra parameters sets the leverage of that order.
Position mode: One-way positions only; exchange.IO("dual", ...) is not supported. Closing (closebuy, closesell) closes the existing position in that direction and fails when there is none.
Notes
Coinw (Spot)
- The open-order endpoint requires a trading pair:
exchange.GetOrders()without arguments queries the open orders of the current trading pair only, not all pairs. - The amount of a market buy order is the quote-currency sum to spend (sent as CoinW's
funds); a market sell order's amount is in the base currency. - Orders are only limit or market: the exchange does not support post-only (
postOnly), IOC or FOK, and passing them fails without sending the order. A custom order id (clientId) is sent as CoinW'sout_trade_no(at most 50 characters, letters, digits,-and_only); the returned and queried order ID is still the exchange order ID.
Futures_Coinw (Futures)
- Conditional orders support take-profit and stop-loss only, not OCO; orders and conditional orders cannot be modified, cancel and place again instead.
- The open-order and open-conditional-order endpoints require a trading pair:
exchange.GetOrders()andexchange.GetConditionOrders()without arguments query the current contract only, not all contracts. exchange.GetHistoryOrders()andexchange.GetHistoryConditionOrders()do not support thesinceargument (the exchange's history endpoint has no time-range parameter) and fail when it is given; only the most recent orders can be queried.- Amounts in
exchange.GetDepth()are in contracts: the coin amounts from the exchange are converted with the coin amount per contract and rounded. Amounts inexchange.GetTrades()are in contracts as well. - USDT-margined and USDC-margined contracts use two accounts:
exchange.GetAccount()andexchange.GetAssets()query the account of the current contract's quote currency (BTC_USDC.swapqueries the USDC account); without a trading pair both accounts are returned. - Limit orders support IOC, FOK and post-only (
postOnly), mapped to the CoinWpositionTypevaluesIOC,FOKandPostOnly; market orders, closing orders (reduceOnly, which use the exchange's close-position endpoint) and conditional orders do not support these options and fail when they are given. A custom order ID (clientId) is sent asthirdOrderId; closing orders do not support it.