ccxt 4.2.13 → 4.2.15

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.
Files changed (53) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +781 -133
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/js/ccxt.js +1 -1
  6. package/dist/cjs/js/src/base/Exchange.js +148 -1
  7. package/dist/cjs/js/src/bigone.js +36 -32
  8. package/dist/cjs/js/src/binance.js +108 -0
  9. package/dist/cjs/js/src/binanceus.js +8 -0
  10. package/dist/cjs/js/src/bingx.js +5 -0
  11. package/dist/cjs/js/src/bitget.js +4 -0
  12. package/dist/cjs/js/src/bybit.js +4 -0
  13. package/dist/cjs/js/src/coinex.js +3 -0
  14. package/dist/cjs/js/src/delta.js +7 -1
  15. package/dist/cjs/js/src/gate.js +5 -0
  16. package/dist/cjs/js/src/htx.js +126 -1
  17. package/dist/cjs/js/src/kraken.js +43 -9
  18. package/dist/cjs/js/src/kucoin.js +5 -0
  19. package/dist/cjs/js/src/kucoinfutures.js +131 -77
  20. package/dist/cjs/js/src/okx.js +9 -8
  21. package/dist/cjs/js/src/pro/htx.js +6 -1
  22. package/dist/cjs/js/src/pro/woo.js +126 -0
  23. package/dist/cjs/js/src/woo.js +6 -2
  24. package/js/ccxt.d.ts +1 -1
  25. package/js/ccxt.js +1 -1
  26. package/js/src/abstract/bigone.d.ts +1 -0
  27. package/js/src/abstract/kucoin.d.ts +4 -0
  28. package/js/src/abstract/kucoinfutures.d.ts +4 -0
  29. package/js/src/base/Exchange.d.ts +8 -0
  30. package/js/src/base/Exchange.js +148 -1
  31. package/js/src/bigone.js +36 -32
  32. package/js/src/binance.d.ts +9 -0
  33. package/js/src/binance.js +108 -0
  34. package/js/src/binanceus.js +8 -0
  35. package/js/src/bingx.js +5 -0
  36. package/js/src/bitget.js +4 -0
  37. package/js/src/bybit.js +4 -0
  38. package/js/src/coinex.js +3 -0
  39. package/js/src/delta.js +7 -1
  40. package/js/src/gate.js +5 -0
  41. package/js/src/htx.d.ts +9 -0
  42. package/js/src/htx.js +126 -1
  43. package/js/src/kraken.d.ts +1 -0
  44. package/js/src/kraken.js +43 -9
  45. package/js/src/kucoin.js +5 -0
  46. package/js/src/kucoinfutures.d.ts +4 -2
  47. package/js/src/kucoinfutures.js +131 -77
  48. package/js/src/okx.js +9 -8
  49. package/js/src/pro/htx.js +6 -1
  50. package/js/src/pro/woo.d.ts +5 -1
  51. package/js/src/pro/woo.js +127 -1
  52. package/js/src/woo.js +6 -2
  53. package/package.json +1 -1
@@ -21,6 +21,7 @@ class woo extends woo$1 {
21
21
  'watchTicker': true,
22
22
  'watchTickers': true,
23
23
  'watchTrades': true,
24
+ 'watchPositions': true,
24
25
  },
