@exchange-connect/coinex
Version:
Coinex ( https://www.coinex.com ) SDK
905 lines (904 loc) • 39.2 kB
JavaScript
"use strict";
/**
* @fileOverview Trading API Endpoints
* @module Trading
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.modifyStopOrder = exports.modifyANormalOrder = exports.acquireMarketTransactionInfo = exports.acquireUserTradingFeeRate = exports.cancelAllUnexecutedStopOrders = exports.cancelUnexecutedStopOrder = exports.cancelAllOrders = exports.cancelOrdersInBatch = exports.cancelOrder = exports.inquireUserTransactionRecords = exports.inquireUnexecutedStopOrder = exports.inquireOrderHistory = exports.inquireUnexecutedOrder = exports.inquireStopOrderHistory = exports.inquireExecutedOrderDetail = exports.inquireOrderStatusInBatch = exports.inquireOrderStatus = exports.submitStopMarketOrder = exports.submitStopLimitOrder = exports.submitIOCOrder = exports.submitMarketOrder = exports.submitLimitOrdersInBatch = exports.submitLimitOrder = void 0;
var _a = require("../../constants"), BASE_URLS = _a.BASE_URLS, METHOD_TYPE = _a.METHOD_TYPE;
var executeRequest = require("../../libs").executeRequest;
var signParams = require("../../utils").signParams;
/**
* [Submit Limit Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade001_limit_order}
* @async
* @function submitLimitOrder
* @param {String} amount Order amount, the minimum order amount is determined by the market
* @param {String} market Market name
* @param {"sell"|"buy"} type Operation (sell: ask order, buy: bid order)
* @param {String} price Order price, accurate to 8 decimals
* @param {Object} options Optional Parameters
* @param {String} [options.source_id] User-defined number and return
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.client_id] client_id is the custom ID of the order.Currently it only supports uppercase and lowercase letters, numbers, hyphens and underscores, and within 32 bytes limit.
* @param {"true"|"false"} [options.hide] Whether to hide the submission (true: hidden, false: not hidden)
* @param {"NORMAL"|"IOC"|"FOK"|"MAKER_ONLY"} [options.option] Order strategy (default is NORMAL) (Normal: NORMAL, Immediate or Cancel: IOC, Fill or Kill: FOK, Maker Only: MAKER_ONLY)
* @param {String} [options.access_id] Key ID
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<SubmitLimitOrderResult>} Promise object represents the result of the request
*/
function submitLimitOrder(amount, market, type, price, _a) {
var _b = _a === void 0 ? { tonce: Date.now() } : _a, source_id = _b.source_id, account_id = _b.account_id, client_id = _b.client_id, hide = _b.hide, option = _b.option, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
amount: amount,
market: market,
type: type,
price: price,
source_id: source_id,
account_id: account_id,
client_id: client_id,
hide: hide,
option: option,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/limit",
params: params,
});
}
exports.submitLimitOrder = submitLimitOrder;
/**
* [Submit Limit Orders In Batch]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade002_batch_limit_orders}
* @async
* @function submitLimitOrdersInBatch
* @param {Object[]} batch_orders Multi-order json format string
* @param {"sell"|"buy"} batch_orders[].type Order Direction (sell: Sell Order, buy: Buy Order)
* @param {String} batch_orders[].amount Order amount, the min. order amount is determined by the market
* @param {String} batch_orders[].price Order price, 8-digit decimal
* @param {String} [batch_orders[].source_id] User-Defined ID
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function submitLimitOrdersInBatch(batch_orders, market, _a) {
var _b = _a === void 0 ? { tonce: Date.now() } : _a, account_id = _b.account_id, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
batch_orders: batch_orders,
market: market,
account_id: account_id,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/limit/batch",
params: params,
});
}
exports.submitLimitOrdersInBatch = submitLimitOrdersInBatch;
/**
* [Submit Market Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order}
* @async
* @function submitMarketOrder
* @param {String} market Market name
* @param {"sell"|"buy"} type (sell: ask order, buy: bid order)
* @param {String} amount Order amount, the minimum order amount is determined by the market
* @param {Object} options Optional Parameters
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.client_id] User-defined order id
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function submitMarketOrder(market, type, amount, _a) {
var _b = _a === void 0 ? { tonce: Date.now() } : _a, account_id = _b.account_id, client_id = _b.client_id, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
type: type,
amount: amount,
account_id: account_id,
client_id: client_id,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/market",
params: params,
});
}
exports.submitMarketOrder = submitMarketOrder;
/**
* [Submit IOC Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade004_IOC_order}
* @async
* @function submitIOCOrder
* @param {String} market Market name
* @param {"sell"|"buy"} type (sell: ask order, buy: bid order)
* @param {String} amount Order amount, the minimum order amount is determined by the market
* @param {String} price Order price, determined by the market
* @param {Object} options Optional Parameters
* @param {String} [options.source_id] User-defined id
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.client_id] User-defined Order ID
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function submitIOCOrder(market, type, amount, price, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, source_id = _b.source_id, account_id = _b.account_id, client_id = _b.client_id, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
type: type,
amount: amount,
price: price,
source_id: source_id,
account_id: account_id,
client_id: client_id,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/ioc",
params: params,
});
}
exports.submitIOCOrder = submitIOCOrder;
/**
* [Submit Stop-Limit Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade005_stop_limit_order}
* @async
* @function submitStopLimitOrder
* @param {String} market Market name
* @param {"sell"|"buy"} type Operation (sell: ask order, buy: bid order)
* @param {String} amount Order amount, the minimum order amount is determined by the market
* @param {String} price Order price, accurate to 8 decimals
* @param {String} stop_price Stop price, accurate to 8 decimals
* @param {Object} options Optional Parameters
* @param {String} [options.source_id] User-defined number and return
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.client_id] client_id is the custom ID of the order.Currently it only supports uppercase and lowercase letters, numbers, hyphens and underscores, and within 32 bytes limit.
* @param {"true"|"false"} [options.hide] Whether to hide the submission (true: hidden, false: not hidden)
* @param {"NORMAL"|"IOC"|"FOK"|"MAKER_ONLY"} [options.option] Order strategy (default is NORMAL) (Normal: NORMAL, Immediate or Cancel: IOC, Fill or Kill: FOK, Maker Only: MAKER_ONLY)
* @param {String} [options.access_id] Key ID
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function submitStopLimitOrder(market, type, amount, price, stop_price, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, source_id = _b.source_id, account_id = _b.account_id, client_id = _b.client_id, hide = _b.hide, option = _b.option, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
type: type,
amount: amount,
price: price,
stop_price: stop_price,
source_id: source_id,
account_id: account_id,
client_id: client_id,
hide: hide,
option: option,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/limit",
params: params,
});
}
exports.submitStopLimitOrder = submitStopLimitOrder;
/**
* [Submit Stop-Market Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade006_stop_market_order}
* @async
* @function submitStopMarketOrder
* @param {String} market Market name
* @param {"sell"|"buy"} type Operation (sell: ask order, buy: bid order)
* @param {String} amount Order amount, the minimum order amount is determined by the market
* @param {String} stop_price Stop price, accurate to 8 decimals
* @param {Object} options Optional Parameters
* @param {String} [options.source_id] User-defined number and return
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.client_id] client_id is the custom ID of the order.Currently it only supports uppercase and lowercase letters, numbers, hyphens and underscores, and within 32 bytes limit.
* @param {"true"|"false"} [options.hide] Whether to hide the submission (true: hidden, false: not hidden)
* @param {"NORMAL"|"IOC"|"FOK"|"MAKER_ONLY"} [options.option] Order strategy (default is NORMAL) (Normal: NORMAL, Immediate or Cancel: IOC, Fill or Kill: FOK, Maker Only: MAKER_ONLY)
* @param {String} [options.access_id] Key ID
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function submitStopMarketOrder(market, type, amount, stop_price, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, source_id = _b.source_id, account_id = _b.account_id, client_id = _b.client_id, hide = _b.hide, option = _b.option, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
type: type,
amount: amount,
stop_price: stop_price,
source_id: source_id,
account_id: account_id,
client_id: client_id,
hide: hide,
option: option,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/market",
params: params,
});
}
exports.submitStopMarketOrder = submitStopMarketOrder;
/**
* [Inquire Order Status]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade007_order_status}
* @async
* @function inquireOrderStatus
* @param {String} id Order No.
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {String} [options.access_id] access_id
* @param {String} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
// @ts-ignore
function inquireOrderStatus(id, market, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
id: id,
market: market,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/status",
params: params,
});
}
exports.inquireOrderStatus = inquireOrderStatus;
/**
* [Inquire Order Status In Batch]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade008_batch_orders_status}
* @async
* @function inquireOrderStatusInBatch
* @param {String} batch_ids Order IDs separated by comma, such as : “1,2,3”
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {String} [options.access_id] access_id
* @param {String} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
// @ts-ignore
function inquireOrderStatusInBatch(batch_ids, market, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
batch_ids: batch_ids,
market: market,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/status/batch",
params: params,
});
}
exports.inquireOrderStatusInBatch = inquireOrderStatusInBatch;
/**
* [Inquire Executed Order Detail]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade009_order_deals}
* @async
* @function inquireExecutedOrderDetail
* @param {String} id Order No.
* @param {Object} options Optional Parameters
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {Number} [options.page=1] Page number, starting from 1
* @param {Number} [options.limit=10] Number per page, Max. 100
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function inquireExecutedOrderDetail(id, _a) {
var _b = _a === void 0 ? {
page: 1,
limit: 10,
tonce: Date.now(),
} : _a, account_id = _b.account_id, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
id: id,
account_id: account_id,
page: page,
limit: limit,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/deals",
params: params,
});
}
exports.inquireExecutedOrderDetail = inquireExecutedOrderDetail;
/**
* [Inquire Stop Order History]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade010_stop_finished_order}
* @async
* @function inquireStopOrderHistory
* @param {Object} options Optional Parameters
* @param {String} [options.market] Market name
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {Number} [options.page=1] Page number, starting from 1
* @param {Number} [options.limit=10] Number of entries per page, Max. 100
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function inquireStopOrderHistory(_a) {
var _b = _a === void 0 ? {
page: 1,
limit: 10,
tonce: Date.now(),
} : _a, market = _b.market, account_id = _b.account_id, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
account_id: account_id,
page: page,
limit: limit,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/finished",
params: params,
});
}
exports.inquireStopOrderHistory = inquireStopOrderHistory;
/**
* [Inquire Unexecuted Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade011_pending_order}
* @async
* @function inquireUnexecutedOrder
* @param {"sell"|"buy"} type Operation (sell: ask order, buy: bid order)
* @param {Object} options Optional Parameters
* @param {String} [options.market] Market name
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.client_id] User-defined id
* @param {Number} [options.page=1] Page number, starting from 1
* @param {Number} [options.limit=10] Number of entries per page, Max. 100
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function inquireUnexecutedOrder(type, _a) {
var _b = _a === void 0 ? {
page: 1,
limit: 10,
tonce: Date.now(),
} : _a, market = _b.market, account_id = _b.account_id, client_id = _b.client_id, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
type: type,
market: market,
account_id: account_id,
client_id: client_id,
page: page,
limit: limit,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/pending",
params: params,
});
}
exports.inquireUnexecutedOrder = inquireUnexecutedOrder;
/**
* [Inquire Order History]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade012_finished_order}
* @async
* @function inquireOrderHistory
* @param {Number} start_time Start time
* @param {Number} end_time End time
* @param {Object} options Optional Parameters
* @param {String} [options.market] Market name
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {"sell"|"buy"} [options.type] Operation (sell: ask order, buy: bid order)
* @param {String} [options.client_id] User-defined id
* @param {Number} [options.stop_order_id] Stop order ID
* @param {Number} [options.page=1] Page number, starting from 1
* @param {Number} [options.limit=10] Number of entries per page, Max. 100
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function inquireOrderHistory(start_time, end_time, _a) {
var _b = _a === void 0 ? {
page: 1,
limit: 10,
tonce: Date.now(),
} : _a, market = _b.market, account_id = _b.account_id, type = _b.type, client_id = _b.client_id, stop_order_id = _b.stop_order_id, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
start_time: start_time,
end_time: end_time,
market: market,
account_id: account_id,
type: type,
client_id: client_id,
stop_order_id: stop_order_id,
page: page,
limit: limit,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/finished",
params: params,
});
}
exports.inquireOrderHistory = inquireOrderHistory;
/**
* [Inquire Unexecuted Stop Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade013_stop_pending_order}
* @async
* @function inquireUnexecutedStopOrder
* @param {Object} options Optional Parameters
* @param {String} [options.market] Market name
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {"sell"|"buy"} [options.type] Operation (sell: ask order, buy: bid order)
* @param {Number} [options.page=1] Page number, starting from 1
* @param {Number} [options.limit=10] Number of entries per page, Max. 100
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function inquireUnexecutedStopOrder(_a) {
var _b = _a === void 0 ? {
page: 1,
limit: 10,
tonce: Date.now(),
} : _a, market = _b.market, account_id = _b.account_id, type = _b.type, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
account_id: account_id,
type: type,
page: page,
limit: limit,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/pending",
params: params,
});
}
exports.inquireUnexecutedStopOrder = inquireUnexecutedStopOrder;
/**
* [Inquire User Transaction Records]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade014_user_deals}
* @async
* @function inquireUserTransactionRecords
* @param {Object} options Optional Parameters
* @param {String} [options.market] Market name
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {"sell"|"buy"} [options.type] Operation (sell: ask order, buy: bid order)
* @param {Number} [options.start_time] Start time
* @param {Number} [options.end_time] End Time
* @param {Number} [options.page=1] Page number, starting from 1
* @param {Number} [options.limit=10] Number per page, Max. 100
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function inquireUserTransactionRecords(_a) {
var _b = _a === void 0 ? {
page: 1,
limit: 10,
tonce: Date.now(),
} : _a, market = _b.market, account_id = _b.account_id, type = _b.type, start_time = _b.start_time, end_time = _b.end_time, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
account_id: account_id,
type: type,
start_time: start_time,
end_time: end_time,
page: page,
limit: limit,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/user/deals",
params: params,
});
}
exports.inquireUserTransactionRecords = inquireUserTransactionRecords;
/**
* [Cancel Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade015_cancel_order}
* @async
* @function cancelOrder
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {Number} [options.id] Order ID
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {"sell"|"buy"} [options.type] Operation (sell: ask order, buy: bid order)
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function cancelOrder(market, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, id = _b.id, account_id = _b.account_id, type = _b.type, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
id: id,
account_id: account_id,
type: type,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.DELETE,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/pending",
params: params,
});
}
exports.cancelOrder = cancelOrder;
/**
* [Cancel Orders In Batch]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade016_batch_cancel_order}
* @async
* @function cancelOrdersInBatch
* @param {String} batch_ids Order IDs separated by comma, such as : “1,2,3”
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function cancelOrdersInBatch(batch_ids, market, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, account_id = _b.account_id, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
batch_ids: batch_ids,
market: market,
account_id: account_id,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.DELETE,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/pending/batch",
params: params,
});
}
exports.cancelOrdersInBatch = cancelOrdersInBatch;
/**
* [Cancel All Orders]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade017_cancel_all_orders}
* @async
* @function cancelAllOrders
* @param {String} market Market name
* @param {Number} account_id Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {Object} options Optional Parameters
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function cancelAllOrders(market, account_id, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
account_id: account_id,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.DELETE,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/pending",
params: params,
});
}
exports.cancelAllOrders = cancelAllOrders;
/**
* [Cancel Unexecuted Stop Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade018_cancle_stop_pending_order}
* @async
* @function cancelUnexecutedStopOrder
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {"sell"|"buy"} [options.type] Operation (sell: ask order, buy: bid order)
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function cancelUnexecutedStopOrder(market, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, account_id = _b.account_id, type = _b.type, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
account_id: account_id,
type: type,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.DELETE,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/pending/<int:order_id>",
params: params,
});
}
exports.cancelUnexecutedStopOrder = cancelUnexecutedStopOrder;
/**
* [Cancel All Unexecuted Stop Orders]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade019_cancel_all_stop_pending_order}
* @async
* @function cancelAllUnexecutedStopOrders
* @param {String} market Market name
* @param {Object} options Optional Parameters
* @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See Acquire Market Info in Margin Account
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function cancelAllUnexecutedStopOrders(market, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, account_id = _b.account_id, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
account_id: account_id,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.DELETE,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/pending",
params: params,
});
}
exports.cancelAllUnexecutedStopOrders = cancelAllUnexecutedStopOrders;
/**
* [Acquire User Trading Fee Rate]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade020_user_trade_fee}
* @async
* @function acquireUserTradingFeeRate
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function acquireUserTradingFeeRate() {
// @ts-ignore
var apiSecret = this.apiSecret;
var params = {};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/user/trade/fee",
params: params,
});
}
exports.acquireUserTradingFeeRate = acquireUserTradingFeeRate;
/**
* [Acquire Market Transaction Info]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade021_market_trade_info}
* @async
* @function acquireMarketTransactionInfo
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function acquireMarketTransactionInfo() {
// @ts-ignore
var apiSecret = this.apiSecret;
var params = {};
return executeRequest({
method: METHOD_TYPE.GET,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/market/trade/info",
params: params,
});
}
exports.acquireMarketTransactionInfo = acquireMarketTransactionInfo;
/**
* [Modify a normal order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade022_modify_order}
* @async
* @function modifyanormalorder
* @param {String} market Market name
* @param {String} id Order No.
* @param {Object} options Optional Parameters
* @param {String} [options.amount] Order amount, the minimum order amount is determined by the market
* @param {String} [options.price] Order price, determined by the market
* @param {String} [options.access_id] access_id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function modifyANormalOrder(market, id, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, amount = _b.amount, price = _b.price, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
id: id,
amount: amount,
price: price,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/modify",
params: params,
});
}
exports.modifyANormalOrder = modifyANormalOrder;
/**
* [Modify Stop Order]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade023_modify_stop_order}
* @async
* @function modifyStopOrder
* @param {String} market Market name
* @param {String} id Order No.
* @param {Object} options Optional Parameters
* @param {String} [options.amount] Order amount, the minimum order amount is determined by the market
* @param {String} [options.price] Order price, accurate to 8 decimals
* @param {String} [options.stop_price] Stop price, accurate to 8 decimals
* @param {String} [options.access_id] Key Id
* @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s
* @returns {Promise<Object>} Promise object represents the result of the request
*/
function modifyStopOrder(market, id, _a) {
var _b = _a === void 0 ? {
tonce: Date.now(),
} : _a, amount = _b.amount, price = _b.price, stop_price = _b.stop_price, access_id = _b.access_id, tonce = _b.tonce;
// @ts-ignore
var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret;
var params = {
market: market,
id: id,
amount: amount,
price: price,
stop_price: stop_price,
access_id: access_id ? access_id : apiKey,
tonce: tonce,
};
return executeRequest({
method: METHOD_TYPE.POST,
baseURL: BASE_URLS.GENERAL,
headers: {
authorization: signParams(apiSecret, params),
},
url: "/order/stop/modify",
params: params,
});
}
exports.modifyStopOrder = modifyStopOrder;