ccxt 4.2.12 → 4.2.14
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 +1338 -366
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/js/ccxt.js +1 -1
- package/dist/cjs/js/src/base/Exchange.js +148 -1
- package/dist/cjs/js/src/bigone.js +125 -54
- package/dist/cjs/js/src/binance.js +142 -27
- package/dist/cjs/js/src/binanceus.js +8 -0
- package/dist/cjs/js/src/bingx.js +110 -36
- package/dist/cjs/js/src/bitget.js +17 -6
- package/dist/cjs/js/src/bitmart.js +3 -3
- package/dist/cjs/js/src/bybit.js +5 -1
- package/dist/cjs/js/src/coinbase.js +176 -26
- package/dist/cjs/js/src/coinex.js +3 -0
- package/dist/cjs/js/src/coinlist.js +1 -1
- package/dist/cjs/js/src/coinone.js +1 -1
- package/dist/cjs/js/src/delta.js +7 -1
- package/dist/cjs/js/src/deribit.js +1 -1
- package/dist/cjs/js/src/gate.js +79 -56
- package/dist/cjs/js/src/gemini.js +1 -1
- package/dist/cjs/js/src/htx.js +151 -1
- package/dist/cjs/js/src/independentreserve.js +7 -5
- package/dist/cjs/js/src/kraken.js +22 -14
- package/dist/cjs/js/src/kucoin.js +5 -0
- package/dist/cjs/js/src/kucoinfutures.js +131 -77
- package/dist/cjs/js/src/lbank.js +59 -33
- package/dist/cjs/js/src/oceanex.js +1 -1
- package/dist/cjs/js/src/okx.js +11 -9
- package/dist/cjs/js/src/phemex.js +9 -2
- package/dist/cjs/js/src/pro/kraken.js +1 -1
- package/dist/cjs/js/src/pro/okx.js +52 -2
- package/dist/cjs/js/src/probit.js +4 -2
- package/dist/cjs/js/src/wavesexchange.js +1 -1
- package/dist/cjs/js/src/woo.js +56 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +1 -0
- package/js/src/abstract/bingx.d.ts +2 -0
- package/js/src/abstract/kucoin.d.ts +4 -0
- package/js/src/abstract/kucoinfutures.d.ts +4 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +8 -0
- package/js/src/base/Exchange.js +148 -1
- package/js/src/bigone.d.ts +2 -0
- package/js/src/bigone.js +125 -54
- package/js/src/binance.d.ts +9 -0
- package/js/src/binance.js +142 -27
- package/js/src/binanceus.js +8 -0
- package/js/src/bingx.js +110 -36
- package/js/src/bitget.js +17 -6
- package/js/src/bitmart.js +3 -3
- package/js/src/bybit.js +5 -1
- package/js/src/coinbase.d.ts +26 -3
- package/js/src/coinbase.js +176 -26
- package/js/src/coinex.js +3 -0
- package/js/src/coinlist.js +1 -1
- package/js/src/coinone.js +1 -1
- package/js/src/delta.js +7 -1
- package/js/src/deribit.js +1 -1
- package/js/src/gate.js +79 -56
- package/js/src/gemini.js +1 -1
- package/js/src/htx.d.ts +10 -0
- package/js/src/htx.js +151 -1
- package/js/src/independentreserve.js +7 -5
- package/js/src/kraken.js +22 -14
- package/js/src/kucoin.js +5 -0
- package/js/src/kucoinfutures.d.ts +4 -2
- package/js/src/kucoinfutures.js +131 -77
- package/js/src/lbank.js +59 -33
- package/js/src/oceanex.js +1 -1
- package/js/src/okx.js +11 -9
- package/js/src/phemex.js +9 -2
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/okx.d.ts +1 -0
- package/js/src/pro/okx.js +52 -2
- package/js/src/probit.js +4 -2
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +2 -0
- package/js/src/woo.js +56 -2
- package/package.json +1 -1
package/js/src/base/Exchange.js
CHANGED
|
@@ -359,13 +359,17 @@ export default class Exchange {
|
|
|
359
359
|
'createMarketOrderWithCost': undefined,
|
|
360
360
|
'createMarketSellOrderWithCost': undefined,
|
|
361
361
|
'createOrders': undefined,
|
|
362
|
+
'createOrderWithTakeProfitAndStopLoss': undefined,
|
|
362
363
|
'createPostOnlyOrder': undefined,
|
|
363
364
|
'createReduceOnlyOrder': undefined,
|
|
365
|
+
'createStopLossOrder': undefined,
|
|
364
366
|
'createStopOrder': undefined,
|
|
365
367
|
'createStopLimitOrder': undefined,
|
|
366
368
|
'createStopMarketOrder': undefined,
|
|
369
|
+
'createTakeProfitOrder': undefined,
|
|
367
370
|
'createTrailingAmountOrder': undefined,
|
|
368
371
|
'createTrailingPercentOrder': undefined,
|
|
372
|
+
'createTriggerOrder': undefined,
|
|
369
373
|
'createOrderWs': undefined,
|
|
370
374
|
'editOrderWs': undefined,
|
|
371
375
|
'fetchOpenOrdersWs': undefined,
|
|
@@ -3868,11 +3872,154 @@ export default class Exchange {
|
|
|
3868
3872
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3869
3873
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3870
3874
|
*/
|
|
3871
|
-
if (this.options['createMarketSellOrderRequiresPrice'] || this.
|
|
3875
|
+
if (this.options['createMarketSellOrderRequiresPrice'] || this.has['createMarketSellOrderWithCost']) {
|
|
3872
3876
|
return await this.createOrder(symbol, 'market', 'sell', cost, 1, params);
|
|
3873
3877
|
}
|
|
3874
3878
|
throw new NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
|
|
3875
3879
|
}
|
|
3880
|
+
async createTriggerOrder(symbol, type, side, amount, price = undefined, triggerPrice = undefined, params = {}) {
|
|
3881
|
+
/**
|
|
3882
|
+
* @method
|
|
3883
|
+
* @name createTriggerOrder
|
|
3884
|
+
* @description create a trigger stop order (type 1)
|
|
3885
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3886
|
+
* @param {string} type 'market' or 'limit'
|
|
3887
|
+
* @param {string} side 'buy' or 'sell'
|
|
3888
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
3889
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
3890
|
+
* @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
|
|
3891
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3892
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3893
|
+
*/
|
|
3894
|
+
if (triggerPrice === undefined) {
|
|
3895
|
+
throw new ArgumentsRequired(this.id + ' createTriggerOrder() requires a triggerPrice argument');
|
|
3896
|
+
}
|
|
3897
|
+
params['triggerPrice'] = triggerPrice;
|
|
3898
|
+
if (this.has['createTriggerOrder']) {
|
|
3899
|
+
return await this.createOrder(symbol, type, side, amount, price, params);
|
|
3900
|
+
}
|
|
3901
|
+
throw new NotSupported(this.id + ' createTriggerOrder() is not supported yet');
|
|
3902
|
+
}
|
|
3903
|
+
async createStopLossOrder(symbol, type, side, amount, price = undefined, stopLossPrice = undefined, params = {}) {
|
|
3904
|
+
/**
|
|
3905
|
+
* @method
|
|
3906
|
+
* @name createStopLossOrder
|
|
3907
|
+
* @description create a trigger stop loss order (type 2)
|
|
3908
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3909
|
+
* @param {string} type 'market' or 'limit'
|
|
3910
|
+
* @param {string} side 'buy' or 'sell'
|
|
3911
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
3912
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
3913
|
+
* @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
|
|
3914
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3915
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3916
|
+
*/
|
|
3917
|
+
if (stopLossPrice === undefined) {
|
|
3918
|
+
throw new ArgumentsRequired(this.id + ' createStopLossOrder() requires a stopLossPrice argument');
|
|
3919
|
+
}
|
|
3920
|
+
params['stopLossPrice'] = stopLossPrice;
|
|
3921
|
+
if (this.has['createStopLossOrder']) {
|
|
3922
|
+
return await this.createOrder(symbol, type, side, amount, price, params);
|
|
3923
|
+
}
|
|
3924
|
+
throw new NotSupported(this.id + ' createStopLossOrder() is not supported yet');
|
|
3925
|
+
}
|
|
3926
|
+
async createTakeProfitOrder(symbol, type, side, amount, price = undefined, takeProfitPrice = undefined, params = {}) {
|
|
3927
|
+
/**
|
|
3928
|
+
* @method
|
|
3929
|
+
* @name createTakeProfitOrder
|
|
3930
|
+
* @description create a trigger take profit order (type 2)
|
|
3931
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3932
|
+
* @param {string} type 'market' or 'limit'
|
|
3933
|
+
* @param {string} side 'buy' or 'sell'
|
|
3934
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
3935
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
3936
|
+
* @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
|
|
3937
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3938
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3939
|
+
*/
|
|
3940
|
+
if (takeProfitPrice === undefined) {
|
|
3941
|
+
throw new ArgumentsRequired(this.id + ' createTakeProfitOrder() requires a takeProfitPrice argument');
|
|
3942
|
+
}
|
|
3943
|
+
params['takeProfitPrice'] = takeProfitPrice;
|
|
3944
|
+
if (this.has['createTakeProfitOrder']) {
|
|
3945
|
+
return await this.createOrder(symbol, type, side, amount, price, params);
|
|
3946
|
+
}
|
|
3947
|
+
throw new NotSupported(this.id + ' createTakeProfitOrder() is not supported yet');
|
|
3948
|
+
}
|
|
3949
|
+
async createOrderWithTakeProfitAndStopLoss(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
|
|
3950
|
+
/**
|
|
3951
|
+
* @method
|
|
3952
|
+
* @name createOrderWithTakeProfitAndStopLoss
|
|
3953
|
+
* @description create an order with a stop loss or take profit attached (type 3)
|
|
3954
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3955
|
+
* @param {string} type 'market' or 'limit'
|
|
3956
|
+
* @param {string} side 'buy' or 'sell'
|
|
3957
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
3958
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
3959
|
+
* @param {float} [takeProfit] the take profit price, in units of the quote currency
|
|
3960
|
+
* @param {float} [stopLoss] the stop loss price, in units of the quote currency
|
|
3961
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3962
|
+
* @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
|
|
3963
|
+
* @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
|
|
3964
|
+
* @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
|
|
3965
|
+
* @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
|
|
3966
|
+
* @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
|
|
3967
|
+
* @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
|
|
3968
|
+
* @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
|
|
3969
|
+
* @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
|
|
3970
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3971
|
+
*/
|
|
3972
|
+
if ((takeProfit === undefined) && (stopLoss === undefined)) {
|
|
3973
|
+
throw new ArgumentsRequired(this.id + ' createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument');
|
|
3974
|
+
}
|
|
3975
|
+
if (takeProfit !== undefined) {
|
|
3976
|
+
params['takeProfit'] = {
|
|
3977
|
+
'triggerPrice': takeProfit,
|
|
3978
|
+
};
|
|
3979
|
+
}
|
|
3980
|
+
if (stopLoss !== undefined) {
|
|
3981
|
+
params['stopLoss'] = {
|
|
3982
|
+
'triggerPrice': stopLoss,
|
|
3983
|
+
};
|
|
3984
|
+
}
|
|
3985
|
+
const takeProfitType = this.safeString(params, 'takeProfitType');
|
|
3986
|
+
const takeProfitPriceType = this.safeString(params, 'takeProfitPriceType');
|
|
3987
|
+
const takeProfitLimitPrice = this.safeString(params, 'takeProfitLimitPrice');
|
|
3988
|
+
const takeProfitAmount = this.safeString(params, 'takeProfitAmount');
|
|
3989
|
+
const stopLossType = this.safeString(params, 'stopLossType');
|
|
3990
|
+
const stopLossPriceType = this.safeString(params, 'stopLossPriceType');
|
|
3991
|
+
const stopLossLimitPrice = this.safeString(params, 'stopLossLimitPrice');
|
|
3992
|
+
const stopLossAmount = this.safeString(params, 'stopLossAmount');
|
|
3993
|
+
if (takeProfitType !== undefined) {
|
|
3994
|
+
params['takeProfit']['type'] = takeProfitType;
|
|
3995
|
+
}
|
|
3996
|
+
if (takeProfitPriceType !== undefined) {
|
|
3997
|
+
params['takeProfit']['priceType'] = takeProfitPriceType;
|
|
3998
|
+
}
|
|
3999
|
+
if (takeProfitLimitPrice !== undefined) {
|
|
4000
|
+
params['takeProfit']['price'] = this.parseToNumeric(takeProfitLimitPrice);
|
|
4001
|
+
}
|
|
4002
|
+
if (takeProfitAmount !== undefined) {
|
|
4003
|
+
params['takeProfit']['amount'] = this.parseToNumeric(takeProfitAmount);
|
|
4004
|
+
}
|
|
4005
|
+
if (stopLossType !== undefined) {
|
|
4006
|
+
params['stopLoss']['type'] = stopLossType;
|
|
4007
|
+
}
|
|
4008
|
+
if (stopLossPriceType !== undefined) {
|
|
4009
|
+
params['stopLoss']['priceType'] = stopLossPriceType;
|
|
4010
|
+
}
|
|
4011
|
+
if (stopLossLimitPrice !== undefined) {
|
|
4012
|
+
params['stopLoss']['price'] = this.parseToNumeric(stopLossLimitPrice);
|
|
4013
|
+
}
|
|
4014
|
+
if (stopLossAmount !== undefined) {
|
|
4015
|
+
params['stopLoss']['amount'] = this.parseToNumeric(stopLossAmount);
|
|
4016
|
+
}
|
|
4017
|
+
params = this.omit(params, ['takeProfitType', 'takeProfitPriceType', 'takeProfitLimitPrice', 'takeProfitAmount', 'stopLossType', 'stopLossPriceType', 'stopLossLimitPrice', 'stopLossAmount']);
|
|
4018
|
+
if (this.has['createOrderWithTakeProfitAndStopLoss']) {
|
|
4019
|
+
return await this.createOrder(symbol, type, side, amount, price, params);
|
|
4020
|
+
}
|
|
4021
|
+
throw new NotSupported(this.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet');
|
|
4022
|
+
}
|
|
3876
4023
|
async createOrders(orders, params = {}) {
|
|
3877
4024
|
throw new NotSupported(this.id + ' createOrders() is not supported yet');
|
|
3878
4025
|
}
|
package/js/src/bigone.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export default class bigone extends Exchange {
|
|
|
13
13
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
14
14
|
fetchTime(params?: {}): Promise<number>;
|
|
15
15
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
16
|
+
parseContractBidsAsks(bidsAsks: any): any[];
|
|
17
|
+
parseContractOrderBook(orderbook: object, symbol: string, limit?: Int): OrderBook;
|
|
16
18
|
parseTrade(trade: any, market?: Market): Trade;
|
|
17
19
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
18
20
|
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
|
package/js/src/bigone.js
CHANGED
|
@@ -127,6 +127,7 @@ export default class bigone extends Exchange {
|
|
|
127
127
|
},
|
|
128
128
|
'contractPublic': {
|
|
129
129
|
'get': [
|
|
130
|
+
'symbols',
|
|
130
131
|
'instruments',
|
|
131
132
|
'depth@{symbol}/snapshot',
|
|
132
133
|
'instruments/difference',
|
|
@@ -522,7 +523,10 @@ export default class bigone extends Exchange {
|
|
|
522
523
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
523
524
|
* @returns {object[]} an array of objects representing market data
|
|
524
525
|
*/
|
|
525
|
-
const
|
|
526
|
+
const promises = [this.publicGetAssetPairs(params), this.contractPublicGetSymbols(params)];
|
|
527
|
+
const promisesResult = await Promise.all(promises);
|
|
528
|
+
const response = promisesResult[0];
|
|
529
|
+
const contractResponse = promisesResult[1];
|
|
526
530
|
//
|
|
527
531
|
// {
|
|
528
532
|
// "code":0,
|
|
@@ -548,29 +552,30 @@ export default class bigone extends Exchange {
|
|
|
548
552
|
// ]
|
|
549
553
|
// }
|
|
550
554
|
//
|
|
551
|
-
const contractResponse = await this.contractPublicGetInstruments(params);
|
|
552
555
|
//
|
|
553
556
|
// [
|
|
554
557
|
// {
|
|
555
|
-
// "
|
|
558
|
+
// "baseCurrency": "BTC",
|
|
559
|
+
// "multiplier": 1,
|
|
560
|
+
// "enable": true,
|
|
561
|
+
// "priceStep": 0.5,
|
|
562
|
+
// "maxRiskLimit": 1000,
|
|
563
|
+
// "pricePrecision": 1,
|
|
564
|
+
// "maintenanceMargin": 0.00500,
|
|
556
565
|
// "symbol": "BTCUSD",
|
|
557
|
-
// "
|
|
558
|
-
// "
|
|
559
|
-
// "
|
|
560
|
-
// "
|
|
561
|
-
// "
|
|
562
|
-
// "
|
|
563
|
-
// "
|
|
564
|
-
// "
|
|
565
|
-
// "
|
|
566
|
-
// "
|
|
567
|
-
// "
|
|
568
|
-
// "
|
|
569
|
-
//
|
|
570
|
-
// "openValue": 32.88054722085945,
|
|
571
|
-
// "last24hMinPrice": 33552.0,
|
|
572
|
-
// "openInterest": 1141372.0
|
|
573
|
-
// }
|
|
566
|
+
// "valuePrecision": 4,
|
|
567
|
+
// "minRiskLimit": 100,
|
|
568
|
+
// "riskLimit": 100,
|
|
569
|
+
// "isInverse": true,
|
|
570
|
+
// "riskStep": 1,
|
|
571
|
+
// "settleCurrency": "BTC",
|
|
572
|
+
// "baseName": "Bitcoin",
|
|
573
|
+
// "feePrecision": 8,
|
|
574
|
+
// "priceMin": 0.5,
|
|
575
|
+
// "priceMax": 1E+6,
|
|
576
|
+
// "initialMargin": 0.01000,
|
|
577
|
+
// "quoteCurrency": "USD"
|
|
578
|
+
// },
|
|
574
579
|
// ...
|
|
575
580
|
// ]
|
|
576
581
|
//
|
|
@@ -637,15 +642,14 @@ export default class bigone extends Exchange {
|
|
|
637
642
|
}
|
|
638
643
|
for (let i = 0; i < contractResponse.length; i++) {
|
|
639
644
|
const market = contractResponse[i];
|
|
645
|
+
const baseId = this.safeString(market, 'baseCurrency');
|
|
646
|
+
const quoteId = this.safeString(market, 'quoteCurrency');
|
|
647
|
+
const settleId = this.safeString(market, 'settleCurrency');
|
|
640
648
|
const marketId = this.safeString(market, 'symbol');
|
|
641
|
-
const index = marketId.indexOf('USD');
|
|
642
|
-
const baseId = marketId.slice(0, index);
|
|
643
|
-
const quoteId = marketId.slice(index);
|
|
644
|
-
const inverse = (quoteId === 'USD');
|
|
645
|
-
const settleId = inverse ? baseId : quoteId;
|
|
646
649
|
const base = this.safeCurrencyCode(baseId);
|
|
647
650
|
const quote = this.safeCurrencyCode(quoteId);
|
|
648
651
|
const settle = this.safeCurrencyCode(settleId);
|
|
652
|
+
const inverse = this.safeValue(market, 'isInverse');
|
|
649
653
|
result.push(this.safeMarketStructure({
|
|
650
654
|
'id': marketId,
|
|
651
655
|
'symbol': base + '/' + quote + ':' + settle,
|
|
@@ -661,18 +665,18 @@ export default class bigone extends Exchange {
|
|
|
661
665
|
'swap': true,
|
|
662
666
|
'future': false,
|
|
663
667
|
'option': false,
|
|
664
|
-
'active':
|
|
668
|
+
'active': this.safeValue(market, 'enable'),
|
|
665
669
|
'contract': true,
|
|
666
670
|
'linear': !inverse,
|
|
667
671
|
'inverse': inverse,
|
|
668
|
-
'contractSize':
|
|
672
|
+
'contractSize': this.safeNumber(market, 'multiplier'),
|
|
669
673
|
'expiry': undefined,
|
|
670
674
|
'expiryDatetime': undefined,
|
|
671
675
|
'strike': undefined,
|
|
672
676
|
'optionType': undefined,
|
|
673
677
|
'precision': {
|
|
674
|
-
'amount':
|
|
675
|
-
'price':
|
|
678
|
+
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'valuePrecision'))),
|
|
679
|
+
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision'))),
|
|
676
680
|
},
|
|
677
681
|
'limits': {
|
|
678
682
|
'leverage': {
|
|
@@ -684,11 +688,11 @@ export default class bigone extends Exchange {
|
|
|
684
688
|
'max': undefined,
|
|
685
689
|
},
|
|
686
690
|
'price': {
|
|
687
|
-
'min':
|
|
688
|
-
'max':
|
|
691
|
+
'min': this.safeNumber(market, 'priceMin'),
|
|
692
|
+
'max': this.safeNumber(market, 'priceMax'),
|
|
689
693
|
},
|
|
690
694
|
'cost': {
|
|
691
|
-
'min':
|
|
695
|
+
'min': this.safeNumber(market, 'initialMargin'),
|
|
692
696
|
'max': undefined,
|
|
693
697
|
},
|
|
694
698
|
},
|
|
@@ -934,29 +938,90 @@ export default class bigone extends Exchange {
|
|
|
934
938
|
*/
|
|
935
939
|
await this.loadMarkets();
|
|
936
940
|
const market = this.market(symbol);
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
941
|
+
let response = undefined;
|
|
942
|
+
if (market['contract']) {
|
|
943
|
+
const request = {
|
|
944
|
+
'symbol': market['id'],
|
|
945
|
+
};
|
|
946
|
+
response = await this.contractPublicGetDepthSymbolSnapshot(this.extend(request, params));
|
|
947
|
+
//
|
|
948
|
+
// {
|
|
949
|
+
// bids: {
|
|
950
|
+
// '20000': '20',
|
|
951
|
+
// ...
|
|
952
|
+
// '34552': '64851',
|
|
953
|
+
// '34526.5': '59594',
|
|
954
|
+
// ...
|
|
955
|
+
// '34551.5': '29711'
|
|
956
|
+
// },
|
|
957
|
+
// asks: {
|
|
958
|
+
// '34557': '34395',
|
|
959
|
+
// ...
|
|
960
|
+
// '40000': '20',
|
|
961
|
+
// '34611.5': '56024',
|
|
962
|
+
// ...
|
|
963
|
+
// '34578.5': '66367'
|
|
964
|
+
// },
|
|
965
|
+
// to: '59737174',
|
|
966
|
+
// lastPrice: '34554.5',
|
|
967
|
+
// bestPrices: {
|
|
968
|
+
// ask: '34557.0',
|
|
969
|
+
// bid: '34552.0'
|
|
970
|
+
// },
|
|
971
|
+
// from: '0'
|
|
972
|
+
// }
|
|
973
|
+
//
|
|
974
|
+
return this.parseContractOrderBook(response, market['symbol'], limit);
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
const request = {
|
|
978
|
+
'asset_pair_name': market['id'],
|
|
979
|
+
};
|
|
980
|
+
if (limit !== undefined) {
|
|
981
|
+
request['limit'] = limit; // default 50, max 200
|
|
982
|
+
}
|
|
983
|
+
response = await this.publicGetAssetPairsAssetPairNameDepth(this.extend(request, params));
|
|
984
|
+
//
|
|
985
|
+
// {
|
|
986
|
+
// "code":0,
|
|
987
|
+
// "data": {
|
|
988
|
+
// "asset_pair_name": "EOS-BTC",
|
|
989
|
+
// "bids": [
|
|
990
|
+
// { "price": "42", "order_count": 4, "quantity": "23.33363711" }
|
|
991
|
+
// ],
|
|
992
|
+
// "asks": [
|
|
993
|
+
// { "price": "45", "order_count": 2, "quantity": "4193.3283464" }
|
|
994
|
+
// ]
|
|
995
|
+
// }
|
|
996
|
+
// }
|
|
997
|
+
//
|
|
998
|
+
const orderbook = this.safeValue(response, 'data', {});
|
|
999
|
+
return this.parseOrderBook(orderbook, market['symbol'], undefined, 'bids', 'asks', 'price', 'quantity');
|
|
942
1000
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
const
|
|
959
|
-
return
|
|
1001
|
+
}
|
|
1002
|
+
parseContractBidsAsks(bidsAsks) {
|
|
1003
|
+
const bidsAsksKeys = Object.keys(bidsAsks);
|
|
1004
|
+
const result = [];
|
|
1005
|
+
for (let i = 0; i < bidsAsksKeys.length; i++) {
|
|
1006
|
+
const price = bidsAsksKeys[i];
|
|
1007
|
+
const amount = bidsAsks[price];
|
|
1008
|
+
result.push([this.parseNumber(price), this.parseNumber(amount)]);
|
|
1009
|
+
}
|
|
1010
|
+
return result;
|
|
1011
|
+
}
|
|
1012
|
+
parseContractOrderBook(orderbook, symbol, limit = undefined) {
|
|
1013
|
+
const responseBids = this.safeValue(orderbook, 'bids');
|
|
1014
|
+
const responseAsks = this.safeValue(orderbook, 'asks');
|
|
1015
|
+
const bids = this.parseContractBidsAsks(responseBids);
|
|
1016
|
+
const asks = this.parseContractBidsAsks(responseAsks);
|
|
1017
|
+
return {
|
|
1018
|
+
'symbol': symbol,
|
|
1019
|
+
'bids': this.filterByLimit(this.sortBy(bids, 0, true), limit),
|
|
1020
|
+
'asks': this.filterByLimit(this.sortBy(asks, 0), limit),
|
|
1021
|
+
'timestamp': undefined,
|
|
1022
|
+
'datetime': undefined,
|
|
1023
|
+
'nonce': undefined,
|
|
1024
|
+
};
|
|
960
1025
|
}
|
|
961
1026
|
parseTrade(trade, market = undefined) {
|
|
962
1027
|
//
|
|
@@ -1116,6 +1181,9 @@ export default class bigone extends Exchange {
|
|
|
1116
1181
|
*/
|
|
1117
1182
|
await this.loadMarkets();
|
|
1118
1183
|
const market = this.market(symbol);
|
|
1184
|
+
if (market['contract']) {
|
|
1185
|
+
throw new BadRequest(this.id + ' fetchTrades () can only fetch trades for spot markets');
|
|
1186
|
+
}
|
|
1119
1187
|
const request = {
|
|
1120
1188
|
'asset_pair_name': market['id'],
|
|
1121
1189
|
};
|
|
@@ -1178,6 +1246,9 @@ export default class bigone extends Exchange {
|
|
|
1178
1246
|
*/
|
|
1179
1247
|
await this.loadMarkets();
|
|
1180
1248
|
const market = this.market(symbol);
|
|
1249
|
+
if (market['contract']) {
|
|
1250
|
+
throw new BadRequest(this.id + ' fetchOHLCV () can only fetch ohlcvs for spot markets');
|
|
1251
|
+
}
|
|
1181
1252
|
if (limit === undefined) {
|
|
1182
1253
|
limit = 100; // default 100, max 500
|
|
1183
1254
|
}
|
package/js/src/binance.d.ts
CHANGED
|
@@ -34,6 +34,15 @@ export default class binance extends Exchange {
|
|
|
34
34
|
}>;
|
|
35
35
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
36
36
|
fetchBidsAsks(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
|
|
37
|
+
fetchLastPrices(symbols?: Strings, params?: {}): Promise<any>;
|
|
38
|
+
parseLastPrice(entry: any, market?: Market): {
|
|
39
|
+
symbol: string;
|
|
40
|
+
timestamp: number;
|
|
41
|
+
datetime: string;
|
|
42
|
+
price: number;
|
|
43
|
+
side: any;
|
|
44
|
+
info: any;
|
|
45
|
+
};
|
|
37
46
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
38
47
|
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
|
|
39
48
|
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|