ccxt 4.2.34 → 4.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.js +520 -182
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +10 -2
- package/dist/cjs/src/base/ws/Client.js +5 -2
- package/dist/cjs/src/binance.js +335 -94
- package/dist/cjs/src/bitfinex.js +21 -0
- package/dist/cjs/src/bitfinex2.js +12 -1
- package/dist/cjs/src/bitget.js +28 -39
- package/dist/cjs/src/bithumb.js +14 -0
- package/dist/cjs/src/krakenfutures.js +25 -3
- package/dist/cjs/src/pro/binance.js +5 -5
- package/dist/cjs/src/woo.js +64 -35
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.js +10 -2
- package/js/src/base/ws/Client.js +5 -2
- package/js/src/binance.js +335 -94
- package/js/src/bitfinex.js +21 -0
- package/js/src/bitfinex2.js +12 -1
- package/js/src/bitget.js +28 -39
- package/js/src/bithumb.js +14 -0
- package/js/src/krakenfutures.js +25 -3
- package/js/src/pro/binance.js +5 -5
- package/js/src/woo.js +64 -35
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -8464,6 +8464,9 @@ class Exchange {
|
|
|
8464
8464
|
* @returns {object | undefined}
|
|
8465
8465
|
*/
|
|
8466
8466
|
const value = this.safeValueN(dictionaryOrList, keys, defaultValue);
|
|
8467
|
+
if (value === undefined) {
|
|
8468
|
+
return defaultValue;
|
|
8469
|
+
}
|
|
8467
8470
|
if (typeof value === 'object') {
|
|
8468
8471
|
return value;
|
|
8469
8472
|
}
|
|
@@ -8495,6 +8498,9 @@ class Exchange {
|
|
|
8495
8498
|
* @returns {Array | undefined}
|
|
8496
8499
|
*/
|
|
8497
8500
|
const value = this.safeValueN(dictionaryOrList, keys, defaultValue);
|
|
8501
|
+
if (value === undefined) {
|
|
8502
|
+
return defaultValue;
|
|
8503
|
+
}
|
|
8498
8504
|
if (Array.isArray(value)) {
|
|
8499
8505
|
return value;
|
|
8500
8506
|
}
|
|
@@ -12294,7 +12300,8 @@ class Exchange {
|
|
|
12294
12300
|
errors = 0;
|
|
12295
12301
|
const responseLength = response.length;
|
|
12296
12302
|
if (this.verbose) {
|
|
12297
|
-
const
|
|
12303
|
+
const iteration = (i + 1).toString();
|
|
12304
|
+
const cursorMessage = 'Cursor pagination call ' + iteration + ' method ' + method + ' response length ' + responseLength.toString() + ' cursor ' + cursorValue;
|
|
12298
12305
|
this.log(cursorMessage);
|
|
12299
12306
|
}
|
|
12300
12307
|
if (responseLength === 0) {
|
|
@@ -12339,7 +12346,8 @@ class Exchange {
|
|
|
12339
12346
|
errors = 0;
|
|
12340
12347
|
const responseLength = response.length;
|
|
12341
12348
|
if (this.verbose) {
|
|
12342
|
-
const
|
|
12349
|
+
const iteration = (i + 1).toString();
|
|
12350
|
+
const incrementalMessage = 'Incremental pagination call ' + iteration + ' method ' + method + ' response length ' + responseLength.toString();
|
|
12343
12351
|
this.log(incrementalMessage);
|
|
12344
12352
|
}
|
|
12345
12353
|
if (responseLength === 0) {
|
|
@@ -14956,9 +14964,12 @@ class Client {
|
|
|
14956
14964
|
this.onError(new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.RequestTimeout('Connection to ' + this.url + ' timed out due to a ping-pong keepalive missing on time'));
|
|
14957
14965
|
}
|
|
14958
14966
|
else {
|
|
14967
|
+
let message;
|
|
14959
14968
|
if (this.ping) {
|
|
14960
|
-
this.
|
|
14961
|
-
|
|
14969
|
+
message = this.ping(this);
|
|
14970
|
+
}
|
|
14971
|
+
if (message) {
|
|
14972
|
+
this.send(message).catch((error) => {
|
|
14962
14973
|
this.onError(error);
|
|
14963
14974
|
});
|
|
14964
14975
|
}
|
|
@@ -21088,9 +21099,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21088
21099
|
let timestamp = undefined;
|
|
21089
21100
|
const isolated = marginMode === 'isolated';
|
|
21090
21101
|
const cross = (type === 'margin') || (marginMode === 'cross');
|
|
21091
|
-
if (
|
|
21102
|
+
if (type === 'papi') {
|
|
21103
|
+
for (let i = 0; i < response.length; i++) {
|
|
21104
|
+
const entry = response[i];
|
|
21105
|
+
const account = this.account();
|
|
21106
|
+
const currencyId = this.safeString(entry, 'asset');
|
|
21107
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
21108
|
+
const borrowed = this.safeString(entry, 'crossMarginBorrowed');
|
|
21109
|
+
const interest = this.safeString(entry, 'crossMarginInterest');
|
|
21110
|
+
account['free'] = this.safeString(entry, 'crossMarginFree');
|
|
21111
|
+
account['used'] = this.safeString(entry, 'crossMarginLocked');
|
|
21112
|
+
account['total'] = this.safeString(entry, 'crossMarginAsset');
|
|
21113
|
+
account['debt'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(borrowed, interest);
|
|
21114
|
+
result[code] = account;
|
|
21115
|
+
}
|
|
21116
|
+
}
|
|
21117
|
+
else if (!isolated && ((type === 'spot') || cross)) {
|
|
21092
21118
|
timestamp = this.safeInteger(response, 'updateTime');
|
|
21093
|
-
const balances = this.
|
|
21119
|
+
const balances = this.safeList2(response, 'balances', 'userAssets', []);
|
|
21094
21120
|
for (let i = 0; i < balances.length; i++) {
|
|
21095
21121
|
const balance = balances[i];
|
|
21096
21122
|
const currencyId = this.safeString(balance, 'asset');
|
|
@@ -21107,13 +21133,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21107
21133
|
}
|
|
21108
21134
|
}
|
|
21109
21135
|
else if (isolated) {
|
|
21110
|
-
const assets = this.
|
|
21136
|
+
const assets = this.safeList(response, 'assets');
|
|
21111
21137
|
for (let i = 0; i < assets.length; i++) {
|
|
21112
21138
|
const asset = assets[i];
|
|
21113
|
-
const marketId = this.
|
|
21139
|
+
const marketId = this.safeString(asset, 'symbol');
|
|
21114
21140
|
const symbol = this.safeSymbol(marketId, undefined, undefined, 'spot');
|
|
21115
|
-
const base = this.
|
|
21116
|
-
const quote = this.
|
|
21141
|
+
const base = this.safeDict(asset, 'baseAsset', {});
|
|
21142
|
+
const quote = this.safeDict(asset, 'quoteAsset', {});
|
|
21117
21143
|
const baseCode = this.safeCurrencyCode(this.safeString(base, 'asset'));
|
|
21118
21144
|
const quoteCode = this.safeCurrencyCode(this.safeString(quote, 'asset'));
|
|
21119
21145
|
const subResult = {};
|
|
@@ -21123,7 +21149,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21123
21149
|
}
|
|
21124
21150
|
}
|
|
21125
21151
|
else if (type === 'savings') {
|
|
21126
|
-
const positionAmountVos = this.
|
|
21152
|
+
const positionAmountVos = this.safeList(response, 'positionAmountVos', []);
|
|
21127
21153
|
for (let i = 0; i < positionAmountVos.length; i++) {
|
|
21128
21154
|
const entry = positionAmountVos[i];
|
|
21129
21155
|
const currencyId = this.safeString(entry, 'asset');
|
|
@@ -21152,7 +21178,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21152
21178
|
else {
|
|
21153
21179
|
let balances = response;
|
|
21154
21180
|
if (!Array.isArray(response)) {
|
|
21155
|
-
balances = this.
|
|
21181
|
+
balances = this.safeList(response, 'assets', []);
|
|
21156
21182
|
}
|
|
21157
21183
|
for (let i = 0; i < balances.length; i++) {
|
|
21158
21184
|
const balance = balances[i];
|
|
@@ -21182,10 +21208,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21182
21208
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data // swap
|
|
21183
21209
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data // future
|
|
21184
21210
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#option-account-information-trade // option
|
|
21211
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#account-balance-user_data // portfolio margin
|
|
21185
21212
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
21186
|
-
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot'
|
|
21213
|
+
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi'
|
|
21187
21214
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
|
|
21188
21215
|
* @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
|
|
21216
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
|
|
21189
21217
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
21190
21218
|
*/
|
|
21191
21219
|
await this.loadMarkets();
|
|
@@ -21193,13 +21221,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21193
21221
|
let type = this.safeString(params, 'type', defaultType);
|
|
21194
21222
|
let subType = undefined;
|
|
21195
21223
|
[subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
|
|
21224
|
+
let isPortfolioMargin = undefined;
|
|
21225
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchBalance', 'papi', 'portfolioMargin', false);
|
|
21196
21226
|
let marginMode = undefined;
|
|
21197
21227
|
let query = undefined;
|
|
21198
21228
|
[marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
21199
21229
|
query = this.omit(query, 'type');
|
|
21200
21230
|
let response = undefined;
|
|
21201
21231
|
const request = {};
|
|
21202
|
-
if (
|
|
21232
|
+
if (isPortfolioMargin || (type === 'papi')) {
|
|
21233
|
+
type = 'papi';
|
|
21234
|
+
response = await this.papiGetBalance(this.extend(request, query));
|
|
21235
|
+
}
|
|
21236
|
+
else if (this.isLinear(type, subType)) {
|
|
21203
21237
|
type = 'linear';
|
|
21204
21238
|
response = await this.fapiPrivateV2GetAccount(this.extend(request, query));
|
|
21205
21239
|
}
|
|
@@ -21208,7 +21242,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21208
21242
|
response = await this.dapiPrivateGetAccount(this.extend(request, query));
|
|
21209
21243
|
}
|
|
21210
21244
|
else if (marginMode === 'isolated') {
|
|
21211
|
-
const paramSymbols = this.
|
|
21245
|
+
const paramSymbols = this.safeList(params, 'symbols');
|
|
21212
21246
|
query = this.omit(query, 'symbols');
|
|
21213
21247
|
if (paramSymbols !== undefined) {
|
|
21214
21248
|
let symbols = '';
|
|
@@ -21424,6 +21458,26 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21424
21458
|
// }
|
|
21425
21459
|
// ]
|
|
21426
21460
|
//
|
|
21461
|
+
// portfolio margin
|
|
21462
|
+
//
|
|
21463
|
+
// [
|
|
21464
|
+
// {
|
|
21465
|
+
// "asset": "USDT",
|
|
21466
|
+
// "totalWalletBalance": "66.9923261",
|
|
21467
|
+
// "crossMarginAsset": "35.9697141",
|
|
21468
|
+
// "crossMarginBorrowed": "0.0",
|
|
21469
|
+
// "crossMarginFree": "35.9697141",
|
|
21470
|
+
// "crossMarginInterest": "0.0",
|
|
21471
|
+
// "crossMarginLocked": "0.0",
|
|
21472
|
+
// "umWalletBalance": "31.022612",
|
|
21473
|
+
// "umUnrealizedPNL": "0.0",
|
|
21474
|
+
// "cmWalletBalance": "0.0",
|
|
21475
|
+
// "cmUnrealizedPNL": "0.0",
|
|
21476
|
+
// "updateTime": 0,
|
|
21477
|
+
// "negativeBalance": "0.0"
|
|
21478
|
+
// },
|
|
21479
|
+
// ]
|
|
21480
|
+
//
|
|
21427
21481
|
return this.parseBalanceCustom(response, type, marginMode);
|
|
21428
21482
|
}
|
|
21429
21483
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
@@ -22637,7 +22691,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
22637
22691
|
}
|
|
22638
22692
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
22639
22693
|
}
|
|
22640
|
-
if (timeInForceIsRequired) {
|
|
22694
|
+
if (timeInForceIsRequired && (this.safeString(params, 'timeInForce') === undefined)) {
|
|
22641
22695
|
request['timeInForce'] = this.options['defaultTimeInForce']; // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
|
|
22642
22696
|
}
|
|
22643
22697
|
if (stopPriceIsRequired) {
|
|
@@ -22942,18 +22996,128 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
22942
22996
|
// "lastTrade": {"id":"69","time":"1676084430567","price":"24.9","qty":"1.00"},
|
|
22943
22997
|
// "mmp": false
|
|
22944
22998
|
// }
|
|
22945
|
-
//
|
|
22999
|
+
//
|
|
22946
23000
|
// cancelOrders/createOrders
|
|
22947
|
-
//
|
|
22948
|
-
//
|
|
22949
|
-
//
|
|
23001
|
+
//
|
|
23002
|
+
// {
|
|
23003
|
+
// "code": -4005,
|
|
23004
|
+
// "msg": "Quantity greater than max quantity."
|
|
23005
|
+
// }
|
|
23006
|
+
//
|
|
23007
|
+
// createOrder: portfolio margin linear swap and future
|
|
23008
|
+
//
|
|
23009
|
+
// {
|
|
23010
|
+
// "symbol": "BTCUSDT",
|
|
23011
|
+
// "side": "BUY",
|
|
23012
|
+
// "executedQty": "0.000",
|
|
23013
|
+
// "orderId": 258649539704,
|
|
23014
|
+
// "goodTillDate": 0,
|
|
23015
|
+
// "avgPrice": "0",
|
|
23016
|
+
// "origQty": "0.010",
|
|
23017
|
+
// "clientOrderId": "x-xcKtGhcu02573c6f15e544e990057b",
|
|
23018
|
+
// "positionSide": "BOTH",
|
|
23019
|
+
// "cumQty": "0.000",
|
|
23020
|
+
// "updateTime": 1707110415436,
|
|
23021
|
+
// "type": "LIMIT",
|
|
23022
|
+
// "reduceOnly": false,
|
|
23023
|
+
// "price": "35000.00",
|
|
23024
|
+
// "cumQuote": "0.00000",
|
|
23025
|
+
// "selfTradePreventionMode": "NONE",
|
|
23026
|
+
// "timeInForce": "GTC",
|
|
23027
|
+
// "status": "NEW"
|
|
23028
|
+
// }
|
|
23029
|
+
//
|
|
23030
|
+
// createOrder: portfolio margin inverse swap and future
|
|
23031
|
+
//
|
|
23032
|
+
// {
|
|
23033
|
+
// "symbol": "ETHUSD_PERP",
|
|
23034
|
+
// "side": "BUY",
|
|
23035
|
+
// "cumBase": "0",
|
|
23036
|
+
// "executedQty": "0",
|
|
23037
|
+
// "orderId": 71275227732,
|
|
23038
|
+
// "avgPrice": "0.00",
|
|
23039
|
+
// "origQty": "1",
|
|
23040
|
+
// "clientOrderId": "x-xcKtGhcuca5af3acfb5044198c5398",
|
|
23041
|
+
// "positionSide": "BOTH",
|
|
23042
|
+
// "cumQty": "0",
|
|
23043
|
+
// "updateTime": 1707110994334,
|
|
23044
|
+
// "type": "LIMIT",
|
|
23045
|
+
// "pair": "ETHUSD",
|
|
23046
|
+
// "reduceOnly": false,
|
|
23047
|
+
// "price": "2000",
|
|
23048
|
+
// "timeInForce": "GTC",
|
|
23049
|
+
// "status": "NEW"
|
|
23050
|
+
// }
|
|
23051
|
+
//
|
|
23052
|
+
// createOrder: portfolio margin linear swap and future conditional
|
|
23053
|
+
//
|
|
23054
|
+
// {
|
|
23055
|
+
// "newClientStrategyId": "x-xcKtGhcu27f109953d6e4dc0974006",
|
|
23056
|
+
// "strategyId": 3645916,
|
|
23057
|
+
// "strategyStatus": "NEW",
|
|
23058
|
+
// "strategyType": "STOP",
|
|
23059
|
+
// "origQty": "0.010",
|
|
23060
|
+
// "price": "35000.00",
|
|
23061
|
+
// "reduceOnly": false,
|
|
23062
|
+
// "side": "BUY",
|
|
23063
|
+
// "positionSide": "BOTH",
|
|
23064
|
+
// "stopPrice": "45000.00",
|
|
23065
|
+
// "symbol": "BTCUSDT",
|
|
23066
|
+
// "timeInForce": "GTC",
|
|
23067
|
+
// "bookTime": 1707112625879,
|
|
23068
|
+
// "updateTime": 1707112625879,
|
|
23069
|
+
// "workingType": "CONTRACT_PRICE",
|
|
23070
|
+
// "priceProtect": false,
|
|
23071
|
+
// "goodTillDate": 0,
|
|
23072
|
+
// "selfTradePreventionMode": "NONE"
|
|
23073
|
+
// }
|
|
23074
|
+
//
|
|
23075
|
+
// createOrder: portfolio margin inverse swap and future conditional
|
|
23076
|
+
//
|
|
23077
|
+
// {
|
|
23078
|
+
// "newClientStrategyId": "x-xcKtGhcuc6b86f053bb34933850739",
|
|
23079
|
+
// "strategyId": 1423462,
|
|
23080
|
+
// "strategyStatus": "NEW",
|
|
23081
|
+
// "strategyType": "STOP",
|
|
23082
|
+
// "origQty": "1",
|
|
23083
|
+
// "price": "2000",
|
|
23084
|
+
// "reduceOnly": false,
|
|
23085
|
+
// "side": "BUY",
|
|
23086
|
+
// "positionSide": "BOTH",
|
|
23087
|
+
// "stopPrice": "3000",
|
|
23088
|
+
// "symbol": "ETHUSD_PERP",
|
|
23089
|
+
// "timeInForce": "GTC",
|
|
23090
|
+
// "bookTime": 1707113098840,
|
|
23091
|
+
// "updateTime": 1707113098840,
|
|
23092
|
+
// "workingType": "CONTRACT_PRICE",
|
|
23093
|
+
// "priceProtect": false
|
|
23094
|
+
// }
|
|
23095
|
+
//
|
|
23096
|
+
// createOrder: portfolio margin spot margin
|
|
23097
|
+
//
|
|
23098
|
+
// {
|
|
23099
|
+
// "clientOrderId": "x-R4BD3S82e9ef29d8346440f0b28b86",
|
|
23100
|
+
// "cummulativeQuoteQty": "0.00000000",
|
|
23101
|
+
// "executedQty": "0.00000000",
|
|
23102
|
+
// "fills": [],
|
|
23103
|
+
// "orderId": 24684460474,
|
|
23104
|
+
// "origQty": "0.00100000",
|
|
23105
|
+
// "price": "35000.00000000",
|
|
23106
|
+
// "selfTradePreventionMode": "EXPIRE_MAKER",
|
|
23107
|
+
// "side": "BUY",
|
|
23108
|
+
// "status": "NEW",
|
|
23109
|
+
// "symbol": "BTCUSDT",
|
|
23110
|
+
// "timeInForce": "GTC",
|
|
23111
|
+
// "transactTime": 1707113538870,
|
|
23112
|
+
// "type": "LIMIT"
|
|
23113
|
+
// }
|
|
22950
23114
|
//
|
|
22951
23115
|
const code = this.safeString(order, 'code');
|
|
22952
23116
|
if (code !== undefined) {
|
|
22953
23117
|
// cancelOrders/createOrders might have a partial success
|
|
22954
23118
|
return this.safeOrder({ 'info': order, 'status': 'rejected' }, market);
|
|
22955
23119
|
}
|
|
22956
|
-
const status = this.parseOrderStatus(this.
|
|
23120
|
+
const status = this.parseOrderStatus(this.safeString2(order, 'status', 'strategyStatus'));
|
|
22957
23121
|
const marketId = this.safeString(order, 'symbol');
|
|
22958
23122
|
const marketType = ('closePosition' in order) ? 'contract' : 'spot';
|
|
22959
23123
|
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
@@ -22980,11 +23144,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
22980
23144
|
// Note this is not the actual cost, since Binance futures uses leverage to calculate margins.
|
|
22981
23145
|
let cost = this.safeString2(order, 'cummulativeQuoteQty', 'cumQuote');
|
|
22982
23146
|
cost = this.safeString(order, 'cumBase', cost);
|
|
22983
|
-
const id = this.safeString(order, 'orderId');
|
|
22984
23147
|
let type = this.safeStringLower(order, 'type');
|
|
22985
23148
|
const side = this.safeStringLower(order, 'side');
|
|
22986
23149
|
const fills = this.safeValue(order, 'fills', []);
|
|
22987
|
-
const clientOrderId = this.safeString(order, 'clientOrderId');
|
|
22988
23150
|
let timeInForce = this.safeString(order, 'timeInForce');
|
|
22989
23151
|
if (timeInForce === 'GTX') {
|
|
22990
23152
|
// GTX means "Good Till Crossing" and is an equivalent way of saying Post Only
|
|
@@ -23007,8 +23169,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23007
23169
|
}
|
|
23008
23170
|
return this.safeOrder({
|
|
23009
23171
|
'info': order,
|
|
23010
|
-
'id':
|
|
23011
|
-
'clientOrderId': clientOrderId,
|
|
23172
|
+
'id': this.safeString2(order, 'orderId', 'strategyId'),
|
|
23173
|
+
'clientOrderId': this.safeString2(order, 'clientOrderId', 'newClientStrategyId'),
|
|
23012
23174
|
'timestamp': timestamp,
|
|
23013
23175
|
'datetime': this.iso8601(timestamp),
|
|
23014
23176
|
'lastTradeTimestamp': lastTradeTimestamp,
|
|
@@ -23122,50 +23284,105 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23122
23284
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#new-order-trade
|
|
23123
23285
|
* @see https://binance-docs.github.io/apidocs/spot/en/#new-order-using-sor-trade
|
|
23124
23286
|
* @see https://binance-docs.github.io/apidocs/spot/en/#test-new-order-using-sor-trade
|
|
23287
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#new-um-order-trade
|
|
23288
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#new-cm-order-trade
|
|
23289
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#new-margin-order-trade
|
|
23290
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#new-um-conditional-order-trade
|
|
23291
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#new-cm-conditional-order-trade
|
|
23125
23292
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
23126
23293
|
* @param {string} type 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
|
|
23127
23294
|
* @param {string} side 'buy' or 'sell'
|
|
23128
|
-
* @param {float} amount how much of
|
|
23129
|
-
* @param {float} [price] the price
|
|
23295
|
+
* @param {float} amount how much of you want to trade in units of the base currency
|
|
23296
|
+
* @param {float} [price] the price that the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
23130
23297
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
23298
|
+
* @param {string} [params.reduceOnly] for swap and future reduceOnly is a string 'true' or 'false' that cant be sent with close position set to true or in hedge mode. For spot margin and option reduceOnly is a boolean.
|
|
23131
23299
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
|
23132
23300
|
* @param {boolean} [params.sor] *spot only* whether to use SOR (Smart Order Routing) or not, default is false
|
|
23133
23301
|
* @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
|
|
23134
23302
|
* @param {float} [params.trailingPercent] the percent to trail away from the current market price
|
|
23135
23303
|
* @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
23304
|
+
* @param {float} [params.triggerPrice] the price that a trigger order is triggered at
|
|
23305
|
+
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
|
|
23306
|
+
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
|
|
23307
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
|
|
23136
23308
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
23137
23309
|
*/
|
|
23138
23310
|
await this.loadMarkets();
|
|
23139
23311
|
const market = this.market(symbol);
|
|
23140
23312
|
const marketType = this.safeString(params, 'type', market['type']);
|
|
23141
|
-
|
|
23142
|
-
|
|
23143
|
-
|
|
23313
|
+
let marginMode = undefined;
|
|
23314
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
23315
|
+
let isPortfolioMargin = undefined;
|
|
23316
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'createOrder', 'papi', 'portfolioMargin', false);
|
|
23317
|
+
const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
|
|
23318
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
23319
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
23320
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
23321
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
23322
|
+
const isStopLoss = stopLossPrice !== undefined;
|
|
23323
|
+
const isTakeProfit = takeProfitPrice !== undefined;
|
|
23324
|
+
const isConditional = (triggerPrice !== undefined) || isTrailingPercentOrder || isStopLoss || isTakeProfit;
|
|
23325
|
+
const sor = this.safeBool2(params, 'sor', 'SOR', false);
|
|
23326
|
+
const test = this.safeBool(params, 'test', false);
|
|
23327
|
+
params = this.omit(params, ['sor', 'SOR', 'test']);
|
|
23328
|
+
if (isPortfolioMargin) {
|
|
23329
|
+
params['portfolioMargin'] = isPortfolioMargin;
|
|
23330
|
+
}
|
|
23144
23331
|
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
23145
|
-
let
|
|
23146
|
-
if (
|
|
23147
|
-
|
|
23332
|
+
let response = undefined;
|
|
23333
|
+
if (market['option']) {
|
|
23334
|
+
response = await this.eapiPrivatePostOrder(request);
|
|
23335
|
+
}
|
|
23336
|
+
else if (sor) {
|
|
23337
|
+
if (test) {
|
|
23338
|
+
response = await this.privatePostSorOrderTest(request);
|
|
23339
|
+
}
|
|
23340
|
+
else {
|
|
23341
|
+
response = await this.privatePostSorOrder(request);
|
|
23342
|
+
}
|
|
23148
23343
|
}
|
|
23149
23344
|
else if (market['linear']) {
|
|
23150
|
-
|
|
23345
|
+
if (isPortfolioMargin) {
|
|
23346
|
+
if (isConditional) {
|
|
23347
|
+
response = await this.papiPostUmConditionalOrder(request);
|
|
23348
|
+
}
|
|
23349
|
+
else {
|
|
23350
|
+
response = await this.papiPostUmOrder(request);
|
|
23351
|
+
}
|
|
23352
|
+
}
|
|
23353
|
+
else {
|
|
23354
|
+
response = await this.fapiPrivatePostOrder(request);
|
|
23355
|
+
}
|
|
23151
23356
|
}
|
|
23152
23357
|
else if (market['inverse']) {
|
|
23153
|
-
|
|
23358
|
+
if (isPortfolioMargin) {
|
|
23359
|
+
if (isConditional) {
|
|
23360
|
+
response = await this.papiPostCmConditionalOrder(request);
|
|
23361
|
+
}
|
|
23362
|
+
else {
|
|
23363
|
+
response = await this.papiPostCmOrder(request);
|
|
23364
|
+
}
|
|
23365
|
+
}
|
|
23366
|
+
else {
|
|
23367
|
+
response = await this.dapiPrivatePostOrder(request);
|
|
23368
|
+
}
|
|
23154
23369
|
}
|
|
23155
23370
|
else if (marketType === 'margin' || marginMode !== undefined) {
|
|
23156
|
-
|
|
23157
|
-
|
|
23158
|
-
|
|
23159
|
-
|
|
23371
|
+
if (isPortfolioMargin) {
|
|
23372
|
+
response = await this.papiPostMarginOrder(request);
|
|
23373
|
+
}
|
|
23374
|
+
else {
|
|
23375
|
+
response = await this.sapiPostMarginOrder(request);
|
|
23376
|
+
}
|
|
23160
23377
|
}
|
|
23161
|
-
|
|
23162
|
-
if (market['spot'] || marketType === 'margin') {
|
|
23163
|
-
const test = this.safeBool(query, 'test', false);
|
|
23378
|
+
else {
|
|
23164
23379
|
if (test) {
|
|
23165
|
-
|
|
23380
|
+
response = await this.privatePostOrderTest(request);
|
|
23381
|
+
}
|
|
23382
|
+
else {
|
|
23383
|
+
response = await this.privatePostOrder(request);
|
|
23166
23384
|
}
|
|
23167
23385
|
}
|
|
23168
|
-
const response = await this[method](request);
|
|
23169
23386
|
return this.parseOrder(response, market);
|
|
23170
23387
|
}
|
|
23171
23388
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -23173,16 +23390,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23173
23390
|
* @method
|
|
23174
23391
|
* @ignore
|
|
23175
23392
|
* @name binance#createOrderRequest
|
|
23176
|
-
* @description helper function to build request
|
|
23393
|
+
* @description helper function to build the request
|
|
23177
23394
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
23178
|
-
* @param {string} type 'market' or 'limit'
|
|
23395
|
+
* @param {string} type 'market' or 'limit'
|
|
23179
23396
|
* @param {string} side 'buy' or 'sell'
|
|
23180
|
-
* @param {float} amount how much
|
|
23181
|
-
* @param {float
|
|
23182
|
-
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
23183
|
-
* @param {string|undefined} params.marginMode 'cross' or 'isolated', for spot margin trading
|
|
23184
|
-
* @param {float} [params.trailingPercent] the percent to trail away from the current market price
|
|
23185
|
-
* @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
23397
|
+
* @param {float} amount how much you want to trade in units of the base currency
|
|
23398
|
+
* @param {float} [price] the price that the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
23399
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
23186
23400
|
* @returns {object} request to be sent to the exchange
|
|
23187
23401
|
*/
|
|
23188
23402
|
const market = this.market(symbol);
|
|
@@ -23191,35 +23405,54 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23191
23405
|
const initialUppercaseType = type.toUpperCase();
|
|
23192
23406
|
const isMarketOrder = initialUppercaseType === 'MARKET';
|
|
23193
23407
|
const isLimitOrder = initialUppercaseType === 'LIMIT';
|
|
23194
|
-
const postOnly = this.isPostOnly(isMarketOrder, initialUppercaseType === 'LIMIT_MAKER', params);
|
|
23195
|
-
const triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
|
|
23196
|
-
const stopLossPrice = this.safeValue(params, 'stopLossPrice', triggerPrice); // fallback to stopLoss
|
|
23197
|
-
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
23198
|
-
const trailingDelta = this.safeValue(params, 'trailingDelta');
|
|
23199
|
-
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', this.numberToString(price));
|
|
23200
|
-
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
23201
|
-
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
23202
|
-
const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
|
|
23203
|
-
const isTakeProfit = takeProfitPrice !== undefined;
|
|
23204
|
-
params = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent']);
|
|
23205
|
-
const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
|
|
23206
23408
|
const request = {
|
|
23207
23409
|
'symbol': market['id'],
|
|
23208
23410
|
'side': side.toUpperCase(),
|
|
23209
23411
|
};
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23412
|
+
let isPortfolioMargin = undefined;
|
|
23413
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'createOrder', 'papi', 'portfolioMargin', false);
|
|
23414
|
+
let marginMode = undefined;
|
|
23415
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
23416
|
+
if ((marketType === 'margin') || (marginMode !== undefined) || market['option']) {
|
|
23417
|
+
// for swap and future reduceOnly is a string that cant be sent with close position set to true or in hedge mode
|
|
23418
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
23419
|
+
params = this.omit(params, 'reduceOnly');
|
|
23420
|
+
if (market['option']) {
|
|
23421
|
+
request['reduceOnly'] = reduceOnly;
|
|
23422
|
+
}
|
|
23423
|
+
else {
|
|
23424
|
+
if (reduceOnly) {
|
|
23425
|
+
request['sideEffectType'] = 'AUTO_REPAY';
|
|
23426
|
+
}
|
|
23214
23427
|
}
|
|
23215
23428
|
}
|
|
23216
|
-
if (
|
|
23217
|
-
const
|
|
23218
|
-
if (
|
|
23219
|
-
|
|
23220
|
-
|
|
23429
|
+
if (!isPortfolioMargin) {
|
|
23430
|
+
const postOnly = this.isPostOnly(isMarketOrder, initialUppercaseType === 'LIMIT_MAKER', params);
|
|
23431
|
+
if (market['spot'] || marketType === 'margin') {
|
|
23432
|
+
// only supported for spot/margin api (all margin markets are spot markets)
|
|
23433
|
+
if (postOnly) {
|
|
23434
|
+
type = 'LIMIT_MAKER';
|
|
23435
|
+
}
|
|
23436
|
+
if (marginMode === 'isolated') {
|
|
23437
|
+
request['isIsolated'] = true;
|
|
23438
|
+
}
|
|
23439
|
+
}
|
|
23440
|
+
if (market['contract'] && postOnly) {
|
|
23441
|
+
request['timeInForce'] = 'GTX';
|
|
23221
23442
|
}
|
|
23222
23443
|
}
|
|
23444
|
+
const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
|
|
23445
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice', triggerPrice); // fallback to stopLoss
|
|
23446
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
23447
|
+
const trailingDelta = this.safeString(params, 'trailingDelta');
|
|
23448
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', this.numberToString(price));
|
|
23449
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
23450
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
23451
|
+
const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
|
|
23452
|
+
const isTakeProfit = takeProfitPrice !== undefined;
|
|
23453
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
23454
|
+
const isConditional = isTriggerOrder || isTrailingPercentOrder || isStopLoss || isTakeProfit;
|
|
23455
|
+
const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
|
|
23223
23456
|
let uppercaseType = type.toUpperCase();
|
|
23224
23457
|
let stopPrice = undefined;
|
|
23225
23458
|
if (isTrailingPercentOrder) {
|
|
@@ -23249,24 +23482,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23249
23482
|
uppercaseType = market['contract'] ? 'TAKE_PROFIT' : 'TAKE_PROFIT_LIMIT';
|
|
23250
23483
|
}
|
|
23251
23484
|
}
|
|
23252
|
-
if (marginMode === 'isolated') {
|
|
23253
|
-
request['isIsolated'] = true;
|
|
23254
|
-
}
|
|
23255
|
-
if (clientOrderId === undefined) {
|
|
23256
|
-
const broker = this.safeValue(this.options, 'broker', {});
|
|
23257
|
-
const defaultId = (market['contract']) ? 'x-xcKtGhcu' : 'x-R4BD3S82';
|
|
23258
|
-
const brokerId = this.safeString(broker, marketType, defaultId);
|
|
23259
|
-
request['newClientOrderId'] = brokerId + this.uuid22();
|
|
23260
|
-
}
|
|
23261
|
-
else {
|
|
23262
|
-
request['newClientOrderId'] = clientOrderId;
|
|
23263
|
-
}
|
|
23264
23485
|
if ((marketType === 'spot') || (marketType === 'margin')) {
|
|
23265
|
-
request['newOrderRespType'] = this.
|
|
23486
|
+
request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'RESULT'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
|
|
23266
23487
|
}
|
|
23267
23488
|
else {
|
|
23268
23489
|
// swap, futures and options
|
|
23269
|
-
|
|
23490
|
+
if (!isPortfolioMargin) {
|
|
23491
|
+
request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
|
|
23492
|
+
}
|
|
23270
23493
|
}
|
|
23271
23494
|
if (market['option']) {
|
|
23272
23495
|
if (type === 'market') {
|
|
@@ -23274,7 +23497,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23274
23497
|
}
|
|
23275
23498
|
}
|
|
23276
23499
|
else {
|
|
23277
|
-
const validOrderTypes = this.
|
|
23500
|
+
const validOrderTypes = this.safeList(market['info'], 'orderTypes');
|
|
23278
23501
|
if (!this.inArray(uppercaseType, validOrderTypes)) {
|
|
23279
23502
|
if (initialUppercaseType !== uppercaseType) {
|
|
23280
23503
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' stopPrice parameter is not allowed for ' + symbol + ' ' + type + ' orders');
|
|
@@ -23284,7 +23507,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23284
23507
|
}
|
|
23285
23508
|
}
|
|
23286
23509
|
}
|
|
23287
|
-
|
|
23510
|
+
const clientOrderIdRequest = isPortfolioMarginConditional ? 'newClientStrategyId' : 'newClientOrderId';
|
|
23511
|
+
if (clientOrderId === undefined) {
|
|
23512
|
+
const broker = this.safeDict(this.options, 'broker', {});
|
|
23513
|
+
const defaultId = (market['contract']) ? 'x-xcKtGhcu' : 'x-R4BD3S82';
|
|
23514
|
+
const brokerId = this.safeString(broker, marketType, defaultId);
|
|
23515
|
+
request[clientOrderIdRequest] = brokerId + this.uuid22();
|
|
23516
|
+
}
|
|
23517
|
+
else {
|
|
23518
|
+
request[clientOrderIdRequest] = clientOrderId;
|
|
23519
|
+
}
|
|
23520
|
+
const typeRequest = isPortfolioMarginConditional ? 'strategyType' : 'type';
|
|
23521
|
+
request[typeRequest] = uppercaseType;
|
|
23288
23522
|
// additional required fields depending on the order type
|
|
23289
23523
|
let timeInForceIsRequired = false;
|
|
23290
23524
|
let priceIsRequired = false;
|
|
@@ -23312,9 +23546,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23312
23546
|
//
|
|
23313
23547
|
if (uppercaseType === 'MARKET') {
|
|
23314
23548
|
if (market['spot']) {
|
|
23315
|
-
const quoteOrderQty = this.
|
|
23549
|
+
const quoteOrderQty = this.safeBool(this.options, 'quoteOrderQty', true);
|
|
23316
23550
|
if (quoteOrderQty) {
|
|
23317
|
-
const quoteOrderQtyNew = this.
|
|
23551
|
+
const quoteOrderQtyNew = this.safeString2(params, 'quoteOrderQty', 'cost');
|
|
23318
23552
|
const precision = market['precision']['price'];
|
|
23319
23553
|
if (quoteOrderQtyNew !== undefined) {
|
|
23320
23554
|
request['quoteOrderQty'] = this.decimalToPrecision(quoteOrderQtyNew, _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TRUNCATE */ .tk, precision, this.precisionMode);
|
|
@@ -23365,7 +23599,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23365
23599
|
priceIsRequired = true;
|
|
23366
23600
|
}
|
|
23367
23601
|
else if ((uppercaseType === 'STOP_MARKET') || (uppercaseType === 'TAKE_PROFIT_MARKET')) {
|
|
23368
|
-
const closePosition = this.
|
|
23602
|
+
const closePosition = this.safeBool(params, 'closePosition');
|
|
23369
23603
|
if (closePosition === undefined) {
|
|
23370
23604
|
quantityIsRequired = true;
|
|
23371
23605
|
}
|
|
@@ -23378,7 +23612,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23378
23612
|
}
|
|
23379
23613
|
}
|
|
23380
23614
|
if (quantityIsRequired) {
|
|
23381
|
-
|
|
23615
|
+
// portfolio margin has a different amount precision
|
|
23616
|
+
if (isPortfolioMargin) {
|
|
23617
|
+
request['quantity'] = this.parseToNumeric(amount);
|
|
23618
|
+
}
|
|
23619
|
+
else {
|
|
23620
|
+
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
23621
|
+
}
|
|
23382
23622
|
}
|
|
23383
23623
|
if (priceIsRequired) {
|
|
23384
23624
|
if (price === undefined) {
|
|
@@ -23389,9 +23629,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23389
23629
|
if (timeInForceIsRequired) {
|
|
23390
23630
|
request['timeInForce'] = this.options['defaultTimeInForce']; // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
|
|
23391
23631
|
}
|
|
23392
|
-
if (market['contract'] && postOnly) {
|
|
23393
|
-
request['timeInForce'] = 'GTX';
|
|
23394
|
-
}
|
|
23395
23632
|
if (stopPriceIsRequired) {
|
|
23396
23633
|
if (market['contract']) {
|
|
23397
23634
|
if (stopPrice === undefined) {
|
|
@@ -23408,11 +23645,26 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23408
23645
|
request['stopPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
23409
23646
|
}
|
|
23410
23647
|
}
|
|
23648
|
+
if (!isPortfolioMargin) {
|
|
23649
|
+
const postOnly = this.isPostOnly(isMarketOrder, initialUppercaseType === 'LIMIT_MAKER', params);
|
|
23650
|
+
if (market['spot'] || marketType === 'margin') {
|
|
23651
|
+
// only supported for spot/margin api (all margin markets are spot markets)
|
|
23652
|
+
if (postOnly) {
|
|
23653
|
+
type = 'LIMIT_MAKER';
|
|
23654
|
+
}
|
|
23655
|
+
if (marginMode === 'isolated') {
|
|
23656
|
+
request['isIsolated'] = true;
|
|
23657
|
+
}
|
|
23658
|
+
}
|
|
23659
|
+
if (market['contract'] && postOnly) {
|
|
23660
|
+
request['timeInForce'] = 'GTX';
|
|
23661
|
+
}
|
|
23662
|
+
}
|
|
23411
23663
|
// remove timeInForce from params because PO is only used by this.isPostOnly and it's not a valid value for Binance
|
|
23412
23664
|
if (this.safeString(params, 'timeInForce') === 'PO') {
|
|
23413
|
-
params = this.omit(params,
|
|
23665
|
+
params = this.omit(params, 'timeInForce');
|
|
23414
23666
|
}
|
|
23415
|
-
const requestParams = this.omit(params, ['
|
|
23667
|
+
const requestParams = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test']);
|
|
23416
23668
|
return this.extend(request, requestParams);
|
|
23417
23669
|
}
|
|
23418
23670
|
async createMarketOrderWithCost(symbol, side, cost, params = {}) {
|
|
@@ -36460,6 +36712,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36460
36712
|
* @method
|
|
36461
36713
|
* @name bitfinex#fetchTradingFees
|
|
36462
36714
|
* @description fetch the trading fees for multiple markets
|
|
36715
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-summary
|
|
36463
36716
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
36464
36717
|
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
36465
36718
|
*/
|
|
@@ -36542,6 +36795,8 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36542
36795
|
* @method
|
|
36543
36796
|
* @name bitfinex#fetchMarkets
|
|
36544
36797
|
* @description retrieves data on all markets for bitfinex
|
|
36798
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-public-symbols
|
|
36799
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-public-symbol-details
|
|
36545
36800
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
36546
36801
|
* @returns {object[]} an array of objects representing market data
|
|
36547
36802
|
*/
|
|
@@ -36666,6 +36921,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36666
36921
|
* @method
|
|
36667
36922
|
* @name bitfinex#fetchBalance
|
|
36668
36923
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
36924
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-wallet-balances
|
|
36669
36925
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
36670
36926
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
36671
36927
|
*/
|
|
@@ -36723,6 +36979,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36723
36979
|
* @method
|
|
36724
36980
|
* @name bitfinex#transfer
|
|
36725
36981
|
* @description transfer currency internally between wallets on the same account
|
|
36982
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-transfer-between-wallets
|
|
36726
36983
|
* @param {string} code unified currency code
|
|
36727
36984
|
* @param {float} amount amount to transfer
|
|
36728
36985
|
* @param {string} fromAccount account to transfer from
|
|
@@ -36808,6 +37065,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36808
37065
|
* @method
|
|
36809
37066
|
* @name bitfinex#fetchOrderBook
|
|
36810
37067
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
37068
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-public-orderbook
|
|
36811
37069
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
36812
37070
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
36813
37071
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -36850,6 +37108,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36850
37108
|
* @method
|
|
36851
37109
|
* @name bitfinex#fetchTicker
|
|
36852
37110
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
37111
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-public-ticker
|
|
36853
37112
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
36854
37113
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
36855
37114
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -36966,6 +37225,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
36966
37225
|
* @method
|
|
36967
37226
|
* @name bitfinex#fetchTrades
|
|
36968
37227
|
* @description get the list of most recent trades for a particular symbol
|
|
37228
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-public-trades
|
|
36969
37229
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
36970
37230
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
36971
37231
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -37001,6 +37261,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37001
37261
|
* @method
|
|
37002
37262
|
* @name bitfinex#fetchMyTrades
|
|
37003
37263
|
* @description fetch all trades made by the user
|
|
37264
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-past-trades
|
|
37004
37265
|
* @param {string} symbol unified market symbol
|
|
37005
37266
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
37006
37267
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
@@ -37029,6 +37290,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37029
37290
|
* @method
|
|
37030
37291
|
* @name bitfinex#createOrder
|
|
37031
37292
|
* @description create a trade order
|
|
37293
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-new-order
|
|
37032
37294
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
37033
37295
|
* @param {string} type 'market' or 'limit'
|
|
37034
37296
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -37096,6 +37358,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37096
37358
|
* @method
|
|
37097
37359
|
* @name bitfinex#cancelOrder
|
|
37098
37360
|
* @description cancels an open order
|
|
37361
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-order
|
|
37099
37362
|
* @param {string} id order id
|
|
37100
37363
|
* @param {string} symbol not used by bitfinex cancelOrder ()
|
|
37101
37364
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -37112,6 +37375,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37112
37375
|
* @method
|
|
37113
37376
|
* @name bitfinex#cancelAllOrders
|
|
37114
37377
|
* @description cancel all open orders
|
|
37378
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-all-orders
|
|
37115
37379
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
37116
37380
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
37117
37381
|
* @returns {object} response from exchange
|
|
@@ -37196,6 +37460,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37196
37460
|
* @method
|
|
37197
37461
|
* @name bitfinex#fetchOpenOrders
|
|
37198
37462
|
* @description fetch all unfilled currently open orders
|
|
37463
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-active-orders
|
|
37199
37464
|
* @param {string} symbol unified market symbol
|
|
37200
37465
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
37201
37466
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
@@ -37220,6 +37485,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37220
37485
|
* @method
|
|
37221
37486
|
* @name bitfinex#fetchClosedOrders
|
|
37222
37487
|
* @description fetches information on multiple closed orders made by the user
|
|
37488
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-orders-history
|
|
37223
37489
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
37224
37490
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
37225
37491
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -37245,6 +37511,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37245
37511
|
* @method
|
|
37246
37512
|
* @name bitfinex#fetchOrder
|
|
37247
37513
|
* @description fetches information on an order made by the user
|
|
37514
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-order-status
|
|
37248
37515
|
* @param {string} symbol not used by bitfinex fetchOrder
|
|
37249
37516
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
37250
37517
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -37281,6 +37548,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37281
37548
|
* @method
|
|
37282
37549
|
* @name bitfinex#fetchOHLCV
|
|
37283
37550
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
37551
|
+
* @see https://docs.bitfinex.com/reference/rest-public-candles#aggregate-funding-currency-candles
|
|
37284
37552
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
37285
37553
|
* @param {string} timeframe the length of time each candle represents
|
|
37286
37554
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -37325,6 +37593,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37325
37593
|
* @method
|
|
37326
37594
|
* @name bitfinex#createDepositAddress
|
|
37327
37595
|
* @description create a currency deposit address
|
|
37596
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit
|
|
37328
37597
|
* @param {string} code unified currency code of the currency for the deposit address
|
|
37329
37598
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
37330
37599
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
@@ -37340,6 +37609,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37340
37609
|
* @method
|
|
37341
37610
|
* @name bitfinex#fetchDepositAddress
|
|
37342
37611
|
* @description fetch the deposit address for a currency associated with this account
|
|
37612
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit
|
|
37343
37613
|
* @param {string} code unified currency code
|
|
37344
37614
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
37345
37615
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
@@ -37373,6 +37643,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37373
37643
|
* @method
|
|
37374
37644
|
* @name bitfinex#fetchDepositsWithdrawals
|
|
37375
37645
|
* @description fetch history of deposits and withdrawals
|
|
37646
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit-withdrawal-history
|
|
37376
37647
|
* @param {string} code unified currency code for the currency of the deposit/withdrawals
|
|
37377
37648
|
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
|
|
37378
37649
|
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
|
|
@@ -37509,6 +37780,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37509
37780
|
* @method
|
|
37510
37781
|
* @name bitfinex#withdraw
|
|
37511
37782
|
* @description make a withdrawal
|
|
37783
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-withdrawal
|
|
37512
37784
|
* @param {string} code unified currency code
|
|
37513
37785
|
* @param {float} amount the amount to withdraw
|
|
37514
37786
|
* @param {string} address the address to withdraw to
|
|
@@ -37559,6 +37831,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
37559
37831
|
* @method
|
|
37560
37832
|
* @name bitfinex#fetchPositions
|
|
37561
37833
|
* @description fetch all open positions
|
|
37834
|
+
* @see https://docs.bitfinex.com/v1/reference/rest-auth-active-positions
|
|
37562
37835
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
37563
37836
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
37564
37837
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
@@ -37690,11 +37963,13 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37690
37963
|
'has': {
|
|
37691
37964
|
'CORS': undefined,
|
|
37692
37965
|
'spot': true,
|
|
37693
|
-
'margin':
|
|
37966
|
+
'margin': true,
|
|
37694
37967
|
'swap': true,
|
|
37695
37968
|
'future': undefined,
|
|
37696
37969
|
'option': undefined,
|
|
37697
37970
|
'addMargin': false,
|
|
37971
|
+
'borrowCrossMargin': false,
|
|
37972
|
+
'borrowIsolatedMargin': false,
|
|
37698
37973
|
'cancelAllOrders': true,
|
|
37699
37974
|
'cancelOrder': true,
|
|
37700
37975
|
'cancelOrders': true,
|
|
@@ -37711,8 +37986,13 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37711
37986
|
'createTriggerOrder': true,
|
|
37712
37987
|
'editOrder': true,
|
|
37713
37988
|
'fetchBalance': true,
|
|
37989
|
+
'fetchBorrowInterest': false,
|
|
37990
|
+
'fetchBorrowRateHistories': false,
|
|
37991
|
+
'fetchBorrowRateHistory': false,
|
|
37714
37992
|
'fetchClosedOrder': true,
|
|
37715
37993
|
'fetchClosedOrders': true,
|
|
37994
|
+
'fetchCrossBorrowRate': false,
|
|
37995
|
+
'fetchCrossBorrowRates': false,
|
|
37716
37996
|
'fetchCurrencies': true,
|
|
37717
37997
|
'fetchDepositAddress': true,
|
|
37718
37998
|
'fetchDepositsWithdrawals': true,
|
|
@@ -37721,6 +38001,8 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37721
38001
|
'fetchFundingRateHistory': true,
|
|
37722
38002
|
'fetchFundingRates': true,
|
|
37723
38003
|
'fetchIndexOHLCV': false,
|
|
38004
|
+
'fetchIsolatedBorrowRate': false,
|
|
38005
|
+
'fetchIsolatedBorrowRates': false,
|
|
37724
38006
|
'fetchLedger': true,
|
|
37725
38007
|
'fetchLeverage': false,
|
|
37726
38008
|
'fetchLeverageTiers': false,
|
|
@@ -37748,6 +38030,8 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37748
38030
|
'fetchTransactionFees': undefined,
|
|
37749
38031
|
'fetchTransactions': 'emulated',
|
|
37750
38032
|
'reduceMargin': false,
|
|
38033
|
+
'repayCrossMargin': false,
|
|
38034
|
+
'repayIsolatedMargin': false,
|
|
37751
38035
|
'setLeverage': false,
|
|
37752
38036
|
'setMargin': true,
|
|
37753
38037
|
'setMarginMode': false,
|
|
@@ -46576,6 +46860,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
46576
46860
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
46577
46861
|
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
46578
46862
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
46863
|
+
* @param {string} [params.price] *swap only* "mark" (to fetch mark price candles) or "index" (to fetch index price candles)
|
|
46579
46864
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
46580
46865
|
*/
|
|
46581
46866
|
await this.loadMarkets();
|
|
@@ -46605,68 +46890,56 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
46605
46890
|
if (limit !== undefined) {
|
|
46606
46891
|
request['limit'] = limit;
|
|
46607
46892
|
}
|
|
46608
|
-
|
|
46609
|
-
|
|
46610
|
-
|
|
46611
|
-
|
|
46612
|
-
|
|
46613
|
-
|
|
46614
|
-
if (since !== undefined) {
|
|
46615
|
-
request['startTime'] = since;
|
|
46616
|
-
}
|
|
46617
|
-
if (until !== undefined) {
|
|
46618
|
-
request['endTime'] = until;
|
|
46893
|
+
if (since !== undefined) {
|
|
46894
|
+
request['startTime'] = since;
|
|
46895
|
+
}
|
|
46896
|
+
if (since !== undefined) {
|
|
46897
|
+
if (limit === undefined) {
|
|
46898
|
+
limit = 100; // exchange default
|
|
46619
46899
|
}
|
|
46900
|
+
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
46901
|
+
request['endTime'] = this.sum(since, duration * (limit + 1)) - 1; // limit + 1)) - 1 is needed for when since is not the exact timestamp of a candle
|
|
46902
|
+
}
|
|
46903
|
+
else if (until !== undefined) {
|
|
46904
|
+
request['endTime'] = until;
|
|
46905
|
+
}
|
|
46906
|
+
else {
|
|
46907
|
+
request['endTime'] = this.milliseconds();
|
|
46620
46908
|
}
|
|
46621
46909
|
let response = undefined;
|
|
46910
|
+
const thirtyOneDaysAgo = this.milliseconds() - 2678400000;
|
|
46622
46911
|
if (market['spot']) {
|
|
46623
|
-
if (
|
|
46624
|
-
response = await this.publicSpotGetV2SpotMarketCandles(this.extend(request, params));
|
|
46625
|
-
}
|
|
46626
|
-
else if (method === 'publicSpotGetV2SpotMarketHistoryCandles') {
|
|
46627
|
-
if (since !== undefined) {
|
|
46628
|
-
if (limit === undefined) {
|
|
46629
|
-
limit = 100; // exchange default
|
|
46630
|
-
}
|
|
46631
|
-
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
46632
|
-
request['endTime'] = this.sum(since, duration * limit);
|
|
46633
|
-
}
|
|
46634
|
-
else if (until !== undefined) {
|
|
46635
|
-
request['endTime'] = until;
|
|
46636
|
-
}
|
|
46637
|
-
else {
|
|
46638
|
-
request['endTime'] = this.milliseconds();
|
|
46639
|
-
}
|
|
46912
|
+
if ((since !== undefined) && (since < thirtyOneDaysAgo)) {
|
|
46640
46913
|
response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
|
|
46641
46914
|
}
|
|
46915
|
+
else {
|
|
46916
|
+
response = await this.publicSpotGetV2SpotMarketCandles(this.extend(request, params));
|
|
46917
|
+
}
|
|
46642
46918
|
}
|
|
46643
46919
|
else {
|
|
46644
|
-
const swapOptions = this.safeValue(options, 'swap', {});
|
|
46645
|
-
const defaultSwapMethod = this.safeString(swapOptions, 'method', 'publicMixGetV2MixMarketCandles');
|
|
46646
|
-
const swapMethod = this.safeString(params, 'method', defaultSwapMethod);
|
|
46647
46920
|
const priceType = this.safeString(params, 'price');
|
|
46648
|
-
params = this.omit(params, ['
|
|
46921
|
+
params = this.omit(params, ['price']);
|
|
46649
46922
|
let productType = undefined;
|
|
46650
46923
|
[productType, params] = this.handleProductTypeAndParams(market, params);
|
|
46651
46924
|
request['productType'] = productType;
|
|
46652
|
-
if (
|
|
46925
|
+
if (priceType === 'mark') {
|
|
46653
46926
|
response = await this.publicMixGetV2MixMarketHistoryMarkCandles(this.extend(request, params));
|
|
46654
46927
|
}
|
|
46655
|
-
else if (
|
|
46928
|
+
else if (priceType === 'index') {
|
|
46656
46929
|
response = await this.publicMixGetV2MixMarketHistoryIndexCandles(this.extend(request, params));
|
|
46657
46930
|
}
|
|
46658
|
-
else if (
|
|
46659
|
-
response = await this.publicMixGetV2MixMarketCandles(this.extend(request, params));
|
|
46660
|
-
}
|
|
46661
|
-
else if (swapMethod === 'publicMixGetV2MixMarketHistoryCandles') {
|
|
46931
|
+
else if ((since !== undefined) && (since < thirtyOneDaysAgo)) {
|
|
46662
46932
|
response = await this.publicMixGetV2MixMarketHistoryCandles(this.extend(request, params));
|
|
46663
46933
|
}
|
|
46934
|
+
else {
|
|
46935
|
+
response = await this.publicMixGetV2MixMarketCandles(this.extend(request, params));
|
|
46936
|
+
}
|
|
46664
46937
|
}
|
|
46665
46938
|
if (response === '') {
|
|
46666
46939
|
return []; // happens when a new token is listed
|
|
46667
46940
|
}
|
|
46668
46941
|
// [ ["1645911960000","39406","39407","39374.5","39379","35.526","1399132.341"] ]
|
|
46669
|
-
const data = this.
|
|
46942
|
+
const data = this.safeList(response, 'data', response);
|
|
46670
46943
|
return this.parseOHLCVs(data, market, timeframe, since, limit);
|
|
46671
46944
|
}
|
|
46672
46945
|
async fetchBalance(params = {}) {
|
|
@@ -51823,6 +52096,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
51823
52096
|
* @method
|
|
51824
52097
|
* @name bithumb#fetchMarkets
|
|
51825
52098
|
* @description retrieves data on all markets for bithumb
|
|
52099
|
+
* @see https://apidocs.bithumb.com/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C-all
|
|
51826
52100
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
51827
52101
|
* @returns {object[]} an array of objects representing market data
|
|
51828
52102
|
*/
|
|
@@ -51925,6 +52199,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
51925
52199
|
* @method
|
|
51926
52200
|
* @name bithumb#fetchBalance
|
|
51927
52201
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
52202
|
+
* @see https://apidocs.bithumb.com/reference/%EB%B3%B4%EC%9C%A0%EC%9E%90%EC%82%B0-%EC%A1%B0%ED%9A%8C
|
|
51928
52203
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
51929
52204
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
51930
52205
|
*/
|
|
@@ -51940,6 +52215,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
51940
52215
|
* @method
|
|
51941
52216
|
* @name bithumb#fetchOrderBook
|
|
51942
52217
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
52218
|
+
* @see https://apidocs.bithumb.com/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
|
|
51943
52219
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
51944
52220
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
51945
52221
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -52032,6 +52308,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52032
52308
|
* @method
|
|
52033
52309
|
* @name bithumb#fetchTickers
|
|
52034
52310
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
52311
|
+
* @see https://apidocs.bithumb.com/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C-all
|
|
52035
52312
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
52036
52313
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
52037
52314
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -52089,6 +52366,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52089
52366
|
* @method
|
|
52090
52367
|
* @name bithumb#fetchTicker
|
|
52091
52368
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
52369
|
+
* @see https://apidocs.bithumb.com/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
|
|
52092
52370
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
52093
52371
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
52094
52372
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -52147,6 +52425,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52147
52425
|
* @method
|
|
52148
52426
|
* @name bithumb#fetchOHLCV
|
|
52149
52427
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
52428
|
+
* @see https://apidocs.bithumb.com/reference/candlestick-rest-api
|
|
52150
52429
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
52151
52430
|
* @param {string} timeframe the length of time each candle represents
|
|
52152
52431
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -52271,6 +52550,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52271
52550
|
* @method
|
|
52272
52551
|
* @name bithumb#fetchTrades
|
|
52273
52552
|
* @description get the list of most recent trades for a particular symbol
|
|
52553
|
+
* @see https://apidocs.bithumb.com/reference/%EC%B5%9C%EA%B7%BC-%EC%B2%B4%EA%B2%B0-%EB%82%B4%EC%97%AD
|
|
52274
52554
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
52275
52555
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
52276
52556
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -52309,6 +52589,9 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52309
52589
|
* @method
|
|
52310
52590
|
* @name bithumb#createOrder
|
|
52311
52591
|
* @description create a trade order
|
|
52592
|
+
* @see https://apidocs.bithumb.com/reference/%EC%A7%80%EC%A0%95%EA%B0%80-%EC%A3%BC%EB%AC%B8%ED%95%98%EA%B8%B0
|
|
52593
|
+
* @see https://apidocs.bithumb.com/reference/%EC%8B%9C%EC%9E%A5%EA%B0%80-%EB%A7%A4%EC%88%98%ED%95%98%EA%B8%B0
|
|
52594
|
+
* @see https://apidocs.bithumb.com/reference/%EC%8B%9C%EC%9E%A5%EA%B0%80-%EB%A7%A4%EB%8F%84%ED%95%98%EA%B8%B0
|
|
52312
52595
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
52313
52596
|
* @param {string} type 'market' or 'limit'
|
|
52314
52597
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -52350,6 +52633,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52350
52633
|
* @method
|
|
52351
52634
|
* @name bithumb#fetchOrder
|
|
52352
52635
|
* @description fetches information on an order made by the user
|
|
52636
|
+
* @see https://apidocs.bithumb.com/reference/%EA%B1%B0%EB%9E%98-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%83%81%EC%84%B8-%EC%A1%B0%ED%9A%8C
|
|
52353
52637
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
52354
52638
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
52355
52639
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -52508,6 +52792,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52508
52792
|
* @method
|
|
52509
52793
|
* @name bithumb#fetchOpenOrders
|
|
52510
52794
|
* @description fetch all unfilled currently open orders
|
|
52795
|
+
* @see https://apidocs.bithumb.com/reference/%EA%B1%B0%EB%9E%98-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
|
|
52511
52796
|
* @param {string} symbol unified market symbol
|
|
52512
52797
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
52513
52798
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
@@ -52556,6 +52841,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52556
52841
|
* @method
|
|
52557
52842
|
* @name bithumb#cancelOrder
|
|
52558
52843
|
* @description cancels an open order
|
|
52844
|
+
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C%ED%95%98%EA%B8%B0
|
|
52559
52845
|
* @param {string} id order id
|
|
52560
52846
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
52561
52847
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -52591,6 +52877,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52591
52877
|
* @method
|
|
52592
52878
|
* @name bithumb#withdraw
|
|
52593
52879
|
* @description make a withdrawal
|
|
52880
|
+
* @see https://apidocs.bithumb.com/reference/%EC%BD%94%EC%9D%B8-%EC%B6%9C%EA%B8%88%ED%95%98%EA%B8%B0-%EA%B0%9C%EC%9D%B8
|
|
52594
52881
|
* @param {string} code unified currency code
|
|
52595
52882
|
* @param {float} amount the amount to withdraw
|
|
52596
52883
|
* @param {string} address the address to withdraw to
|
|
@@ -159955,10 +160242,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
159955
160242
|
},
|
|
159956
160243
|
'fees': {
|
|
159957
160244
|
'trading': {
|
|
159958
|
-
'tierBased':
|
|
160245
|
+
'tierBased': true,
|
|
159959
160246
|
'percentage': true,
|
|
159960
|
-
'
|
|
159961
|
-
'
|
|
160247
|
+
'taker': this.parseNumber('0.0005'),
|
|
160248
|
+
'maker': this.parseNumber('0.0002'),
|
|
160249
|
+
'tiers': {
|
|
160250
|
+
'taker': [
|
|
160251
|
+
[this.parseNumber('0'), this.parseNumber('0.0005')],
|
|
160252
|
+
[this.parseNumber('100000'), this.parseNumber('0.0004')],
|
|
160253
|
+
[this.parseNumber('1000000'), this.parseNumber('0.0003')],
|
|
160254
|
+
[this.parseNumber('5000000'), this.parseNumber('0.00025')],
|
|
160255
|
+
[this.parseNumber('10000000'), this.parseNumber('0.0002')],
|
|
160256
|
+
[this.parseNumber('20000000'), this.parseNumber('0.00015')],
|
|
160257
|
+
[this.parseNumber('50000000'), this.parseNumber('0.000125')],
|
|
160258
|
+
[this.parseNumber('100000000'), this.parseNumber('0.0001')],
|
|
160259
|
+
],
|
|
160260
|
+
'maker': [
|
|
160261
|
+
[this.parseNumber('0'), this.parseNumber('0.0002')],
|
|
160262
|
+
[this.parseNumber('100000'), this.parseNumber('0.0015')],
|
|
160263
|
+
[this.parseNumber('1000000'), this.parseNumber('0.000125')],
|
|
160264
|
+
[this.parseNumber('5000000'), this.parseNumber('0.0001')],
|
|
160265
|
+
[this.parseNumber('10000000'), this.parseNumber('0.000075')],
|
|
160266
|
+
[this.parseNumber('20000000'), this.parseNumber('0.00005')],
|
|
160267
|
+
[this.parseNumber('50000000'), this.parseNumber('0.000025')],
|
|
160268
|
+
[this.parseNumber('100000000'), this.parseNumber('0')],
|
|
160269
|
+
],
|
|
160270
|
+
},
|
|
159962
160271
|
},
|
|
159963
160272
|
},
|
|
159964
160273
|
'exceptions': {
|
|
@@ -214724,8 +215033,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
214724
215033
|
},
|
|
214725
215034
|
'api': {
|
|
214726
215035
|
'ws': {
|
|
214727
|
-
'spot': 'wss://stream.binance.com/ws',
|
|
214728
|
-
'margin': 'wss://stream.binance.com/ws',
|
|
215036
|
+
'spot': 'wss://stream.binance.com:9443/ws',
|
|
215037
|
+
'margin': 'wss://stream.binance.com:9443/ws',
|
|
214729
215038
|
'future': 'wss://fstream.binance.com/ws',
|
|
214730
215039
|
'delivery': 'wss://dstream.binance.com/ws',
|
|
214731
215040
|
'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
|
|
@@ -217112,7 +217421,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
217112
217421
|
return this.safePosition({
|
|
217113
217422
|
'info': position,
|
|
217114
217423
|
'id': undefined,
|
|
217115
|
-
'symbol': this.safeSymbol(marketId, undefined, undefined, '
|
|
217424
|
+
'symbol': this.safeSymbol(marketId, undefined, undefined, 'contract'),
|
|
217116
217425
|
'notional': undefined,
|
|
217117
217426
|
'marginMode': this.safeString(position, 'mt'),
|
|
217118
217427
|
'liquidationPrice': undefined,
|
|
@@ -217266,9 +217575,9 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
217266
217575
|
const messageHash = 'myTrades';
|
|
217267
217576
|
const executionType = this.safeString(message, 'x');
|
|
217268
217577
|
if (executionType === 'TRADE') {
|
|
217269
|
-
const trade = this.
|
|
217578
|
+
const trade = this.parseWsTrade(message);
|
|
217270
217579
|
const orderId = this.safeString(trade, 'order');
|
|
217271
|
-
let tradeFee = this.safeValue(trade, 'fee');
|
|
217580
|
+
let tradeFee = this.safeValue(trade, 'fee', {});
|
|
217272
217581
|
tradeFee = this.extend({}, tradeFee);
|
|
217273
217582
|
const symbol = this.safeString(trade, 'symbol');
|
|
217274
217583
|
if (orderId !== undefined && tradeFee !== undefined && symbol !== undefined) {
|
|
@@ -290527,11 +290836,12 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
290527
290836
|
* @method
|
|
290528
290837
|
* @name woo#fetchOHLCV
|
|
290529
290838
|
* @see https://docs.woo.org/#kline-public
|
|
290839
|
+
* @see https://docs.woo.org/#kline-historical-data-public
|
|
290530
290840
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
290531
290841
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
290532
290842
|
* @param {string} timeframe the length of time each candle represents
|
|
290533
290843
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
290534
|
-
* @param {int} [limit]
|
|
290844
|
+
* @param {int} [limit] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms)))
|
|
290535
290845
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
290536
290846
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
290537
290847
|
*/
|
|
@@ -290541,42 +290851,70 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
290541
290851
|
'symbol': market['id'],
|
|
290542
290852
|
'type': this.safeString(this.timeframes, timeframe, timeframe),
|
|
290543
290853
|
};
|
|
290544
|
-
|
|
290854
|
+
let useHistEndpoint = since !== undefined;
|
|
290855
|
+
if ((limit !== undefined) && (since !== undefined)) {
|
|
290856
|
+
const oneThousandCandles = this.parseTimeframe(timeframe) * 1000 * 999; // 999 because there will be delay between this and the request, causing the latest candle to be excluded sometimes
|
|
290857
|
+
const startWithLimit = this.milliseconds() - oneThousandCandles;
|
|
290858
|
+
useHistEndpoint = since < startWithLimit;
|
|
290859
|
+
}
|
|
290860
|
+
if (useHistEndpoint) {
|
|
290861
|
+
request['start_time'] = since;
|
|
290862
|
+
}
|
|
290863
|
+
else if (limit !== undefined) { // the hist endpoint does not accept limit
|
|
290545
290864
|
request['limit'] = Math.min(limit, 1000);
|
|
290546
290865
|
}
|
|
290547
|
-
|
|
290548
|
-
|
|
290549
|
-
|
|
290550
|
-
|
|
290551
|
-
|
|
290552
|
-
|
|
290553
|
-
|
|
290554
|
-
|
|
290555
|
-
|
|
290556
|
-
|
|
290557
|
-
|
|
290558
|
-
|
|
290559
|
-
|
|
290560
|
-
|
|
290561
|
-
|
|
290562
|
-
|
|
290563
|
-
|
|
290564
|
-
|
|
290565
|
-
|
|
290566
|
-
|
|
290567
|
-
|
|
290568
|
-
|
|
290569
|
-
|
|
290570
|
-
|
|
290571
|
-
|
|
290572
|
-
|
|
290573
|
-
|
|
290574
|
-
|
|
290575
|
-
|
|
290576
|
-
|
|
290577
|
-
|
|
290578
|
-
|
|
290579
|
-
|
|
290866
|
+
let response = undefined;
|
|
290867
|
+
if (!useHistEndpoint) {
|
|
290868
|
+
response = await this.v1PublicGetKline(this.extend(request, params));
|
|
290869
|
+
//
|
|
290870
|
+
// {
|
|
290871
|
+
// "success": true,
|
|
290872
|
+
// "rows": [
|
|
290873
|
+
// {
|
|
290874
|
+
// "open": "0.94238",
|
|
290875
|
+
// "close": "0.94271",
|
|
290876
|
+
// "low": "0.94238",
|
|
290877
|
+
// "high": "0.94296",
|
|
290878
|
+
// "volume": "73.55",
|
|
290879
|
+
// "amount": "69.32040520",
|
|
290880
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
290881
|
+
// "type": "1m",
|
|
290882
|
+
// "start_timestamp": "1641584700000",
|
|
290883
|
+
// "end_timestamp": "1641584760000"
|
|
290884
|
+
// },
|
|
290885
|
+
// ...
|
|
290886
|
+
// ]
|
|
290887
|
+
// }
|
|
290888
|
+
//
|
|
290889
|
+
}
|
|
290890
|
+
else {
|
|
290891
|
+
response = await this.v1PubGetHistKline(this.extend(request, params));
|
|
290892
|
+
response = this.safeDict(response, 'data');
|
|
290893
|
+
//
|
|
290894
|
+
// {
|
|
290895
|
+
// "success": true,
|
|
290896
|
+
// "data": {
|
|
290897
|
+
// "rows": [
|
|
290898
|
+
// {
|
|
290899
|
+
// "symbol": "SPOT_BTC_USDT",
|
|
290900
|
+
// "open": 44181.40000000,
|
|
290901
|
+
// "close": 44174.29000000,
|
|
290902
|
+
// "high": 44193.44000000,
|
|
290903
|
+
// "low": 44148.34000000,
|
|
290904
|
+
// "volume": 110.11930100,
|
|
290905
|
+
// "amount": 4863796.24318878,
|
|
290906
|
+
// "type": "1m",
|
|
290907
|
+
// "start_timestamp": 1704153600000,
|
|
290908
|
+
// "end_timestamp": 1704153660000
|
|
290909
|
+
// },
|
|
290910
|
+
// ...
|
|
290911
|
+
// ]
|
|
290912
|
+
// }
|
|
290913
|
+
// }
|
|
290914
|
+
//
|
|
290915
|
+
}
|
|
290916
|
+
const rows = this.safeValue(response, 'rows', []);
|
|
290917
|
+
return this.parseOHLCVs(rows, market, timeframe, since, limit);
|
|
290580
290918
|
}
|
|
290581
290919
|
parseOHLCV(ohlcv, market = undefined) {
|
|
290582
290920
|
// example response in fetchOHLCV
|
|
@@ -301317,7 +301655,7 @@ SOFTWARE.
|
|
|
301317
301655
|
|
|
301318
301656
|
//-----------------------------------------------------------------------------
|
|
301319
301657
|
// this is updated by vss.js when building
|
|
301320
|
-
const version = '4.2.
|
|
301658
|
+
const version = '4.2.36';
|
|
301321
301659
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
301322
301660
|
//-----------------------------------------------------------------------------
|
|
301323
301661
|
|