-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
gateio swaps
github-actions[bot] edited this page Jun 24, 2026
·
4 revisions
// @NO_AUTO_TRANSPILE
import ccxt from '../../js/ccxt.js';
const exchange = new ccxt.gate({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET_KEY',
'options': {
'defaultType': 'swap',
},
});
(async () => {
// exchange.setSandboxMode (true)
const markets = await exchange.loadMarkets();
exchange.verbose = true; // uncomment for debugging purposes if necessary
// Example 1: Creating and canceling a linear swap (limit) order
try {
const symbol = 'LTC/USDT:USDT';
const type = 'limit';
const side = 'buy';
const amount = 1;
const price = 55;
// placing an order
const order = await exchange.createOrder(symbol, type, side, amount, price);
console.log(order);
// fetching open orders
const openOrders = await exchange.fetchOpenOrders(symbol);
console.log(openOrders);
// canceling an order
const cancel = await exchange.cancelOrder(order['id'], symbol);
console.log(cancel);
}
catch (e) {
console.log(e.constructor.name, e.message);
}
// Example 2: Creating and canceling a linear swap (stop-limit) order with leverage
try {
const symbol = 'LTC/USDT:USDT';
const type = 'limit';
const side = 'buy';
const amount = 1;
const price = 55;
const stopPrice = 130;
const params = {
'stopPrice': stopPrice,
};
//set leverage
const leverage = await exchange.setLeverage(3, symbol);
console.log(leverage);
// placing an order
const order = await exchange.createOrder(symbol, type, side, amount, price, params);
console.log(order);
// canceling an order
const cancelParams = {
isStop: true,
};
const cancel = await exchange.cancelOrder(order['id'], symbol, cancelParams);
console.log(cancel);
//reset leverage
exchange.setLeverage(1, symbol);
}
catch (e) {
console.log(e.constructor.name, e.message);
}
})();(If the page is not being rendered for you, you can refer to the mirror at https://docs.ccxt.com/)
- Install
- Examples
- Manual
- CCXT Pro
- Contributing
- Supported Exchanges
- Exchanges By Country
- API Spec By Method
- FAQ
- Changelog
- Awesome
- API Spec by Exchange
- alpaca
- apex
- aster
- backpack
- bigone
- binance
- bingx
- bit2c
- bitbank
- bitbns
- bitfinex
- bitflyer
- bitget
- bithumb
- bitmex
- bitopro
- bitrue
- bitso
- bitstamp
- bitteam
- bittrade
- bitvavo
- blockchaincom
- blofin
- btcbox
- btcmarkets
- btcturk
- btse
- bullish
- bybit
- bydfi
- cex
- coinbase
- coinbaseexchange
- coinbaseinternational
- coincheck
- coinex
- coinmate
- coinone
- coinsph
- coinspot
- cryptocom
- cryptomus
- deepcoin
- delta
- deribit
- derive
- digifinex
- dydx
- extended
- foxbit
- gate
- gemini
- grvt
- hashkey
- hibachi
- hitbtc
- hollaex
- htx
- hyperliquid
- independentreserve
- indodax
- kraken
- krakenfutures
- kucoin
- kucoinfutures
- latoken
- lbank
- lighter
- luno
- mercado
- mexc
- modetrade
- mudrex
- nado
- ndax
- okx
- onetrading
- p2b
- pacifica
- paradex
- paymium
- phemex
- poloniex
- revolutx
- tokocrypto
- toobit
- upbit
- weex
- whitebit
- woo
- woofipro
- xt
- zaif
- zebpay
- API Spec by Prediction Exchange