ccxt 4.3.29 → 4.3.30

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.
@@ -15,7 +15,7 @@ export declare class BigInteger {
15
15
  protected intValue(): number;
16
16
  protected byteValue(): number;
17
17
  protected shortValue(): number;
18
- protected signum(): 0 | 1 | -1;
18
+ protected signum(): 1 | 0 | -1;
19
19
  toByteArray(): number[];
20
20
  protected equals(a: BigInteger): boolean;
21
21
  protected min(a: BigInteger): BigInteger;
@@ -34,6 +34,8 @@ export default class whitebit extends Exchange {
34
34
  info: any;
35
35
  }>;
36
36
  fetchTime(params?: {}): Promise<number>;
37
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: number, params?: {}): Promise<Order>;
38
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
37
39
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
38
40
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
39
41
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
@@ -35,6 +35,9 @@ export default class whitebit extends Exchange {
35
35
  'cancelAllOrdersAfter': true,
36
36
  'cancelOrder': true,
37
37
  'cancelOrders': false,
38
+ 'createMarketBuyOrderWithCost': true,
39
+ 'createMarketOrderWithCost': false,
40
+ 'createMarketSellOrderWithCost': false,
38
41
  'createOrder': true,
39
42
  'createStopLimitOrder': true,
40
43
  'createStopMarketOrder': true,
@@ -1200,6 +1203,33 @@ export default class whitebit extends Exchange {
1200
1203
  //
1201
1204
  return this.safeInteger(response, 'time');
1202
1205
  }
1206
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1207
+ /**
1208
+ * @method
1209
+ * @name createMarketOrderWithCost
1210
+ * @description create a market order by providing the symbol, side and cost
1211
+ * @param {string} symbol unified symbol of the market to create an order in
1212
+ * @param {string} side 'buy' or 'sell'
1213
+ * @param {float} cost how much you want to trade in units of the quote currency
1214
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1215
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1216
+ */
1217
+ params['cost'] = cost;
1218
+ // only buy side is supported
1219
+ return await this.createOrder(symbol, 'market', side, 0, undefined, params);
1220
+ }
1221
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1222
+ /**
1223
+ * @method
1224
+ * @name createMarketBuyOrderWithCost
1225
+ * @description create a market buy order by providing the symbol and cost
1226
+ * @param {string} symbol unified symbol of the market to create an order in
1227
+ * @param {float} cost how much you want to trade in units of the quote currency
1228
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1229
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1230
+ */
1231
+ return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
1232
+ }
1203
1233
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1204
1234
  /**
1205
1235
  * @method
@@ -1216,6 +1246,7 @@ export default class whitebit extends Exchange {
1216
1246
  * @param {float} amount how much of currency you want to trade in units of base currency
1217
1247
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1218
1248
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1249
+ * @param {float} [params.cost] *market orders only* the cost of the order in units of the base currency
1219
1250
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1220
1251
  */
1221
1252
  await this.loadMarkets();
@@ -1223,8 +1254,18 @@ export default class whitebit extends Exchange {
1223
1254
  const request = {
1224
1255
  'market': market['id'],
1225
1256
  'side': side,
1226
- 'amount': this.amountToPrecision(symbol, amount),
1227
1257
  };
1258
+ let cost = undefined;
1259
+ [cost, params] = this.handleParamString(params, 'cost');
1260
+ if (cost !== undefined) {
1261
+ if ((side !== 'buy') || (type !== 'market')) {
1262
+ throw new InvalidOrder(this.id + ' createOrder() cost is only supported for market buy orders');
1263
+ }
1264
+ request['amount'] = this.costToPrecision(symbol, cost);
1265
+ }
1266
+ else {
1267
+ request['amount'] = this.amountToPrecision(symbol, amount);
1268
+ }
1228
1269
  const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1229
1270
  if (clientOrderId === undefined) {
1230
1271
  const brokerId = this.safeString(this.options, 'brokerId');
@@ -1286,7 +1327,12 @@ export default class whitebit extends Exchange {
1286
1327
  response = await this.v4PrivatePostOrderCollateralMarket(this.extend(request, params));
1287
1328
  }
1288
1329
  else {
1289
- response = await this.v4PrivatePostOrderStockMarket(this.extend(request, params));
1330
+ if (cost !== undefined) {
1331
+ response = await this.v4PrivatePostOrderMarket(this.extend(request, params));
1332
+ }
1333
+ else {
1334
+ response = await this.v4PrivatePostOrderStockMarket(this.extend(request, params));
1335
+ }
1290
1336
  }
1291
1337
  }
1292
1338
  }
@@ -1697,7 +1743,7 @@ export default class whitebit extends Exchange {
1697
1743
  const symbol = market['symbol'];
1698
1744
  const side = this.safeString(order, 'side');
1699
1745
  const filled = this.safeString(order, 'dealStock');
1700
- const remaining = this.safeString(order, 'left');
1746
+ let remaining = this.safeString(order, 'left');
1701
1747
  let clientOrderId = this.safeString(order, 'clientOrderId');
1702
1748
  if (clientOrderId === '') {
1703
1749
  clientOrderId = undefined;
@@ -1706,6 +1752,10 @@ export default class whitebit extends Exchange {
1706
1752
  const stopPrice = this.safeNumber(order, 'activation_price');
1707
1753
  const orderId = this.safeString2(order, 'orderId', 'id');
1708
1754
  const type = this.safeString(order, 'type');
1755
+ const orderType = this.parseOrderType(type);
1756
+ if (orderType === 'market') {
1757
+ remaining = undefined;
1758
+ }
1709
1759
  let amount = this.safeString(order, 'amount');
1710
1760
  const cost = this.safeString(order, 'dealMoney');
1711
1761
  if ((side === 'buy') && ((type === 'market') || (type === 'stop market'))) {
@@ -1734,7 +1784,7 @@ export default class whitebit extends Exchange {
1734
1784
  'status': undefined,
1735
1785
  'side': side,
1736
1786
  'price': price,
1737
- 'type': this.parseOrderType(type),
1787
+ 'type': orderType,
1738
1788
  'stopPrice': stopPrice,
1739
1789
  'triggerPrice': stopPrice,
1740
1790
  'amount': amount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.29",
3
+ "version": "4.3.30",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",
@@ -96,6 +96,8 @@
96
96
  "fast-force-transpileWs": "node build/transpileWS.js --multiprocess --force",
97
97
  "test-js-cache": "node js/src/pro/test/base/test.Cache.js",
98
98
  "test-js-orderbook": "node js/src/pro/test/base/test.OrderBook.js",
99
+ "test-python-future": "python python/ccxt/pro/test/base/test_future.py",
100
+ "test-python-close": "python python/ccxt/pro/test/base/test_close.py",
99
101
  "test-python-cache": "python python/ccxt/pro/test/base/test_cache.py",
100
102
  "test-python-orderbook": "python python/ccxt/pro/test/base/test_order_book.py",
101
103
  "test-cs-cache": "dotnet run --project cs/tests/tests.csproj --cache",