25
26
  'urls': {
26
27
  'api': {
@@ -45,6 +46,10 @@ class woo extends woo$1 {
45
46
  'tradesLimit': 1000,
46
47
  'ordersLimit': 1000,
47
48
  'requestId': {},
49
+ 'watchPositions': {
50
+ 'fetchPositionsSnapshot': true,
51
+ 'awaitPositionsSnapshot': true, // whether to wait for the positions snapshot before providing updates
52
+ },
48
53
  },
49
54
  'streaming': {
50
55
  'ping': this.ping,
@@ -603,6 +608,126 @@ class woo extends woo$1 {
603
608
  client.resolve(this.orders, messageHashSymbol);
604
609
  }
605
610
  }
611
+ async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
612
+ /**
613
+ * @method
614
+ * @name woo#watchPositions
615
+ * @see https://docs.woo.org/#position-push
616
+ * @description watch all open positions
617
+ * @param {string[]|undefined} symbols list of unified market symbols
618
+ * @param {object} params extra parameters specific to the exchange API endpoint
619
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
620
+ */
621
+ await this.loadMarkets();
622
+ let messageHash = '';
623
+ symbols = this.marketSymbols(symbols);
624
+ if (!this.isEmpty(symbols)) {
625
+ messageHash = '::' + symbols.join(',');
626
+ }
627
+ messageHash = 'positions' + messageHash;
628
+ const url = this.urls['api']['ws']['private'] + '/' + this.uid;
629
+ const client = this.client(url);
630
+ this.setPositionsCache(client, symbols);
631
+ const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
632
+ const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
633
+ if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
634
+ const snapshot = await client.future('fetchPositionsSnapshot');
635
+ return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
636
+ }
637
+ const request = {
638
+ 'event': 'subscribe',
639
+ 'topic': 'position',
640
+ };
641
+ const newPositions = await this.watchPrivate(messageHash, request, params);
642
+ if (this.newUpdates) {
643
+ return newPositions;
644
+ }
645
+ return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
646
+ }
647
+ setPositionsCache(client, type, symbols = undefined) {
648
+ const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', false);
649
+ if (fetchPositionsSnapshot) {
650
+ const messageHash = 'fetchPositionsSnapshot';
651
+ if (!(messageHash in client.futures)) {
652
+ client.future(messageHash);
653
+ this.spawn(this.loadPositionsSnapshot, client, messageHash);
654
+ }
655
+ }
656
+ else {
657
+ this.positions = new Cache.ArrayCacheBySymbolBySide();
658
+ }
659
+ }
660
+ async loadPositionsSnapshot(client, messageHash) {
661
+ const positions = await this.fetchPositions();
662
+ this.positions = new Cache.ArrayCacheBySymbolBySide();
663
+ const cache = this.positions;
664
+ for (let i = 0; i < positions.length; i++) {
665
+ const position = positions[i];
666
+ const contracts = this.safeNumber(position, 'contracts', 0);
667
+ if (contracts > 0) {
668
+ cache.append(position);
669
+ }
670
+ }
671
+ // don't remove the future from the .futures cache
672
+ const future = client.futures[messageHash];
673
+ future.resolve(cache);
674
+ client.resolve(cache, 'positions');
675
+ }
676
+ handlePositions(client, message) {
677
+ //
678
+ // {
679
+ // "topic":"position",
680
+ // "ts":1705292345255,
681
+ // "data":{
682
+ // "positions":{
683
+ // "PERP_LTC_USDT":{
684
+ // "holding":1,
685
+ // "pendingLongQty":0,
686
+ // "pendingShortQty":0,
687
+ // "averageOpenPrice":71.53,
688
+ // "pnl24H":0,
689
+ // "fee24H":0.07153,
690
+ // "settlePrice":71.53,
691
+ // "markPrice":71.32098452065145,
692
+ // "version":7886,
693
+ // "openingTime":1705292304267,
694
+ // "pnl24HPercentage":0,
695
+ // "adlQuantile":1,
696
+ // "positionSide":"BOTH"
697
+ // }
698
+ // }
699
+ // }
700
+ // }
701
+ //
702
+ const data = this.safeValue(message, 'data', {});
703
+ const rawPositions = this.safeValue(data, 'positions', {});
704
+ const postitionsIds = Object.keys(rawPositions);
705
+ if (this.positions === undefined) {
706
+ this.positions = new Cache.ArrayCacheBySymbolBySide();
707
+ }
708
+ const cache = this.positions;
709
+ const newPositions = [];
710
+ for (let i = 0; i < postitionsIds.length; i++) {
711
+ const marketId = postitionsIds[i];
712
+ const market = this.safeMarket(marketId);
713
+ const rawPosition = rawPositions[marketId];
714
+ const position = this.parsePosition(rawPosition, market);
715
+ newPositions.push(position);
716
+ cache.append(position);
717
+ }
718
+ const messageHashes = this.findMessageHashes(client, 'positions::');
719
+ for (let i = 0; i < messageHashes.length; i++) {
720
+ const messageHash = messageHashes[i];
721
+ const parts = messageHash.split('::');
722
+ const symbolsString = parts[1];
723
+ const symbols = symbolsString.split(',');
724
+ const positions = this.filterByArray(newPositions, 'symbol', symbols, false);
725
+ if (!this.isEmpty(positions)) {
726
+ client.resolve(positions, messageHash);
727
+ }
728
+ }
729
+ client.resolve(newPositions, 'positions');
730
+ }
606
731
  async watchBalance(params = {}) {
607
732
  /**
608
733
  * @method
@@ -686,6 +811,7 @@ class woo extends woo$1 {
686
811
  'executionreport': this.handleOrderUpdate,
687
812
  'trade': this.handleTrade,
688
813
  'balance': this.handleBalance,
814
+ 'position': this.handlePositions,
689
815
  };
690
816
  const event = this.safeString(message, 'event');
691
817
  let method = this.safeValue(methods, event);
@@ -42,12 +42,16 @@ class woo extends woo$1 {
42
42
  'createMarketOrderWithCost': false,
43
43
  'createMarketSellOrderWithCost': false,
44
44
  'createOrder': true,
45
+ 'createOrderWithTakeProfitAndStopLoss': true,
45
46
  'createReduceOnlyOrder': true,
46
47
  'createStopLimitOrder': false,
48
+ 'createStopLossOrder': true,
47
49
  'createStopMarketOrder': false,
48
50
  'createStopOrder': false,
51
+ 'createTakeProfitOrder': true,
49
52
  'createTrailingAmountOrder': true,
50
53
  'createTrailingPercentOrder': true,
54
+ 'createTriggerOrder': true,
51
55
  'fetchAccounts': true,
52
56
  'fetchBalance': true,
53
57
  'fetchCanceledOrders': false,
@@ -766,7 +770,7 @@ class woo extends woo$1 {
766
770
  async createTrailingAmountOrder(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
767
771
  /**
768
772
  * @method
769
- * @name createTrailingAmountOrder
773
+ * @name woo#createTrailingAmountOrder
770
774
  * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
771
775
  * @param {string} symbol unified symbol of the market to create an order in
772
776
  * @param {string} type 'market' or 'limit'
@@ -791,7 +795,7 @@ class woo extends woo$1 {
791
795
  async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
792
796
  /**
793
797
  * @method
794
- * @name createTrailingPercentOrder
798
+ * @name woo#createTrailingPercentOrder
795
799
  * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
796
800
  * @param {string} symbol unified symbol of the market to create an order in
797
801
  * @param {string} type 'market' or 'limit'
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 } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.12";
7
+ declare const version = "4.2.14";
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, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.13';
41
+ const version = '4.2.15';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -22,6 +22,7 @@ interface Exchange {
22
22
  privatePostOrdersCancel(params?: {}): Promise<implicitReturnType>;
23
23
  privatePostWithdrawals(params?: {}): Promise<implicitReturnType>;
24
24
  privatePostTransfer(params?: {}): Promise<implicitReturnType>;
25
+ contractPublicGetSymbols(params?: {}): Promise<implicitReturnType>;
25
26
  contractPublicGetInstruments(params?: {}): Promise<implicitReturnType>;
26
27
  contractPublicGetDepthSymbolSnapshot(params?: {}): Promise<implicitReturnType>;
27
28
  contractPublicGetInstrumentsDifference(params?: {}): Promise<implicitReturnType>;
@@ -149,6 +149,7 @@ interface Exchange {
149
149
  futuresPublicGetPremiumQuery(params?: {}): Promise<implicitReturnType>;
150
150
  futuresPublicGetTradeStatistics(params?: {}): Promise<implicitReturnType>;
151
151
  futuresPublicGetFundingRateSymbolCurrent(params?: {}): Promise<implicitReturnType>;
152
+ futuresPublicGetContractFundingRates(params?: {}): Promise<implicitReturnType>;
152
153
  futuresPublicGetTimestamp(params?: {}): Promise<implicitReturnType>;
153
154
  futuresPublicGetStatus(params?: {}): Promise<implicitReturnType>;
154
155
  futuresPublicGetLevel2MessageQuery(params?: {}): Promise<implicitReturnType>;
@@ -167,13 +168,16 @@ interface Exchange {
167
168
  futuresPrivateGetOpenOrderStatistics(params?: {}): Promise<implicitReturnType>;
168
169
  futuresPrivateGetPosition(params?: {}): Promise<implicitReturnType>;
169
170
  futuresPrivateGetPositions(params?: {}): Promise<implicitReturnType>;
171
+ futuresPrivateGetMarginMaxWithdrawMargin(params?: {}): Promise<implicitReturnType>;
170
172
  futuresPrivateGetContractsRiskLimitSymbol(params?: {}): Promise<implicitReturnType>;
171
173
  futuresPrivateGetFundingHistory(params?: {}): Promise<implicitReturnType>;
172
174
  futuresPrivatePostTransferOut(params?: {}): Promise<implicitReturnType>;
173
175
  futuresPrivatePostTransferIn(params?: {}): Promise<implicitReturnType>;
174
176
  futuresPrivatePostOrders(params?: {}): Promise<implicitReturnType>;
175
177
  futuresPrivatePostOrdersTest(params?: {}): Promise<implicitReturnType>;
178
+ futuresPrivatePostOrdersMulti(params?: {}): Promise<implicitReturnType>;
176
179
  futuresPrivatePostPositionMarginAutoDepositStatus(params?: {}): Promise<implicitReturnType>;
180
+ futuresPrivatePostMarginWithdrawMargin(params?: {}): Promise<implicitReturnType>;
177
181
  futuresPrivatePostPositionMarginDepositMargin(params?: {}): Promise<implicitReturnType>;
178
182
  futuresPrivatePostPositionRiskLimitLevelChange(params?: {}): Promise<implicitReturnType>;
179
183
  futuresPrivatePostBulletPrivate(params?: {}): Promise<implicitReturnType>;
@@ -149,6 +149,7 @@ interface kucoin {
149
149
  futuresPublicGetPremiumQuery(params?: {}): Promise<implicitReturnType>;
150
150
  futuresPublicGetTradeStatistics(params?: {}): Promise<implicitReturnType>;
151
151
  futuresPublicGetFundingRateSymbolCurrent(params?: {}): Promise<implicitReturnType>;
152
+ futuresPublicGetContractFundingRates(params?: {}): Promise<implicitReturnType>;
152
153
  futuresPublicGetTimestamp(params?: {}): Promise<implicitReturnType>;
153
154
  futuresPublicGetStatus(params?: {}): Promise<implicitReturnType>;
154
155
  futuresPublicGetLevel2MessageQuery(params?: {}): Promise<implicitReturnType>;
@@ -171,6 +172,7 @@ interface kucoin {
171
172
  futuresPrivateGetOpenOrderStatistics(params?: {}): Promise<implicitReturnType>;
172
173
  futuresPrivateGetPosition(params?: {}): Promise<implicitReturnType>;
173
174
  futuresPrivateGetPositions(params?: {}): Promise<implicitReturnType>;
175
+ futuresPrivateGetMarginMaxWithdrawMargin(params?: {}): Promise<implicitReturnType>;
174
176
  futuresPrivateGetContractsRiskLimitSymbol(params?: {}): Promise<implicitReturnType>;
175
177
  futuresPrivateGetFundingHistory(params?: {}): Promise<implicitReturnType>;
176
178
  futuresPrivateGetDepositAddress(params?: {}): Promise<implicitReturnType>;
@@ -183,7 +185,9 @@ interface kucoin {
183
185
  futuresPrivatePostTransferIn(params?: {}): Promise<implicitReturnType>;
184
186
  futuresPrivatePostOrders(params?: {}): Promise<implicitReturnType>;
185
187
  futuresPrivatePostOrdersTest(params?: {}): Promise<implicitReturnType>;
188
+ futuresPrivatePostOrdersMulti(params?: {}): Promise<implicitReturnType>;
186
189
  futuresPrivatePostPositionMarginAutoDepositStatus(params?: {}): Promise<implicitReturnType>;
190
+ futuresPrivatePostMarginWithdrawMargin(params?: {}): Promise<implicitReturnType>;
187
191
  futuresPrivatePostPositionMarginDepositMargin(params?: {}): Promise<implicitReturnType>;
188
192
  futuresPrivatePostPositionRiskLimitLevelChange(params?: {}): Promise<implicitReturnType>;
189
193
  futuresPrivatePostBulletPrivate(params?: {}): Promise<implicitReturnType>;
@@ -303,13 +303,17 @@ export default class Exchange {
303
303
  createMarketOrderWithCost: any;
304
304
  createMarketSellOrderWithCost: any;
305
305
  createOrders: any;
306
+ createOrderWithTakeProfitAndStopLoss: any;
306
307
  createPostOnlyOrder: any;
307
308
  createReduceOnlyOrder: any;
309
+ createStopLossOrder: any;
308
310
  createStopOrder: any;
309
311
  createStopLimitOrder: any;
310
312
  createStopMarketOrder: any;
313
+ createTakeProfitOrder: any;
311
314
  createTrailingAmountOrder: any;
312
315
  createTrailingPercentOrder: any;
316
+ createTriggerOrder: any;
313
317
  createOrderWs: any;
314
318
  editOrderWs: any;
315
319
  fetchOpenOrdersWs: any;
@@ -778,6 +782,10 @@ export default class Exchange {
778
782
  createMarketOrderWithCost(symbol: string, side: OrderSide, cost: any, params?: {}): Promise<Order>;
779
783
  createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
780
784
  createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
785
+ createTriggerOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, triggerPrice?: any, params?: {}): Promise<Order>;
786
+ createStopLossOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, stopLossPrice?: any, params?: {}): Promise<Order>;
787
+ createTakeProfitOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, takeProfitPrice?: any, params?: {}): Promise<Order>;
788
+ createOrderWithTakeProfitAndStopLoss(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, takeProfit?: any, stopLoss?: any, params?: {}): Promise<Order>;
781
789
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
782
790
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
783
791
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<any>;
@@ -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.options['createMarketSellOrderWithCost']) {
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.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 response = await this.publicGetAssetPairs(params);
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
- // "usdtPrice": 1.00031998,
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
- // "btcPrice": 34700.4,
558
- // "ethPrice": 1787.83,
559
- // "nextFundingRate": 0.00010,
560
- // "fundingRate": 0.00010,
561
- // "latestPrice": 34708.5,
562
- // "last24hPriceChange": 0.0321,
563
- // "indexPrice": 34700.4,
564
- // "volume24h": 261319063,
565
- // "turnover24h": 8204.129380685496,
566
- // "nextFundingTime": 1698285600000,
567
- // "markPrice": 34702.4646738,
568
- // "last24hMaxPrice": 35127.5,
569
- // "volume24hInUsd": 0.0,
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': true,
668
+ 'active': this.safeValue(market, 'enable'),
665
669
  'contract': true,
666
670
  'linear': !inverse,
667
671
  'inverse': inverse,
668
- 'contractSize': 1,
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': undefined,
675
- 'price': undefined,
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': undefined,
688
- 'max': undefined,
691
+ 'min': this.safeNumber(market, 'priceMin'),
692
+ 'max': this.safeNumber(market, 'priceMax'),
689
693
  },
690
694
  'cost': {
691
- 'min': undefined,
695
+ 'min': this.safeNumber(market, 'initialMargin'),
692
696
  'max': undefined,
693
697
  },
694
698
  },
@@ -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[]>;