ccxt 4.2.95 → 4.2.97
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/CHANGELOG.md +51 -0
- package/README.md +3 -3
- package/dist/ccxt.browser.js +746 -148
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +18 -3
- package/dist/cjs/src/base/functions/crypto.js +15 -2
- package/dist/cjs/src/base/functions/rsa.js +2 -2
- package/dist/cjs/src/binance.js +11 -12
- package/dist/cjs/src/coinbase.js +621 -102
- package/dist/cjs/src/deribit.js +8 -3
- package/dist/cjs/src/gemini.js +29 -11
- package/dist/cjs/src/okx.js +2 -2
- package/dist/cjs/src/poloniexfutures.js +4 -1
- package/dist/cjs/src/pro/binance.js +10 -4
- package/dist/cjs/src/pro/coinbase.js +19 -4
- package/dist/cjs/src/pro/poloniexfutures.js +5 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/coinbase.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/base/Exchange.js +18 -3
- package/js/src/base/functions/crypto.d.ts +1 -1
- package/js/src/base/functions/crypto.js +15 -2
- package/js/src/base/functions/rsa.js +2 -2
- package/js/src/base/types.d.ts +1 -0
- package/js/src/base/ws/OrderBook.d.ts +1 -0
- package/js/src/base/ws/OrderBookSide.d.ts +2 -2
- package/js/src/binance.js +11 -12
- package/js/src/coinbase.d.ts +8 -1
- package/js/src/coinbase.js +622 -103
- package/js/src/deribit.js +8 -3
- package/js/src/gemini.js +29 -11
- package/js/src/okx.d.ts +1 -1
- package/js/src/okx.js +2 -2
- package/js/src/poloniexfutures.js +4 -1
- package/js/src/pro/binance.js +11 -5
- package/js/src/pro/coinbase.js +19 -4
- package/js/src/pro/poloniexfutures.js +6 -2
- package/package.json +1 -1
- package/skip-tests.json +163 -31
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -1212,13 +1212,18 @@ class deribit extends deribit$1 {
|
|
|
1212
1212
|
* @name deribit#fetchTickers
|
|
1213
1213
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1214
1214
|
* @see https://docs.deribit.com/#public-get_book_summary_by_currency
|
|
1215
|
-
* @param {string[]
|
|
1215
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1216
1216
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1217
|
+
* @param {string} [params.code] *required* the currency code to fetch the tickers for, eg. 'BTC', 'ETH'
|
|
1217
1218
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1218
1219
|
*/
|
|
1219
1220
|
await this.loadMarkets();
|
|
1220
1221
|
symbols = this.marketSymbols(symbols);
|
|
1221
|
-
const code = this.
|
|
1222
|
+
const code = this.safeString2(params, 'code', 'currency');
|
|
1223
|
+
params = this.omit(params, ['code']);
|
|
1224
|
+
if (code === undefined) {
|
|
1225
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchTickers requires a currency/code (eg: BTC/ETH/USDT) parameter to fetch tickers for');
|
|
1226
|
+
}
|
|
1222
1227
|
const currency = this.currency(code);
|
|
1223
1228
|
const request = {
|
|
1224
1229
|
'currency': currency['id'],
|
|
@@ -1254,7 +1259,7 @@ class deribit extends deribit$1 {
|
|
|
1254
1259
|
// "testnet": false
|
|
1255
1260
|
// }
|
|
1256
1261
|
//
|
|
1257
|
-
const result = this.
|
|
1262
|
+
const result = this.safeList(response, 'result', []);
|
|
1258
1263
|
const tickers = {};
|
|
1259
1264
|
for (let i = 0; i < result.length; i++) {
|
|
1260
1265
|
const ticker = this.parseTicker(result[i]);
|
package/dist/cjs/src/gemini.js
CHANGED
|
@@ -285,7 +285,13 @@ class gemini extends gemini$1 {
|
|
|
285
285
|
'ATOM': 'cosmos',
|
|
286
286
|
'DOT': 'polkadot',
|
|
287
287
|
},
|
|
288
|
-
'nonce': 'milliseconds',
|
|
288
|
+
'nonce': 'milliseconds',
|
|
289
|
+
'conflictingMarkets': {
|
|
290
|
+
'paxgusd': {
|
|
291
|
+
'base': 'PAXG',
|
|
292
|
+
'quote': 'USD',
|
|
293
|
+
},
|
|
294
|
+
},
|
|
289
295
|
},
|
|
290
296
|
});
|
|
291
297
|
}
|
|
@@ -679,17 +685,29 @@ class gemini extends gemini$1 {
|
|
|
679
685
|
const marketIdUpper = marketId.toUpperCase();
|
|
680
686
|
const isPerp = (marketIdUpper.indexOf('PERP') >= 0);
|
|
681
687
|
const marketIdWithoutPerp = marketIdUpper.replace('PERP', '');
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
688
|
+
const conflictingMarkets = this.safeDict(this.options, 'conflictingMarkets', {});
|
|
689
|
+
const lowerCaseId = marketIdWithoutPerp.toLowerCase();
|
|
690
|
+
if (lowerCaseId in conflictingMarkets) {
|
|
691
|
+
const conflictingMarket = conflictingMarkets[lowerCaseId];
|
|
692
|
+
baseId = conflictingMarket['base'];
|
|
693
|
+
quoteId = conflictingMarket['quote'];
|
|
694
|
+
if (isPerp) {
|
|
695
|
+
settleId = conflictingMarket['quote'];
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
const quoteCurrencies = this.handleOption('fetchMarketsFromAPI', 'quoteCurrencies', []);
|
|
700
|
+
for (let i = 0; i < quoteCurrencies.length; i++) {
|
|
701
|
+
const quoteCurrency = quoteCurrencies[i];
|
|
702
|
+
if (marketIdWithoutPerp.endsWith(quoteCurrency)) {
|
|
703
|
+
const quoteLength = this.parseToInt(-1 * quoteCurrency.length);
|
|
704
|
+
baseId = marketIdWithoutPerp.slice(0, quoteLength);
|
|
705
|
+
quoteId = quoteCurrency;
|
|
706
|
+
if (isPerp) {
|
|
707
|
+
settleId = quoteCurrency; // always same
|
|
708
|
+
}
|
|
709
|
+
break;
|
|
691
710
|
}
|
|
692
|
-
break;
|
|
693
711
|
}
|
|
694
712
|
}
|
|
695
713
|
}
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -1107,14 +1107,14 @@ class okx extends okx$1 {
|
|
|
1107
1107
|
},
|
|
1108
1108
|
});
|
|
1109
1109
|
}
|
|
1110
|
-
handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
|
|
1110
|
+
handleMarketTypeAndParams(methodName, market = undefined, params = {}, defaultValue = undefined) {
|
|
1111
1111
|
const instType = this.safeString(params, 'instType');
|
|
1112
1112
|
params = this.omit(params, 'instType');
|
|
1113
1113
|
const type = this.safeString(params, 'type');
|
|
1114
1114
|
if ((type === undefined) && (instType !== undefined)) {
|
|
1115
1115
|
params['type'] = instType;
|
|
1116
1116
|
}
|
|
1117
|
-
return super.handleMarketTypeAndParams(methodName, market, params);
|
|
1117
|
+
return super.handleMarketTypeAndParams(methodName, market, params, defaultValue);
|
|
1118
1118
|
}
|
|
1119
1119
|
convertToInstrumentType(type) {
|
|
1120
1120
|
const exchangeTypes = this.safeDict(this.options, 'exchangeType', {});
|
|
@@ -372,7 +372,10 @@ class poloniexfutures extends poloniexfutures$1 {
|
|
|
372
372
|
//
|
|
373
373
|
const marketId = this.safeString(ticker, 'symbol');
|
|
374
374
|
const symbol = this.safeSymbol(marketId, market);
|
|
375
|
-
const
|
|
375
|
+
const timestampString = this.safeString(ticker, 'ts');
|
|
376
|
+
// check timestamp bcz bug: https://app.travis-ci.com/github/ccxt/ccxt/builds/269959181#L4011
|
|
377
|
+
const multiplier = (timestampString.length === 18) ? 0.00001 : 0.000001;
|
|
378
|
+
const timestamp = this.safeIntegerProduct(ticker, 'ts', multiplier);
|
|
376
379
|
const last = this.safeString2(ticker, 'price', 'lastPrice');
|
|
377
380
|
const percentage = Precise["default"].stringMul(this.safeString(ticker, 'priceChgPct'), '100');
|
|
378
381
|
return this.safeTicker({
|
|
@@ -422,8 +422,11 @@ class binance extends binance$1 {
|
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
else {
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
426
|
+
if (checksum) {
|
|
427
|
+
// todo: client.reject from handleOrderBookMessage properly
|
|
428
|
+
throw new errors.InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
|
|
429
|
+
}
|
|
427
430
|
}
|
|
428
431
|
}
|
|
429
432
|
}
|
|
@@ -440,8 +443,11 @@ class binance extends binance$1 {
|
|
|
440
443
|
}
|
|
441
444
|
}
|
|
442
445
|
else {
|
|
443
|
-
|
|
444
|
-
|
|
446
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
447
|
+
if (checksum) {
|
|
448
|
+
// todo: client.reject from handleOrderBookMessage properly
|
|
449
|
+
throw new errors.InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
|
|
450
|
+
}
|
|
445
451
|
}
|
|
446
452
|
}
|
|
447
453
|
}
|
|
@@ -140,6 +140,11 @@ class coinbase extends coinbase$1 {
|
|
|
140
140
|
// "low_52_w": "15460",
|
|
141
141
|
// "high_52_w": "48240",
|
|
142
142
|
// "price_percent_chg_24_h": "-4.15775596190603"
|
|
143
|
+
// new as of 2024-04-12
|
|
144
|
+
// "best_bid":"21835.29",
|
|
145
|
+
// "best_bid_quantity": "0.02000000",
|
|
146
|
+
// "best_ask":"23011.18",
|
|
147
|
+
// "best_ask_quantity": "0.01500000"
|
|
143
148
|
// }
|
|
144
149
|
// ]
|
|
145
150
|
// }
|
|
@@ -165,6 +170,11 @@ class coinbase extends coinbase$1 {
|
|
|
165
170
|
// "low_52_w": "0.04908",
|
|
166
171
|
// "high_52_w": "0.1801",
|
|
167
172
|
// "price_percent_chg_24_h": "0.50177456859626"
|
|
173
|
+
// new as of 2024-04-12
|
|
174
|
+
// "best_bid":"0.07989",
|
|
175
|
+
// "best_bid_quantity": "500.0",
|
|
176
|
+
// "best_ask":"0.08308",
|
|
177
|
+
// "best_ask_quantity": "300.0"
|
|
168
178
|
// }
|
|
169
179
|
// ]
|
|
170
180
|
// }
|
|
@@ -219,6 +229,11 @@ class coinbase extends coinbase$1 {
|
|
|
219
229
|
// "low_52_w": "0.04908",
|
|
220
230
|
// "high_52_w": "0.1801",
|
|
221
231
|
// "price_percent_chg_24_h": "0.50177456859626"
|
|
232
|
+
// new as of 2024-04-12
|
|
233
|
+
// "best_bid":"0.07989",
|
|
234
|
+
// "best_bid_quantity": "500.0",
|
|
235
|
+
// "best_ask":"0.08308",
|
|
236
|
+
// "best_ask_quantity": "300.0"
|
|
222
237
|
// }
|
|
223
238
|
//
|
|
224
239
|
const marketId = this.safeString(ticker, 'product_id');
|
|
@@ -231,10 +246,10 @@ class coinbase extends coinbase$1 {
|
|
|
231
246
|
'datetime': this.iso8601(timestamp),
|
|
232
247
|
'high': this.safeString(ticker, 'high_24_h'),
|
|
233
248
|
'low': this.safeString(ticker, 'low_24_h'),
|
|
234
|
-
'bid':
|
|
235
|
-
'bidVolume':
|
|
236
|
-
'ask':
|
|
237
|
-
'askVolume':
|
|
249
|
+
'bid': this.safeString(ticker, 'best_bid'),
|
|
250
|
+
'bidVolume': this.safeString(ticker, 'best_bid_quantity'),
|
|
251
|
+
'ask': this.safeString(ticker, 'best_ask'),
|
|
252
|
+
'askVolume': this.safeString(ticker, 'best_ask_quantity'),
|
|
238
253
|
'vwap': undefined,
|
|
239
254
|
'open': undefined,
|
|
240
255
|
'close': last,
|
|
@@ -851,7 +851,11 @@ class poloniexfutures extends poloniexfutures$1 {
|
|
|
851
851
|
const sequence = this.safeInteger(delta, 'sequence');
|
|
852
852
|
const nonce = this.safeInteger(orderbook, 'nonce');
|
|
853
853
|
if (nonce !== sequence - 1) {
|
|
854
|
-
|
|
854
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
855
|
+
if (checksum) {
|
|
856
|
+
// todo: client.reject from handleOrderBookMessage properly
|
|
857
|
+
throw new errors.InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
|
|
858
|
+
}
|
|
855
859
|
}
|
|
856
860
|
const change = this.safeString(delta, 'change');
|
|
857
861
|
const splitChange = change.split(',');
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.96";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.97';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -82,6 +82,7 @@ interface Exchange {
|
|
|
82
82
|
v3PrivatePostBrokerageConvertTradeTradeId(params?: {}): Promise<implicitReturnType>;
|
|
83
83
|
v3PrivatePostBrokerageCfmSweepsSchedule(params?: {}): Promise<implicitReturnType>;
|
|
84
84
|
v3PrivatePostBrokerageIntxAllocate(params?: {}): Promise<implicitReturnType>;
|
|
85
|
+
v3PrivatePostBrokerageOrdersClosePosition(params?: {}): Promise<implicitReturnType>;
|
|
85
86
|
v3PrivatePutBrokeragePortfoliosPortfolioUuid(params?: {}): Promise<implicitReturnType>;
|
|
86
87
|
v3PrivateDeleteBrokeragePortfoliosPortfolioUuid(params?: {}): Promise<implicitReturnType>;
|
|
87
88
|
v3PrivateDeleteBrokerageCfmSweeps(params?: {}): Promise<implicitReturnType>;
|
|
@@ -860,7 +860,7 @@ export default class Exchange {
|
|
|
860
860
|
handleOptionAndParams(params: object, methodName: string, optionName: string, defaultValue?: any): any[];
|
|
861
861
|
handleOptionAndParams2(params: object, methodName: string, methodName2: string, optionName: string, defaultValue?: any): any[];
|
|
862
862
|
handleOption(methodName: string, optionName: string, defaultValue?: any): any;
|
|
863
|
-
handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}): any;
|
|
863
|
+
handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}, defaultValue?: any): any;
|
|
864
864
|
handleSubTypeAndParams(methodName: string, market?: any, params?: {}, defaultValue?: any): any[];
|
|
865
865
|
handleMarginModeAndParams(methodName: string, params?: {}, defaultValue?: any): any[];
|
|
866
866
|
throwExactlyMatchedException(exact: any, string: any, message: any): void;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -4049,11 +4049,26 @@ export default class Exchange {
|
|
|
4049
4049
|
const [result, empty] = this.handleOptionAndParams({}, methodName, optionName, defaultValue);
|
|
4050
4050
|
return result;
|
|
4051
4051
|
}
|
|
4052
|
-
handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
|
|
4052
|
+
handleMarketTypeAndParams(methodName, market = undefined, params = {}, defaultValue = undefined) {
|
|
4053
|
+
/**
|
|
4054
|
+
* @ignore
|
|
4055
|
+
* @method
|
|
4056
|
+
* @name exchange#handleMarketTypeAndParams
|
|
4057
|
+
* @param methodName the method calling handleMarketTypeAndParams
|
|
4058
|
+
* @param {Market} market
|
|
4059
|
+
* @param {object} params
|
|
4060
|
+
* @param {string} [params.type] type assigned by user
|
|
4061
|
+
* @param {string} [params.defaultType] same as params.type
|
|
4062
|
+
* @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
|
|
4063
|
+
* @returns {[string, object]} the market type and params with type and defaultType omitted
|
|
4064
|
+
*/
|
|
4053
4065
|
const defaultType = this.safeString2(this.options, 'defaultType', 'type', 'spot');
|
|
4066
|
+
if (defaultValue === undefined) { // defaultValue takes precendence over exchange wide defaultType
|
|
4067
|
+
defaultValue = defaultType;
|
|
4068
|
+
}
|
|
4054
4069
|
const methodOptions = this.safeDict(this.options, methodName);
|
|
4055
|
-
let methodType =
|
|
4056
|
-
if (methodOptions !== undefined) {
|
|
4070
|
+
let methodType = defaultValue;
|
|
4071
|
+
if (methodOptions !== undefined) { // user defined methodType takes precedence over defaultValue
|
|
4057
4072
|
if (typeof methodOptions === 'string') {
|
|
4058
4073
|
methodType = methodOptions;
|
|
4059
4074
|
}
|
|
@@ -5,7 +5,7 @@ import { Hex } from '../../static_dependencies/noble-curves/abstract/utils.js';
|
|
|
5
5
|
declare type Digest = 'binary' | 'hex' | 'base64';
|
|
6
6
|
declare const hash: (request: Input, hash: CHash, digest?: Digest) => any;
|
|
7
7
|
declare const hmac: (request: Input, secret: Input, hash: CHash, digest?: Digest) => any;
|
|
8
|
-
declare function ecdsa(request: Hex, secret: Hex, curve: CurveFn, prehash?: CHash): {
|
|
8
|
+
declare function ecdsa(request: Hex, secret: Hex, curve: CurveFn, prehash?: CHash, fixedLength?: boolean): {
|
|
9
9
|
r: string;
|
|
10
10
|
s: string;
|
|
11
11
|
v: number;
|
|
@@ -11,6 +11,7 @@ import { Base64 } from '../../static_dependencies/jsencrypt/lib/asn1js/base64.js
|
|
|
11
11
|
import { ASN1 } from "../../static_dependencies/jsencrypt/lib/asn1js/asn1.js";
|
|
12
12
|
import { secp256k1 } from '../../static_dependencies/noble-curves/secp256k1.js';
|
|
13
13
|
import { P256 } from '../../static_dependencies/noble-curves/p256.js';
|
|
14
|
+
import { numberToBytesLE } from '../../static_dependencies/noble-curves/abstract/utils.js';
|
|
14
15
|
/* ------------------------------------------------------------------------ */
|
|
15
16
|
const encoders = {
|
|
16
17
|
binary: x => x,
|
|
@@ -32,7 +33,7 @@ const hmac = (request, secret, hash, digest = 'hex') => {
|
|
|
32
33
|
return encoders[digest](binary);
|
|
33
34
|
};
|
|
34
35
|
/* ............................................. */
|
|
35
|
-
function ecdsa(request, secret, curve, prehash = null) {
|
|
36
|
+
function ecdsa(request, secret, curve, prehash = null, fixedLength = false) {
|
|
36
37
|
if (prehash) {
|
|
37
38
|
request = hash(request, prehash, 'hex');
|
|
38
39
|
}
|
|
@@ -66,7 +67,19 @@ function ecdsa(request, secret, curve, prehash = null) {
|
|
|
66
67
|
throw new Error('Unsupported key format');
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
let signature = curve.sign(request, secret, {
|
|
71
|
+
lowS: true,
|
|
72
|
+
});
|
|
73
|
+
const minimumSize = (BigInt(1) << (BigInt(8) * BigInt(31))) - BigInt(1);
|
|
74
|
+
const halfOrder = curve.CURVE.n / BigInt(2);
|
|
75
|
+
let counter = 0;
|
|
76
|
+
while (fixedLength && (signature.r > halfOrder || signature.r <= minimumSize || signature.s <= minimumSize)) {
|
|
77
|
+
signature = curve.sign(request, secret, {
|
|
78
|
+
lowS: true,
|
|
79
|
+
extraEntropy: numberToBytesLE(BigInt(counter), 32)
|
|
80
|
+
});
|
|
81
|
+
counter += 1;
|
|
82
|
+
}
|
|
70
83
|
return {
|
|
71
84
|
'r': signature.r.toString(16),
|
|
72
85
|
's': signature.s.toString(16),
|
|
@@ -40,8 +40,8 @@ function jwt(request, secret, hash, isRSA = false, opts = {}) {
|
|
|
40
40
|
}
|
|
41
41
|
else if (algoType === 'ES') {
|
|
42
42
|
const signedHash = ecdsa(token, utf8.encode(secret), P256, hash);
|
|
43
|
-
const r =
|
|
44
|
-
const s =
|
|
43
|
+
const r = signedHash.r.padStart(64, '0');
|
|
44
|
+
const s = signedHash.s.padStart(64, '0');
|
|
45
45
|
signature = urlencodeBase64(binaryToBase64(base16ToBinary(r + s)));
|
|
46
46
|
}
|
|
47
47
|
return [token, signature].join('.');
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ interface IOrderBookSide<T> extends Array<T> {
|
|
|
4
4
|
storeArray(array: any[]): any;
|
|
5
5
|
limit(): any;
|
|
6
6
|
}
|
|
7
|
-
declare class OrderBookSide implements IOrderBookSide
|
|
7
|
+
declare class OrderBookSide extends Array implements IOrderBookSide {
|
|
8
8
|
constructor(deltas?: any[], depth?: any);
|
|
9
9
|
storeArray(delta: any): void;
|
|
10
10
|
store(price: any, size: any): void;
|
|
@@ -14,7 +14,7 @@ declare class CountedOrderBookSide extends OrderBookSide {
|
|
|
14
14
|
store(price: any, size: any, count: any): void;
|
|
15
15
|
storeArray(delta: any): void;
|
|
16
16
|
}
|
|
17
|
-
declare class IndexedOrderBookSide implements IOrderBookSide
|
|
17
|
+
declare class IndexedOrderBookSide extends Array implements IOrderBookSide {
|
|
18
18
|
constructor(deltas?: any[], depth?: number);
|
|
19
19
|
store(price: any, size: any, id: any): void;
|
|
20
20
|
storeArray(delta: any): void;
|
package/js/src/binance.js
CHANGED
|
@@ -5799,7 +5799,7 @@ export default class binance extends Exchange {
|
|
|
5799
5799
|
response = await this.dapiPrivatePostOrder(request);
|
|
5800
5800
|
}
|
|
5801
5801
|
}
|
|
5802
|
-
else if (marketType === 'margin' || marginMode !== undefined) {
|
|
5802
|
+
else if (marketType === 'margin' || marginMode !== undefined || isPortfolioMargin) {
|
|
5803
5803
|
if (isPortfolioMargin) {
|
|
5804
5804
|
response = await this.papiPostMarginOrder(request);
|
|
5805
5805
|
}
|
|
@@ -5901,15 +5901,6 @@ export default class binance extends Exchange {
|
|
|
5901
5901
|
uppercaseType = market['contract'] ? 'TAKE_PROFIT' : 'TAKE_PROFIT_LIMIT';
|
|
5902
5902
|
}
|
|
5903
5903
|
}
|
|
5904
|
-
if ((marketType === 'spot') || (marketType === 'margin')) {
|
|
5905
|
-
request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'RESULT'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
|
|
5906
|
-
}
|
|
5907
|
-
else {
|
|
5908
|
-
// swap, futures and options
|
|
5909
|
-
if (!isPortfolioMargin) {
|
|
5910
|
-
request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
|
|
5911
|
-
}
|
|
5912
|
-
}
|
|
5913
5904
|
if (market['option']) {
|
|
5914
5905
|
if (type === 'market') {
|
|
5915
5906
|
throw new InvalidOrder(this.id + ' ' + type + ' is not a valid order type for the ' + symbol + ' market');
|
|
@@ -5949,6 +5940,14 @@ export default class binance extends Exchange {
|
|
|
5949
5940
|
}
|
|
5950
5941
|
}
|
|
5951
5942
|
}
|
|
5943
|
+
// handle newOrderRespType response type
|
|
5944
|
+
if (((marketType === 'spot') || (marketType === 'margin')) && !isPortfolioMargin) {
|
|
5945
|
+
request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'FULL'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
|
|
5946
|
+
}
|
|
5947
|
+
else {
|
|
5948
|
+
// swap, futures and options
|
|
5949
|
+
request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
|
|
5950
|
+
}
|
|
5952
5951
|
const typeRequest = isPortfolioMarginConditional ? 'strategyType' : 'type';
|
|
5953
5952
|
request[typeRequest] = uppercaseType;
|
|
5954
5953
|
// additional required fields depending on the order type
|
|
@@ -6602,7 +6601,7 @@ export default class binance extends Exchange {
|
|
|
6602
6601
|
response = await this.dapiPrivateGetOpenOrders(this.extend(request, params));
|
|
6603
6602
|
}
|
|
6604
6603
|
}
|
|
6605
|
-
else if (type === 'margin' || marginMode !== undefined) {
|
|
6604
|
+
else if (type === 'margin' || marginMode !== undefined || isPortfolioMargin) {
|
|
6606
6605
|
if (isPortfolioMargin) {
|
|
6607
6606
|
response = await this.papiGetMarginOpenOrders(this.extend(request, params));
|
|
6608
6607
|
}
|
|
@@ -7103,7 +7102,7 @@ export default class binance extends Exchange {
|
|
|
7103
7102
|
response = await this.dapiPrivateDeleteAllOpenOrders(this.extend(request, params));
|
|
7104
7103
|
}
|
|
7105
7104
|
}
|
|
7106
|
-
else if ((type === 'margin') || (marginMode !== undefined)) {
|
|
7105
|
+
else if ((type === 'margin') || (marginMode !== undefined) || isPortfolioMargin) {
|
|
7107
7106
|
if (isPortfolioMargin) {
|
|
7108
7107
|
response = await this.papiDeleteMarginAllOpenOrders(this.extend(request, params));
|
|
7109
7108
|
}
|
package/js/src/coinbase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/coinbase.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class coinbase
|
|
5
5
|
* @augments Exchange
|
|
@@ -10,6 +10,7 @@ export default class coinbase extends Exchange {
|
|
|
10
10
|
fetchAccounts(params?: {}): Promise<Account[]>;
|
|
11
11
|
fetchAccountsV2(params?: {}): Promise<Account[]>;
|
|
12
12
|
fetchAccountsV3(params?: {}): Promise<Account[]>;
|
|
13
|
+
fetchPortfolios(params?: {}): Promise<Account[]>;
|
|
13
14
|
parseAccount(account: any): {
|
|
14
15
|
id: string;
|
|
15
16
|
type: string;
|
|
@@ -33,6 +34,8 @@ export default class coinbase extends Exchange {
|
|
|
33
34
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
34
35
|
fetchMarketsV2(params?: {}): Promise<any[]>;
|
|
35
36
|
fetchMarketsV3(params?: {}): Promise<any[]>;
|
|
37
|
+
parseSpotMarket(market: any, feeTier: any): MarketInterface;
|
|
38
|
+
parseContractMarket(market: any, feeTier: any): MarketInterface;
|
|
36
39
|
fetchCurrenciesFromCache(params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
|
|
37
40
|
fetchCurrencies(params?: {}): Promise<Currencies>;
|
|
38
41
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
@@ -101,6 +104,10 @@ export default class coinbase extends Exchange {
|
|
|
101
104
|
};
|
|
102
105
|
deposit(code: string, amount: number, id: string, params?: {}): Promise<Transaction>;
|
|
103
106
|
fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
|
|
107
|
+
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
108
|
+
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
109
|
+
fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
|
|
110
|
+
parsePosition(position: any, market?: Market): import("./base/types.js").Position;
|
|
104
111
|
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
105
112
|
url: string;
|
|
106
113
|
method: string;
|