ccxt 4.4.49 → 4.4.53
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 +6 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +65 -2
- package/dist/cjs/src/base/Exchange.js +112 -3
- package/dist/cjs/src/binance.js +42 -19
- package/dist/cjs/src/bitfinex1.js +22 -22
- package/dist/cjs/src/blofin.js +6 -2
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/coinex.js +5 -5
- package/dist/cjs/src/coinmetro.js +21 -4
- package/dist/cjs/src/defx.js +1 -1
- package/dist/cjs/src/deribit.js +23 -4
- package/dist/cjs/src/ellipx.js +1 -0
- package/dist/cjs/src/gate.js +2 -2
- package/dist/cjs/src/hollaex.js +15 -20
- package/dist/cjs/src/htx.js +6 -4
- package/dist/cjs/src/hyperliquid.js +4 -4
- package/dist/cjs/src/krakenfutures.js +1 -1
- package/dist/cjs/src/kucoin.js +52 -74
- package/dist/cjs/src/kuna.js +1 -1
- package/dist/cjs/src/mexc.js +29 -8
- package/dist/cjs/src/okcoin.js +13 -5
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/onetrading.js +1 -1
- package/dist/cjs/src/paradex.js +2 -2
- package/dist/cjs/src/paymium.js +42 -0
- package/dist/cjs/src/pro/binance.js +2 -0
- package/dist/cjs/src/pro/bitfinex1.js +4 -4
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/blofin.js +9 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coincatch.js +2 -2
- package/dist/cjs/src/pro/coinex.js +4 -1
- package/dist/cjs/src/pro/cryptocom.js +2 -2
- package/dist/cjs/src/pro/defx.js +1 -1
- package/dist/cjs/src/pro/exmo.js +1 -1
- package/dist/cjs/src/pro/gemini.js +1 -1
- package/dist/cjs/src/pro/hashkey.js +2 -2
- package/dist/cjs/src/pro/htx.js +8 -8
- package/dist/cjs/src/pro/hyperliquid.js +2 -2
- package/dist/cjs/src/pro/kucoin.js +1 -1
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/oxfun.js +1 -1
- package/dist/cjs/src/probit.js +77 -9
- package/dist/cjs/src/timex.js +67 -0
- package/dist/cjs/src/tokocrypto.js +82 -5
- package/dist/cjs/src/tradeogre.js +55 -2
- package/dist/cjs/src/vertex.js +65 -2
- package/dist/cjs/src/wavesexchange.js +73 -0
- package/dist/cjs/src/wazirx.js +59 -3
- package/dist/cjs/src/whitebit.js +80 -4
- package/dist/cjs/src/xt.js +112 -0
- package/dist/cjs/src/yobit.js +56 -0
- package/dist/cjs/src/zaif.js +55 -0
- package/dist/cjs/src/zonda.js +56 -0
- package/examples/README.md +6 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/alpaca.d.ts +35 -0
- package/js/src/alpaca.js +65 -2
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +112 -3
- package/js/src/binance.d.ts +4 -1
- package/js/src/binance.js +42 -19
- package/js/src/bitfinex1.d.ts +22 -22
- package/js/src/bitfinex1.js +22 -22
- package/js/src/blofin.d.ts +1 -1
- package/js/src/blofin.js +6 -2
- package/js/src/bybit.d.ts +2 -2
- package/js/src/bybit.js +2 -2
- package/js/src/coinex.js +5 -5
- package/js/src/coinmetro.d.ts +1 -1
- package/js/src/coinmetro.js +21 -4
- package/js/src/defx.d.ts +1 -1
- package/js/src/defx.js +1 -1
- package/js/src/deribit.d.ts +1 -1
- package/js/src/deribit.js +23 -4
- package/js/src/ellipx.d.ts +1 -0
- package/js/src/ellipx.js +1 -0
- package/js/src/gate.d.ts +1 -1
- package/js/src/gate.js +2 -2
- package/js/src/hollaex.d.ts +2 -1
- package/js/src/hollaex.js +15 -20
- package/js/src/htx.d.ts +1 -1
- package/js/src/htx.js +6 -4
- package/js/src/hyperliquid.d.ts +3 -3
- package/js/src/hyperliquid.js +4 -4
- package/js/src/krakenfutures.d.ts +1 -1
- package/js/src/krakenfutures.js +1 -1
- package/js/src/kucoin.js +52 -74
- package/js/src/kuna.d.ts +1 -1
- package/js/src/kuna.js +1 -1
- package/js/src/mexc.d.ts +1 -1
- package/js/src/mexc.js +29 -8
- package/js/src/okcoin.js +13 -5
- package/js/src/okx.d.ts +1 -1
- package/js/src/okx.js +1 -1
- package/js/src/onetrading.d.ts +1 -1
- package/js/src/onetrading.js +1 -1
- package/js/src/paradex.d.ts +1 -1
- package/js/src/paradex.js +2 -2
- package/js/src/paymium.js +42 -0
- package/js/src/pro/binance.js +2 -0
- package/js/src/pro/bitfinex1.d.ts +4 -4
- package/js/src/pro/bitfinex1.js +4 -4
- package/js/src/pro/bitvavo.d.ts +1 -1
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/blofin.d.ts +1 -1
- package/js/src/pro/blofin.js +9 -1
- package/js/src/pro/bybit.d.ts +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coincatch.d.ts +2 -2
- package/js/src/pro/coincatch.js +2 -2
- package/js/src/pro/coinex.js +4 -1
- package/js/src/pro/cryptocom.d.ts +2 -2
- package/js/src/pro/cryptocom.js +2 -2
- package/js/src/pro/defx.d.ts +1 -1
- package/js/src/pro/defx.js +1 -1
- package/js/src/pro/exmo.d.ts +1 -1
- package/js/src/pro/exmo.js +1 -1
- package/js/src/pro/gemini.d.ts +1 -1
- package/js/src/pro/gemini.js +1 -1
- package/js/src/pro/hashkey.d.ts +2 -2
- package/js/src/pro/hashkey.js +2 -2
- package/js/src/pro/htx.d.ts +8 -8
- package/js/src/pro/htx.js +8 -8
- package/js/src/pro/hyperliquid.d.ts +2 -2
- package/js/src/pro/hyperliquid.js +2 -2
- package/js/src/pro/kucoin.d.ts +1 -1
- package/js/src/pro/kucoin.js +1 -1
- package/js/src/pro/okx.d.ts +1 -1
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/oxfun.d.ts +1 -1
- package/js/src/pro/oxfun.js +1 -1
- package/js/src/probit.d.ts +1 -0
- package/js/src/probit.js +77 -9
- package/js/src/timex.js +67 -0
- package/js/src/tokocrypto.d.ts +2 -3
- package/js/src/tokocrypto.js +82 -5
- package/js/src/tradeogre.d.ts +4 -2
- package/js/src/tradeogre.js +55 -2
- package/js/src/vertex.js +65 -2
- package/js/src/wavesexchange.js +73 -0
- package/js/src/wazirx.js +59 -3
- package/js/src/whitebit.js +80 -4
- package/js/src/xt.js +112 -0
- package/js/src/yobit.js +56 -0
- package/js/src/zaif.js +55 -0
- package/js/src/zonda.d.ts +1 -0
- package/js/src/zonda.js +56 -0
- package/package.json +2 -2
- package/js/src/hitbtc3.d.ts +0 -8
- package/js/src/hitbtc3.js +0 -20
package/js/src/base/Exchange.js
CHANGED
|
@@ -2295,6 +2295,11 @@ export default class Exchange {
|
|
|
2295
2295
|
const res = this.parseToNumeric((value % 1));
|
|
2296
2296
|
return res === 0;
|
|
2297
2297
|
}
|
|
2298
|
+
safeNumberOmitZero(obj, key, defaultValue = undefined) {
|
|
2299
|
+
const value = this.safeString(obj, key);
|
|
2300
|
+
const final = this.parseNumber(this.omitZero(value));
|
|
2301
|
+
return (final === undefined) ? defaultValue : final;
|
|
2302
|
+
}
|
|
2298
2303
|
safeIntegerOmitZero(obj, key, defaultValue = undefined) {
|
|
2299
2304
|
const timestamp = this.safeInteger(obj, key, defaultValue);
|
|
2300
2305
|
if (timestamp === undefined || timestamp === 0) {
|
|
@@ -2390,13 +2395,16 @@ export default class Exchange {
|
|
|
2390
2395
|
featuresObj['createOrder']['stopLoss'] = value;
|
|
2391
2396
|
featuresObj['createOrder']['takeProfit'] = value;
|
|
2392
2397
|
}
|
|
2393
|
-
// for spot, default 'hedged' to false
|
|
2394
2398
|
if (marketType === 'spot') {
|
|
2399
|
+
// default 'hedged': false
|
|
2395
2400
|
featuresObj['createOrder']['hedged'] = false;
|
|
2401
|
+
// default 'leverage': false
|
|
2402
|
+
if (!('leverage' in featuresObj['createOrder'])) {
|
|
2403
|
+
featuresObj['createOrder']['leverage'] = false;
|
|
2404
|
+
}
|
|
2396
2405
|
}
|
|
2397
2406
|
// default 'GTC' to true
|
|
2398
|
-
|
|
2399
|
-
if (gtcValue === undefined) {
|
|
2407
|
+
if (this.safeBool(featuresObj['createOrder']['timeInForce'], 'GTC') === undefined) {
|
|
2400
2408
|
featuresObj['createOrder']['timeInForce']['GTC'] = true;
|
|
2401
2409
|
}
|
|
2402
2410
|
}
|
|
@@ -2469,6 +2477,81 @@ export default class Exchange {
|
|
|
2469
2477
|
};
|
|
2470
2478
|
}
|
|
2471
2479
|
safeCurrencyStructure(currency) {
|
|
2480
|
+
// derive data from networks: deposit, withdraw, active, fee, limits, precision
|
|
2481
|
+
const networks = this.safeDict(currency, 'networks', {});
|
|
2482
|
+
const keys = Object.keys(networks);
|
|
2483
|
+
const length = keys.length;
|
|
2484
|
+
if (length !== 0) {
|
|
2485
|
+
for (let i = 0; i < length; i++) {
|
|
2486
|
+
const network = networks[keys[i]];
|
|
2487
|
+
const deposit = this.safeBool(network, 'deposit');
|
|
2488
|
+
if (currency['deposit'] === undefined || deposit) {
|
|
2489
|
+
currency['deposit'] = deposit;
|
|
2490
|
+
}
|
|
2491
|
+
const withdraw = this.safeBool(network, 'withdraw');
|
|
2492
|
+
if (currency['withdraw'] === undefined || withdraw) {
|
|
2493
|
+
currency['withdraw'] = withdraw;
|
|
2494
|
+
}
|
|
2495
|
+
const active = this.safeBool(network, 'active');
|
|
2496
|
+
if (currency['active'] === undefined || active) {
|
|
2497
|
+
currency['active'] = active;
|
|
2498
|
+
}
|
|
2499
|
+
// find lowest fee (which is more desired)
|
|
2500
|
+
const fee = this.safeString(network, 'fee');
|
|
2501
|
+
const feeMain = this.safeString(currency, 'fee');
|
|
2502
|
+
if (feeMain === undefined || Precise.stringLt(fee, feeMain)) {
|
|
2503
|
+
currency['fee'] = this.parseNumber(fee);
|
|
2504
|
+
}
|
|
2505
|
+
// find lowest precision (which is more desired)
|
|
2506
|
+
const precision = this.safeString(network, 'precision');
|
|
2507
|
+
const precisionMain = this.safeString(currency, 'precision');
|
|
2508
|
+
if (precisionMain === undefined || Precise.stringLt(precision, precisionMain)) {
|
|
2509
|
+
currency['precision'] = this.parseNumber(precision);
|
|
2510
|
+
}
|
|
2511
|
+
// limits
|
|
2512
|
+
const limits = this.safeDict(network, 'limits');
|
|
2513
|
+
const limitsMain = this.safeDict(currency, 'limits');
|
|
2514
|
+
if (limitsMain === undefined) {
|
|
2515
|
+
currency['limits'] = {};
|
|
2516
|
+
}
|
|
2517
|
+
// deposits
|
|
2518
|
+
const limitsDeposit = this.safeDict(limits, 'deposit');
|
|
2519
|
+
const limitsDepositMain = this.safeDict(limitsMain, 'deposit');
|
|
2520
|
+
if (limitsDepositMain === undefined) {
|
|
2521
|
+
currency['limits']['deposit'] = {};
|
|
2522
|
+
}
|
|
2523
|
+
const limitsDepositMin = this.safeString(limitsDeposit, 'min');
|
|
2524
|
+
const limitsDepositMax = this.safeString(limitsDeposit, 'max');
|
|
2525
|
+
const limitsDepositMinMain = this.safeString(limitsDepositMain, 'min');
|
|
2526
|
+
const limitsDepositMaxMain = this.safeString(limitsDepositMain, 'max');
|
|
2527
|
+
// find min
|
|
2528
|
+
if (limitsDepositMinMain === undefined || Precise.stringLt(limitsDepositMin, limitsDepositMinMain)) {
|
|
2529
|
+
currency['limits']['deposit']['min'] = this.parseNumber(limitsDepositMin);
|
|
2530
|
+
}
|
|
2531
|
+
// find max
|
|
2532
|
+
if (limitsDepositMaxMain === undefined || Precise.stringGt(limitsDepositMax, limitsDepositMaxMain)) {
|
|
2533
|
+
currency['limits']['deposit']['max'] = this.parseNumber(limitsDepositMax);
|
|
2534
|
+
}
|
|
2535
|
+
// withdrawals
|
|
2536
|
+
const limitsWithdraw = this.safeDict(limits, 'withdraw');
|
|
2537
|
+
const limitsWithdrawMain = this.safeDict(limitsMain, 'withdraw');
|
|
2538
|
+
if (limitsWithdrawMain === undefined) {
|
|
2539
|
+
currency['limits']['withdraw'] = {};
|
|
2540
|
+
}
|
|
2541
|
+
const limitsWithdrawMin = this.safeString(limitsWithdraw, 'min');
|
|
2542
|
+
const limitsWithdrawMax = this.safeString(limitsWithdraw, 'max');
|
|
2543
|
+
const limitsWithdrawMinMain = this.safeString(limitsWithdrawMain, 'min');
|
|
2544
|
+
const limitsWithdrawMaxMain = this.safeString(limitsWithdrawMain, 'max');
|
|
2545
|
+
// find min
|
|
2546
|
+
if (limitsWithdrawMinMain === undefined || Precise.stringLt(limitsWithdrawMin, limitsWithdrawMinMain)) {
|
|
2547
|
+
currency['limits']['withdraw']['min'] = this.parseNumber(limitsWithdrawMin);
|
|
2548
|
+
}
|
|
2549
|
+
// find max
|
|
2550
|
+
if (limitsWithdrawMaxMain === undefined || Precise.stringGt(limitsWithdrawMax, limitsWithdrawMaxMain)) {
|
|
2551
|
+
currency['limits']['withdraw']['max'] = this.parseNumber(limitsWithdrawMax);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2472
2555
|
return this.extend({
|
|
2473
2556
|
'info': undefined,
|
|
2474
2557
|
'id': undefined,
|
|
@@ -5739,6 +5822,32 @@ export default class Exchange {
|
|
|
5739
5822
|
const symbol = (market === undefined) ? undefined : market['symbol'];
|
|
5740
5823
|
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
5741
5824
|
}
|
|
5825
|
+
handleTriggerDirectionAndParams(params, exchangeSpecificKey = undefined, allowEmpty = false) {
|
|
5826
|
+
/**
|
|
5827
|
+
* @ignore
|
|
5828
|
+
* @method
|
|
5829
|
+
* @returns {[string, object]} the trigger-direction value and omited params
|
|
5830
|
+
*/
|
|
5831
|
+
let triggerDirection = this.safeString(params, 'triggerDirection');
|
|
5832
|
+
const exchangeSpecificDefined = (exchangeSpecificKey !== undefined) && (exchangeSpecificKey in params);
|
|
5833
|
+
if (triggerDirection !== undefined) {
|
|
5834
|
+
params = this.omit(params, 'triggerDirection');
|
|
5835
|
+
}
|
|
5836
|
+
// throw exception if:
|
|
5837
|
+
// A) if provided value is not unified (support old "up/down" strings too)
|
|
5838
|
+
// B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
|
|
5839
|
+
if (!this.inArray(triggerDirection, ['ascending', 'descending', 'up', 'down', 'above', 'below']) && !exchangeSpecificDefined && !allowEmpty) {
|
|
5840
|
+
throw new ArgumentsRequired(this.id + ' createOrder() : trigger orders require params["triggerDirection"] to be either "ascending" or "descending"');
|
|
5841
|
+
}
|
|
5842
|
+
// if old format was provided, overwrite to new
|
|
5843
|
+
if (triggerDirection === 'up' || triggerDirection === 'above') {
|
|
5844
|
+
triggerDirection = 'ascending';
|
|
5845
|
+
}
|
|
5846
|
+
else if (triggerDirection === 'down' || triggerDirection === 'below') {
|
|
5847
|
+
triggerDirection = 'descending';
|
|
5848
|
+
}
|
|
5849
|
+
return [triggerDirection, params];
|
|
5850
|
+
}
|
|
5742
5851
|
handleTriggerAndParams(params) {
|
|
5743
5852
|
const isTrigger = this.safeBool2(params, 'trigger', 'stop');
|
|
5744
5853
|
if (isTrigger) {
|
package/js/src/binance.d.ts
CHANGED
|
@@ -324,7 +324,7 @@ export default class binance extends Exchange {
|
|
|
324
324
|
* @method
|
|
325
325
|
* @name binance#createOrder
|
|
326
326
|
* @description create a trade order
|
|
327
|
-
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/
|
|
327
|
+
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
|
|
328
328
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade
|
|
329
329
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
|
|
330
330
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/New-Order
|
|
@@ -352,6 +352,8 @@ export default class binance extends Exchange {
|
|
|
352
352
|
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
|
|
353
353
|
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
|
|
354
354
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
|
|
355
|
+
* @param {string} [params.selfTradePrevention] set unified value for stp (see .features for available values)
|
|
356
|
+
* @param {float} [params.icebergAmount] set iceberg amount for limit orders
|
|
355
357
|
* @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
|
|
356
358
|
* @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
|
357
359
|
* @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
|
|
@@ -476,6 +478,7 @@ export default class binance extends Exchange {
|
|
|
476
478
|
* @param {string} symbol unified market symbol
|
|
477
479
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
478
480
|
* @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
|
481
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch for a portfolio margin account
|
|
479
482
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
480
483
|
*/
|
|
481
484
|
fetchOpenOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
package/js/src/binance.js
CHANGED
|
@@ -482,6 +482,7 @@ export default class binance extends Exchange {
|
|
|
482
482
|
'portfolio/repay-futures-switch': 3,
|
|
483
483
|
'portfolio/margin-asset-leverage': 5,
|
|
484
484
|
'portfolio/balance': 2,
|
|
485
|
+
'portfolio/negative-balance-exchange-record': 2,
|
|
485
486
|
// staking
|
|
486
487
|
'staking/productList': 0.1,
|
|
487
488
|
'staking/position': 0.1,
|
|
@@ -1587,12 +1588,16 @@ export default class binance extends Exchange {
|
|
|
1587
1588
|
},
|
|
1588
1589
|
'hedged': true,
|
|
1589
1590
|
'leverage': false,
|
|
1590
|
-
'marketBuyRequiresPrice': false,
|
|
1591
1591
|
'marketBuyByCost': true,
|
|
1592
|
-
|
|
1593
|
-
'selfTradePrevention':
|
|
1594
|
-
|
|
1595
|
-
|
|
1592
|
+
'marketBuyRequiresPrice': false,
|
|
1593
|
+
'selfTradePrevention': {
|
|
1594
|
+
'expire_maker': true,
|
|
1595
|
+
'expire_taker': true,
|
|
1596
|
+
'expire_both': true,
|
|
1597
|
+
'none': true,
|
|
1598
|
+
},
|
|
1599
|
+
'trailing': false,
|
|
1600
|
+
'icebergAmount': true,
|
|
1596
1601
|
},
|
|
1597
1602
|
'createOrders': undefined,
|
|
1598
1603
|
'fetchMyTrades': {
|
|
@@ -1633,7 +1638,7 @@ export default class binance extends Exchange {
|
|
|
1633
1638
|
'limit': 1000,
|
|
1634
1639
|
},
|
|
1635
1640
|
},
|
|
1636
|
-
'
|
|
1641
|
+
'forDerivatives': {
|
|
1637
1642
|
'sandbox': true,
|
|
1638
1643
|
'createOrder': {
|
|
1639
1644
|
'marginMode': false,
|
|
@@ -1705,18 +1710,18 @@ export default class binance extends Exchange {
|
|
|
1705
1710
|
},
|
|
1706
1711
|
'swap': {
|
|
1707
1712
|
'linear': {
|
|
1708
|
-
'extends': '
|
|
1713
|
+
'extends': 'forDerivatives',
|
|
1709
1714
|
},
|
|
1710
1715
|
'inverse': {
|
|
1711
|
-
'extends': '
|
|
1716
|
+
'extends': 'forDerivatives',
|
|
1712
1717
|
},
|
|
1713
1718
|
},
|
|
1714
1719
|
'future': {
|
|
1715
1720
|
'linear': {
|
|
1716
|
-
'extends': '
|
|
1721
|
+
'extends': 'forDerivatives',
|
|
1717
1722
|
},
|
|
1718
1723
|
'inverse': {
|
|
1719
|
-
'extends': '
|
|
1724
|
+
'extends': 'forDerivatives',
|
|
1720
1725
|
},
|
|
1721
1726
|
},
|
|
1722
1727
|
},
|
|
@@ -4512,12 +4517,11 @@ export default class binance extends Exchange {
|
|
|
4512
4517
|
const type = (timestamp === undefined) ? 'spot' : 'swap';
|
|
4513
4518
|
const marketId = this.safeString(entry, 'symbol');
|
|
4514
4519
|
market = this.safeMarket(marketId, market, undefined, type);
|
|
4515
|
-
const price = this.safeNumber(entry, 'price');
|
|
4516
4520
|
return {
|
|
4517
4521
|
'symbol': market['symbol'],
|
|
4518
4522
|
'timestamp': timestamp,
|
|
4519
4523
|
'datetime': this.iso8601(timestamp),
|
|
4520
|
-
'price': price,
|
|
4524
|
+
'price': this.safeNumberOmitZero(entry, 'price'),
|
|
4521
4525
|
'side': undefined,
|
|
4522
4526
|
'info': entry,
|
|
4523
4527
|
};
|
|
@@ -5161,12 +5165,14 @@ export default class binance extends Exchange {
|
|
|
5161
5165
|
request['endTime'] = until;
|
|
5162
5166
|
}
|
|
5163
5167
|
}
|
|
5168
|
+
let method = this.safeString(this.options, 'fetchTradesMethod');
|
|
5169
|
+
method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
|
|
5164
5170
|
if (limit !== undefined) {
|
|
5165
5171
|
const isFutureOrSwap = (market['swap'] || market['future']);
|
|
5166
|
-
|
|
5172
|
+
const isHistoricalEndpoint = (method !== undefined) && (method.indexOf('GetHistoricalTrades') >= 0);
|
|
5173
|
+
const maxLimitForContractHistorical = isHistoricalEndpoint ? 500 : 1000;
|
|
5174
|
+
request['limit'] = isFutureOrSwap ? Math.min(limit, maxLimitForContractHistorical) : limit; // default = 500, maximum = 1000
|
|
5167
5175
|
}
|
|
5168
|
-
let method = this.safeString(this.options, 'fetchTradesMethod');
|
|
5169
|
-
method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
|
|
5170
5176
|
params = this.omit(params, ['until', 'fetchTradesMethod']);
|
|
5171
5177
|
let response = undefined;
|
|
5172
5178
|
if (market['option'] || method === 'eapiPublicGetTrades') {
|
|
@@ -6244,7 +6250,7 @@ export default class binance extends Exchange {
|
|
|
6244
6250
|
* @method
|
|
6245
6251
|
* @name binance#createOrder
|
|
6246
6252
|
* @description create a trade order
|
|
6247
|
-
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/
|
|
6253
|
+
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
|
|
6248
6254
|
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade
|
|
6249
6255
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
|
|
6250
6256
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/New-Order
|
|
@@ -6272,6 +6278,8 @@ export default class binance extends Exchange {
|
|
|
6272
6278
|
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
|
|
6273
6279
|
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
|
|
6274
6280
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
|
|
6281
|
+
* @param {string} [params.selfTradePrevention] set unified value for stp (see .features for available values)
|
|
6282
|
+
* @param {float} [params.icebergAmount] set iceberg amount for limit orders
|
|
6275
6283
|
* @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
|
|
6276
6284
|
* @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
|
6277
6285
|
* @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
|
|
@@ -6658,7 +6666,7 @@ export default class binance extends Exchange {
|
|
|
6658
6666
|
}
|
|
6659
6667
|
}
|
|
6660
6668
|
if (timeInForceIsRequired && (this.safeString(params, 'timeInForce') === undefined) && (this.safeString(request, 'timeInForce') === undefined)) {
|
|
6661
|
-
request['timeInForce'] = this.options
|
|
6669
|
+
request['timeInForce'] = this.safeString(this.options, 'defaultTimeInForce'); // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
|
|
6662
6670
|
}
|
|
6663
6671
|
if (!isPortfolioMargin && market['contract'] && postOnly) {
|
|
6664
6672
|
request['timeInForce'] = 'GTX';
|
|
@@ -6675,7 +6683,21 @@ export default class binance extends Exchange {
|
|
|
6675
6683
|
}
|
|
6676
6684
|
request['positionSide'] = (side === 'buy') ? 'LONG' : 'SHORT';
|
|
6677
6685
|
}
|
|
6678
|
-
|
|
6686
|
+
// unified stp
|
|
6687
|
+
const selfTradePrevention = this.safeString(params, 'selfTradePrevention');
|
|
6688
|
+
if (selfTradePrevention !== undefined) {
|
|
6689
|
+
if (market['spot']) {
|
|
6690
|
+
request['selfTradePreventionMode'] = selfTradePrevention.toUpperCase(); // binance enums exactly match the unified ccxt enums (but needs uppercase)
|
|
6691
|
+
}
|
|
6692
|
+
}
|
|
6693
|
+
// unified iceberg
|
|
6694
|
+
const icebergAmount = this.safeNumber(params, 'icebergAmount');
|
|
6695
|
+
if (icebergAmount !== undefined) {
|
|
6696
|
+
if (market['spot']) {
|
|
6697
|
+
request['icebergQty'] = this.amountToPrecision(symbol, icebergAmount);
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
const requestParams = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test', 'hedged', 'selfTradePrevention', 'icebergAmount']);
|
|
6679
6701
|
return this.extend(request, requestParams);
|
|
6680
6702
|
}
|
|
6681
6703
|
/**
|
|
@@ -7220,6 +7242,7 @@ export default class binance extends Exchange {
|
|
|
7220
7242
|
* @param {string} symbol unified market symbol
|
|
7221
7243
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7222
7244
|
* @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
|
7245
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch for a portfolio margin account
|
|
7223
7246
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
7224
7247
|
*/
|
|
7225
7248
|
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
@@ -10820,7 +10843,7 @@ export default class binance extends Exchange {
|
|
|
10820
10843
|
// }
|
|
10821
10844
|
//
|
|
10822
10845
|
const marketId = this.safeString(position, 'symbol');
|
|
10823
|
-
market = this.safeMarket(marketId, market);
|
|
10846
|
+
market = this.safeMarket(marketId, market, undefined, 'swap');
|
|
10824
10847
|
const symbol = market['symbol'];
|
|
10825
10848
|
const side = this.safeStringLower(position, 'side');
|
|
10826
10849
|
let quantity = this.safeString(position, 'quantity');
|
package/js/src/bitfinex1.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
8
8
|
describe(): any;
|
|
9
9
|
/**
|
|
10
10
|
* @method
|
|
11
|
-
* @name
|
|
11
|
+
* @name bitfinex1#fetchTransactionFees
|
|
12
12
|
* @deprecated
|
|
13
13
|
* @description please use fetchDepositWithdrawFees instead
|
|
14
14
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-fees
|
|
@@ -19,7 +19,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
19
19
|
fetchTransactionFees(codes?: Strings, params?: {}): Promise<Dict>;
|
|
20
20
|
/**
|
|
21
21
|
* @method
|
|
22
|
-
* @name
|
|
22
|
+
* @name bitfinex1#fetchDepositWithdrawFees
|
|
23
23
|
* @description fetch deposit and withdraw fees
|
|
24
24
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-fees
|
|
25
25
|
* @param {string[]|undefined} codes list of unified currency codes
|
|
@@ -41,7 +41,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* @method
|
|
44
|
-
* @name
|
|
44
|
+
* @name bitfinex1#fetchTradingFees
|
|
45
45
|
* @description fetch the trading fees for multiple markets
|
|
46
46
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-summary
|
|
47
47
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -50,7 +50,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
50
50
|
fetchTradingFees(params?: {}): Promise<TradingFees>;
|
|
51
51
|
/**
|
|
52
52
|
* @method
|
|
53
|
-
* @name
|
|
53
|
+
* @name bitfinex1#fetchMarkets
|
|
54
54
|
* @description retrieves data on all markets for bitfinex
|
|
55
55
|
* @see https://docs.bitfinex.com/v1/reference/rest-public-symbols
|
|
56
56
|
* @see https://docs.bitfinex.com/v1/reference/rest-public-symbol-details
|
|
@@ -62,7 +62,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
62
62
|
priceToPrecision(symbol: any, price: any): string;
|
|
63
63
|
/**
|
|
64
64
|
* @method
|
|
65
|
-
* @name
|
|
65
|
+
* @name bitfinex1#fetchBalance
|
|
66
66
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
67
67
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-wallet-balances
|
|
68
68
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -71,7 +71,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
71
71
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
72
72
|
/**
|
|
73
73
|
* @method
|
|
74
|
-
* @name
|
|
74
|
+
* @name bitfinex1#transfer
|
|
75
75
|
* @description transfer currency internally between wallets on the same account
|
|
76
76
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-transfer-between-wallets
|
|
77
77
|
* @param {string} code unified currency code
|
|
@@ -87,7 +87,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
87
87
|
convertDerivativesId(currencyId: any, type: any): any;
|
|
88
88
|
/**
|
|
89
89
|
* @method
|
|
90
|
-
* @name
|
|
90
|
+
* @name bitfinex1#fetchOrderBook
|
|
91
91
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
92
92
|
* @see https://docs.bitfinex.com/v1/reference/rest-public-orderbook
|
|
93
93
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
@@ -98,7 +98,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
98
98
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
99
99
|
/**
|
|
100
100
|
* @method
|
|
101
|
-
* @name
|
|
101
|
+
* @name bitfinex1#fetchTickers
|
|
102
102
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
103
103
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
104
104
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -107,7 +107,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
107
107
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
108
108
|
/**
|
|
109
109
|
* @method
|
|
110
|
-
* @name
|
|
110
|
+
* @name bitfinex1#fetchTicker
|
|
111
111
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
112
112
|
* @see https://docs.bitfinex.com/v1/reference/rest-public-ticker
|
|
113
113
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
@@ -119,7 +119,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
119
119
|
parseTrade(trade: Dict, market?: Market): Trade;
|
|
120
120
|
/**
|
|
121
121
|
* @method
|
|
122
|
-
* @name
|
|
122
|
+
* @name bitfinex1#fetchTrades
|
|
123
123
|
* @description get the list of most recent trades for a particular symbol
|
|
124
124
|
* @see https://docs.bitfinex.com/v1/reference/rest-public-trades
|
|
125
125
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
@@ -131,7 +131,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
131
131
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
132
132
|
/**
|
|
133
133
|
* @method
|
|
134
|
-
* @name
|
|
134
|
+
* @name bitfinex1#fetchMyTrades
|
|
135
135
|
* @description fetch all trades made by the user
|
|
136
136
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-past-trades
|
|
137
137
|
* @param {string} symbol unified market symbol
|
|
@@ -143,7 +143,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
143
143
|
fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
144
144
|
/**
|
|
145
145
|
* @method
|
|
146
|
-
* @name
|
|
146
|
+
* @name bitfinex1#createOrder
|
|
147
147
|
* @description create a trade order
|
|
148
148
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-new-order
|
|
149
149
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
@@ -158,7 +158,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
158
158
|
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
159
159
|
/**
|
|
160
160
|
* @method
|
|
161
|
-
* @name
|
|
161
|
+
* @name bitfinex1#cancelOrder
|
|
162
162
|
* @description cancels an open order
|
|
163
163
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-order
|
|
164
164
|
* @param {string} id order id
|
|
@@ -169,7 +169,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
169
169
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
170
170
|
/**
|
|
171
171
|
* @method
|
|
172
|
-
* @name
|
|
172
|
+
* @name bitfinex1#cancelAllOrders
|
|
173
173
|
* @description cancel all open orders
|
|
174
174
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-all-orders
|
|
175
175
|
* @param {string} symbol not used by bitfinex cancelAllOrders
|
|
@@ -180,7 +180,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
180
180
|
parseOrder(order: Dict, market?: Market): Order;
|
|
181
181
|
/**
|
|
182
182
|
* @method
|
|
183
|
-
* @name
|
|
183
|
+
* @name bitfinex1#fetchOpenOrders
|
|
184
184
|
* @description fetch all unfilled currently open orders
|
|
185
185
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-active-orders
|
|
186
186
|
* @param {string} symbol unified market symbol
|
|
@@ -192,7 +192,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
192
192
|
fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
193
193
|
/**
|
|
194
194
|
* @method
|
|
195
|
-
* @name
|
|
195
|
+
* @name bitfinex1#fetchClosedOrders
|
|
196
196
|
* @description fetches information on multiple closed orders made by the user
|
|
197
197
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-orders-history
|
|
198
198
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
@@ -204,7 +204,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
204
204
|
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
205
205
|
/**
|
|
206
206
|
* @method
|
|
207
|
-
* @name
|
|
207
|
+
* @name bitfinex1#fetchOrder
|
|
208
208
|
* @description fetches information on an order made by the user
|
|
209
209
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-order-status
|
|
210
210
|
* @param {string} id the order id
|
|
@@ -231,7 +231,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
231
231
|
getCurrencyName(code: any): any;
|
|
232
232
|
/**
|
|
233
233
|
* @method
|
|
234
|
-
* @name
|
|
234
|
+
* @name bitfinex1#createDepositAddress
|
|
235
235
|
* @description create a currency deposit address
|
|
236
236
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit
|
|
237
237
|
* @param {string} code unified currency code of the currency for the deposit address
|
|
@@ -241,7 +241,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
241
241
|
createDepositAddress(code: string, params?: {}): Promise<DepositAddress>;
|
|
242
242
|
/**
|
|
243
243
|
* @method
|
|
244
|
-
* @name
|
|
244
|
+
* @name bitfinex1#fetchDepositAddress
|
|
245
245
|
* @description fetch the deposit address for a currency associated with this account
|
|
246
246
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit
|
|
247
247
|
* @param {string} code unified currency code
|
|
@@ -251,7 +251,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
251
251
|
fetchDepositAddress(code: string, params?: {}): Promise<DepositAddress>;
|
|
252
252
|
/**
|
|
253
253
|
* @method
|
|
254
|
-
* @name
|
|
254
|
+
* @name bitfinex1#fetchDepositsWithdrawals
|
|
255
255
|
* @description fetch history of deposits and withdrawals
|
|
256
256
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit-withdrawal-history
|
|
257
257
|
* @param {string} code unified currency code for the currency of the deposit/withdrawals
|
|
@@ -265,7 +265,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
265
265
|
parseTransactionStatus(status: Str): string;
|
|
266
266
|
/**
|
|
267
267
|
* @method
|
|
268
|
-
* @name
|
|
268
|
+
* @name bitfinex1#withdraw
|
|
269
269
|
* @description make a withdrawal
|
|
270
270
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-withdrawal
|
|
271
271
|
* @param {string} code unified currency code
|
|
@@ -278,7 +278,7 @@ export default class bitfinex1 extends Exchange {
|
|
|
278
278
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
279
279
|
/**
|
|
280
280
|
* @method
|
|
281
|
-
* @name
|
|
281
|
+
* @name bitfinex1#fetchPositions
|
|
282
282
|
* @description fetch all open positions
|
|
283
283
|
* @see https://docs.bitfinex.com/v1/reference/rest-auth-active-positions
|
|
284
284
|
* @param {string[]|undefined} symbols list of unified market symbols
|