WEEX
WEEX (Spot): WEEX spot trading over the WEEX spot V3 REST API (api-spot.weex.com). The API KEY configuration needs the Access Key, Secret Key and Passphrase. Spot only; use Futures_WEEX for perpetual contracts.
Futures_WEEX (Futures): WEEX USDT-margined perpetual contracts over the WEEX futures V3 REST API (api-contract.weex.com), with no delivery contracts. The API KEY configuration needs the Access Key, Secret Key and Passphrase. Native take-profit and stop-loss conditional orders are supported.
Names and Configuration
exchange.GetName() | Type |
|---|---|
WEEX | Spot |
Futures_WEEX | Futures |
| Field | Required |
| - | - |
| Access Key | Yes |
| Secret Key | Yes |
| Passphrase | Yes |
Trading Pairs and Contract Codes
All exchange objects
Pair examples: BTC_USDT, ETH_USDT
WEEX (Spot)
Trading pairs are written BTC_USDT, matching the WEEX native code BTCUSDT. Symbols with a contract suffix are rejected.
Futures_WEEX (Futures)
Trading pairs are written BTC_USDT, matching the WEEX native code BTCUSDT; exchange.GetMarkets() lists the tradable contracts.
| Contract code | Description |
|---|---|
swap | Perpetual contract. |
WEEX has no delivery contracts; other contract codes are rejected. Order amounts are in the base currency (the exchange does not accept orders in contracts; CtVal is 1 in exchange.GetMarkets()).
Function Support
WEEX (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, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 1w; other periods are synthesized by the docker.
Futures_WEEX (Futures)
Not supported (the call fails with an error and returns null): exchange.ModifyOrder.
Served through a fallback:
exchange.GetRecords: Native periods are 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w; other periods are synthesized by the docker.
Margin, Account and Simulation
Futures_WEEX (Futures)
Margin mode: There is no IO command for switching cross/isolated margin; the margin mode follows the contract's setting in the exchange account. exchange.SetMarginLevel() first reads the contract's current margin mode: under isolated margin it sets both the long and short leverage, under cross margin the cross leverage.
Position mode: Every order carries the position side positionSide, derived from the order direction: LONG for opening or closing long, SHORT for opening or closing short; positionSide can also be passed explicitly in the extra parameters. Conditional orders carry the position side too.
Notes
WEEX (Spot)
- The amount of a market buy order is in the quote currency: the WEEX spot API cannot place market orders by amount, so the connector converts the amount into a base-currency quantity using the current asks (up to 200 levels, rounded down to the quantity step) before ordering; the filled amount may differ slightly from the amount passed. If the asks cannot absorb the amount, or the converted quantity is below the minimum order size, an error is reported instead of buying less. An explicit
quantityin the extra parameters is used as is. When the order is queried, theAmountof a market buy order is the base-currency quantity recorded by the exchange. - Post-only (maker-only) orders are not supported; limit orders accept GTC, IOC and FOK only.
exchange.GetHistoryOrders()queries one trading pair only (the exchange's order history endpoint is per pair): withoutsymbolit queries the current trading pair, and an empty string fails. The exchange looks back about 90 days only; asinceolder than that is queried from 90 days ago.
Futures_WEEX (Futures)
- Conditional orders support take-profit and stop-loss only, not OCO (place the take-profit and stop-loss legs as two conditional orders).
exchange.ModifyConditionOrder()modifies the order in place through the exchange's modify endpoint, keeping the order ID; only untriggered take-profit and stop-loss conditional orders can be modified. The trigger price and order price can be changed: they are taken fromTpTriggerPrice/TpOrderPriceorSlTriggerPrice/SlOrderPriceofconditionaccording to the condition type, and an order price of-1(or not greater than 0) switches to market execution after triggering. The exchange cannot change the amount or the side: if the amount or direction passed differs from the original order, an error is reported and a null value is returned rather than ignoring it. The trigger price type is kept from the original order (mark price or last price);triggerPriceType(CONTRACT_PRICEorMARK_PRICE) can also be passed in the extra parameters. Whether the modified order is a take-profit or a stop-loss is decided by the exchange from the new trigger price and may differ fromConditionType; checkexchange.GetConditionOrder().- The exchange has no endpoint for querying a conditional order by ID, so
exchange.GetConditionOrder()searches the active conditional orders and then the latest 20000 historical conditional orders, and fails when the order is not found. exchange.GetHistoryOrders()andexchange.GetHistoryConditionOrders()look back about 90 days only; asinceolder than that is queried from 90 days ago.- The
Rateofexchange.GetFundings()is the forecast funding rate of the next settlement andTimeis the next settlement time; batch queries are supported (no symbol, or a range such asUSDT.swap). - In
exchange.GetTickers(), contracts without order book data (missing from the exchange's book ticker, for example a contract whose market is closed) haveBuyandSellof 0. Offsetof orders and conditional orders follows the side and the position side: selling on the long side (close long) and buying on the short side (close short) are closing, everything else is opening. In hedge mode the exchange returnsreduceOnlyasfalseeven for closing conditional orders, so it is not used; only when the position side is one-way (BOTH) or missing arereduceOnly/closePositionused.