ccxt 4.1.95 → 4.1.96
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/build.sh +16 -16
- package/dist/ccxt.browser.js +385 -251
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +145 -135
- package/dist/cjs/src/bingx.js +8 -7
- package/dist/cjs/src/bit2c.js +2 -3
- package/dist/cjs/src/bitfinex2.js +2 -3
- package/dist/cjs/src/bitmart.js +1 -1
- package/dist/cjs/src/btcbox.js +2 -3
- package/dist/cjs/src/coinbase.js +11 -5
- package/dist/cjs/src/cryptocom.js +2 -1
- package/dist/cjs/src/delta.js +25 -0
- package/dist/cjs/src/gate.js +2 -2
- package/dist/cjs/src/kraken.js +46 -45
- package/dist/cjs/src/krakenfutures.js +53 -26
- package/dist/cjs/src/kucoin.js +73 -3
- package/dist/cjs/src/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/binance.js +2 -3
- package/dist/cjs/src/pro/bitfinex.js +2 -3
- package/dist/cjs/src/pro/cex.js +1 -1
- package/dist/cjs/src/pro/gate.js +2 -2
- package/dist/cjs/src/pro/kraken.js +2 -3
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/woo.js +2 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoin.d.ts +12 -0
- package/js/src/abstract/kucoinfutures.d.ts +12 -1
- package/js/src/binance.js +145 -135
- package/js/src/bingx.js +8 -7
- package/js/src/bit2c.js +2 -3
- package/js/src/bitfinex2.js +2 -3
- package/js/src/bitmart.js +1 -1
- package/js/src/btcbox.js +2 -3
- package/js/src/coinbase.js +11 -5
- package/js/src/cryptocom.js +2 -1
- package/js/src/delta.d.ts +5 -4
- package/js/src/delta.js +25 -0
- package/js/src/gate.js +2 -2
- package/js/src/kraken.js +46 -45
- package/js/src/krakenfutures.js +53 -26
- package/js/src/kucoin.d.ts +3 -0
- package/js/src/kucoin.js +73 -3
- package/js/src/kucoinfutures.js +1 -1
- package/js/src/pro/binance.js +2 -3
- package/js/src/pro/bitfinex.js +2 -3
- package/js/src/pro/cex.js +1 -1
- package/js/src/pro/gate.js +2 -2
- package/js/src/pro/kraken.js +2 -3
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/woo.js +2 -3
- package/package.json +2 -2
package/js/src/cryptocom.js
CHANGED
|
@@ -1910,6 +1910,7 @@ export default class cryptocom extends Exchange {
|
|
|
1910
1910
|
const timestamp = this.safeInteger(ticker, 't');
|
|
1911
1911
|
const marketId = this.safeString(ticker, 'i');
|
|
1912
1912
|
market = this.safeMarket(marketId, market, '_');
|
|
1913
|
+
const quote = this.safeString(market, 'quote');
|
|
1913
1914
|
const last = this.safeString(ticker, 'a');
|
|
1914
1915
|
return this.safeTicker({
|
|
1915
1916
|
'symbol': market['symbol'],
|
|
@@ -1930,7 +1931,7 @@ export default class cryptocom extends Exchange {
|
|
|
1930
1931
|
'percentage': this.safeString(ticker, 'c'),
|
|
1931
1932
|
'average': undefined,
|
|
1932
1933
|
'baseVolume': this.safeString(ticker, 'v'),
|
|
1933
|
-
'quoteVolume': this.safeString(ticker, 'vv'),
|
|
1934
|
+
'quoteVolume': (quote === 'USD') ? this.safeString(ticker, 'vv') : undefined,
|
|
1934
1935
|
'info': ticker,
|
|
1935
1936
|
}, market);
|
|
1936
1937
|
}
|
package/js/src/delta.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/delta.js';
|
|
2
|
-
import type { Balances, Currency, Greeks, Int, Market, MarketInterface, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade } from './base/types.js';
|
|
2
|
+
import type { Balances, Currency, Greeks, Int, Market, MarketInterface, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Position } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class delta
|
|
5
5
|
* @augments Exchange
|
|
@@ -31,9 +31,9 @@ export default class delta extends Exchange {
|
|
|
31
31
|
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
32
32
|
parseBalance(response: any): Balances;
|
|
33
33
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
34
|
-
fetchPosition(symbol: string, params?: {}): Promise<
|
|
35
|
-
fetchPositions(symbols?: Strings, params?: {}): Promise<
|
|
36
|
-
parsePosition(position: any, market?: Market):
|
|
34
|
+
fetchPosition(symbol: string, params?: {}): Promise<Position>;
|
|
35
|
+
fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
|
|
36
|
+
parsePosition(position: any, market?: Market): Position;
|
|
37
37
|
parseOrderStatus(status: any): string;
|
|
38
38
|
parseOrder(order: any, market?: Market): Order;
|
|
39
39
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
@@ -187,6 +187,7 @@ export default class delta extends Exchange {
|
|
|
187
187
|
underlyingPrice: number;
|
|
188
188
|
info: any;
|
|
189
189
|
};
|
|
190
|
+
closeAllPositions(params?: {}): Promise<Position[]>;
|
|
190
191
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
191
192
|
url: string;
|
|
192
193
|
method: string;
|
package/js/src/delta.js
CHANGED
|
@@ -34,6 +34,8 @@ export default class delta extends Exchange {
|
|
|
34
34
|
'addMargin': true,
|
|
35
35
|
'cancelAllOrders': true,
|
|
36
36
|
'cancelOrder': true,
|
|
37
|
+
'closeAllPositions': true,
|
|
38
|
+
'closePosition': false,
|
|
37
39
|
'createOrder': true,
|
|
38
40
|
'createReduceOnlyOrder': true,
|
|
39
41
|
'editOrder': true,
|
|
@@ -3178,6 +3180,29 @@ export default class delta extends Exchange {
|
|
|
3178
3180
|
'info': greeks,
|
|
3179
3181
|
};
|
|
3180
3182
|
}
|
|
3183
|
+
async closeAllPositions(params = {}) {
|
|
3184
|
+
/**
|
|
3185
|
+
* @method
|
|
3186
|
+
* @name delta#closeAllPositions
|
|
3187
|
+
* @description closes all open positions for a market type
|
|
3188
|
+
* @see https://docs.delta.exchange/#close-all-positions
|
|
3189
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3190
|
+
* @param {int} [params.user_id] the users id
|
|
3191
|
+
* @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3192
|
+
*/
|
|
3193
|
+
await this.loadMarkets();
|
|
3194
|
+
const request = {
|
|
3195
|
+
'close_all_portfolio': true,
|
|
3196
|
+
'close_all_isolated': true,
|
|
3197
|
+
// 'user_id': 12345,
|
|
3198
|
+
};
|
|
3199
|
+
const response = await this.privatePostPositionsCloseAll(this.extend(request, params));
|
|
3200
|
+
//
|
|
3201
|
+
// {"result":{},"success":true}
|
|
3202
|
+
//
|
|
3203
|
+
const position = this.parsePosition(this.safeValue(response, 'result', {}));
|
|
3204
|
+
return [position];
|
|
3205
|
+
}
|
|
3181
3206
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3182
3207
|
const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
|
|
3183
3208
|
let url = this.urls['api'][api] + requestPath;
|
package/js/src/gate.js
CHANGED
|
@@ -6995,7 +6995,7 @@ export default class gate extends Exchange {
|
|
|
6995
6995
|
async closePosition(symbol, side = undefined, params = {}) {
|
|
6996
6996
|
/**
|
|
6997
6997
|
* @method
|
|
6998
|
-
* @name gate#
|
|
6998
|
+
* @name gate#closePosition
|
|
6999
6999
|
* @description closes open positions for a market
|
|
7000
7000
|
* @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order
|
|
7001
7001
|
* @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order-2
|
|
@@ -7003,7 +7003,7 @@ export default class gate extends Exchange {
|
|
|
7003
7003
|
* @param {string} symbol Unified CCXT market symbol
|
|
7004
7004
|
* @param {string} side 'buy' or 'sell'
|
|
7005
7005
|
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
7006
|
-
* @returns {[
|
|
7006
|
+
* @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
7007
7007
|
*/
|
|
7008
7008
|
const request = {
|
|
7009
7009
|
'close': true,
|
package/js/src/kraken.js
CHANGED
|
@@ -827,7 +827,6 @@ export default class kraken extends Exchange {
|
|
|
827
827
|
// "o":"2571.56000"
|
|
828
828
|
// }
|
|
829
829
|
//
|
|
830
|
-
const timestamp = this.milliseconds();
|
|
831
830
|
const symbol = this.safeSymbol(undefined, market);
|
|
832
831
|
const v = this.safeValue(ticker, 'v', []);
|
|
833
832
|
const baseVolume = this.safeString(v, 1);
|
|
@@ -842,8 +841,8 @@ export default class kraken extends Exchange {
|
|
|
842
841
|
const ask = this.safeValue(ticker, 'a', []);
|
|
843
842
|
return this.safeTicker({
|
|
844
843
|
'symbol': symbol,
|
|
845
|
-
'timestamp':
|
|
846
|
-
'datetime':
|
|
844
|
+
'timestamp': undefined,
|
|
845
|
+
'datetime': undefined,
|
|
847
846
|
'high': this.safeString(high, 1),
|
|
848
847
|
'low': this.safeString(low, 1),
|
|
849
848
|
'bid': this.safeString(bid, 0),
|
|
@@ -1357,8 +1356,12 @@ export default class kraken extends Exchange {
|
|
|
1357
1356
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
1358
1357
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1359
1358
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1360
|
-
* @param {bool} params.postOnly
|
|
1361
|
-
* @param {bool} params.reduceOnly
|
|
1359
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
|
|
1360
|
+
* @param {bool} [params.reduceOnly] *margin only* indicates if this order is to reduce the size of a position
|
|
1361
|
+
* @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
|
|
1362
|
+
* @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
|
|
1363
|
+
* @param {string} [params.trailingStopPrice] *margin only* the quote amount to trail away from the current market price
|
|
1364
|
+
* @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
|
|
1362
1365
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1363
1366
|
*/
|
|
1364
1367
|
await this.loadMarkets();
|
|
@@ -1613,50 +1616,48 @@ export default class kraken extends Exchange {
|
|
|
1613
1616
|
if (clientOrderId !== undefined) {
|
|
1614
1617
|
request['userref'] = clientOrderId;
|
|
1615
1618
|
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
// settle-position
|
|
1624
|
-
//
|
|
1619
|
+
const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
|
|
1620
|
+
const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
|
|
1621
|
+
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
1622
|
+
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
1623
|
+
const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
|
|
1624
|
+
const trailingStopPrice = this.safeString(params, 'trailingStopPrice');
|
|
1625
|
+
const isTrailingStopPriceOrder = trailingStopPrice !== undefined;
|
|
1625
1626
|
if (type === 'limit') {
|
|
1626
1627
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
1627
1628
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
if (
|
|
1631
|
-
|
|
1629
|
+
let reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
1630
|
+
if (isStopLossOrTakeProfitTrigger) {
|
|
1631
|
+
if (isStopLossTriggerOrder) {
|
|
1632
|
+
request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
1633
|
+
request['ordertype'] = 'stop-loss-limit';
|
|
1632
1634
|
}
|
|
1633
|
-
else {
|
|
1634
|
-
request['price'] = this.priceToPrecision(symbol,
|
|
1635
|
+
else if (isTakeProfitTriggerOrder) {
|
|
1636
|
+
request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
1637
|
+
request['ordertype'] = 'take-profit-limit';
|
|
1635
1638
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
const
|
|
1641
|
-
const
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1639
|
+
request['price2'] = this.priceToPrecision(symbol, price);
|
|
1640
|
+
reduceOnly = true;
|
|
1641
|
+
}
|
|
1642
|
+
else if (isTrailingStopPriceOrder) {
|
|
1643
|
+
const trailingStopActivationPriceType = this.safeString(params, 'trigger', 'last');
|
|
1644
|
+
const trailingStopPriceString = '+' + trailingStopPrice;
|
|
1645
|
+
request['trigger'] = trailingStopActivationPriceType;
|
|
1646
|
+
reduceOnly = true;
|
|
1647
|
+
if (type === 'limit') {
|
|
1648
|
+
const trailingStopLimitPriceString = '+' + this.numberToString(price);
|
|
1649
|
+
request['price'] = trailingStopPriceString;
|
|
1650
|
+
request['price2'] = trailingStopLimitPriceString;
|
|
1651
|
+
request['ordertype'] = 'trailing-stop-limit';
|
|
1648
1652
|
}
|
|
1649
1653
|
else {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
request['price2'] = this.priceToPrecision(symbol, price);
|
|
1653
|
-
}
|
|
1654
|
-
else if (limitPriceDefined) {
|
|
1655
|
-
request['price'] = this.priceToPrecision(symbol, price);
|
|
1656
|
-
request['price2'] = this.priceToPrecision(symbol, limitPrice);
|
|
1657
|
-
}
|
|
1654
|
+
request['price'] = trailingStopPriceString;
|
|
1655
|
+
request['ordertype'] = 'trailing-stop';
|
|
1658
1656
|
}
|
|
1659
1657
|
}
|
|
1658
|
+
if (reduceOnly) {
|
|
1659
|
+
request['reduce_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
|
|
1660
|
+
}
|
|
1660
1661
|
let close = this.safeValue(params, 'close');
|
|
1661
1662
|
if (close !== undefined) {
|
|
1662
1663
|
close = this.extend({}, close);
|
|
@@ -1680,11 +1681,7 @@ export default class kraken extends Exchange {
|
|
|
1680
1681
|
if (postOnly) {
|
|
1681
1682
|
request['oflags'] = 'post';
|
|
1682
1683
|
}
|
|
1683
|
-
|
|
1684
|
-
if (reduceOnly) {
|
|
1685
|
-
request['reduce_only'] = true;
|
|
1686
|
-
}
|
|
1687
|
-
params = this.omit(params, ['price', 'stopPrice', 'price2', 'close', 'timeInForce', 'reduceOnly']);
|
|
1684
|
+
params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingStopPrice']);
|
|
1688
1685
|
return [request, params];
|
|
1689
1686
|
}
|
|
1690
1687
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
@@ -1700,6 +1697,10 @@ export default class kraken extends Exchange {
|
|
|
1700
1697
|
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
1701
1698
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1702
1699
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1700
|
+
* @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
|
|
1701
|
+
* @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
|
|
1702
|
+
* @param {string} [params.trailingStopPrice] *margin only* the quote price away from the current market price
|
|
1703
|
+
* @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
|
|
1703
1704
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1704
1705
|
*/
|
|
1705
1706
|
await this.loadMarkets();
|
package/js/src/krakenfutures.js
CHANGED
|
@@ -844,20 +844,12 @@ export default class krakenfutures extends Exchange {
|
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
846
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
847
|
+
const market = this.market(symbol);
|
|
847
848
|
type = this.safeString(params, 'orderType', type);
|
|
848
849
|
const timeInForce = this.safeString(params, 'timeInForce');
|
|
849
|
-
const stopPrice = this.safeString(params, 'stopPrice');
|
|
850
850
|
let postOnly = false;
|
|
851
851
|
[postOnly, params] = this.handlePostOnly(type === 'market', type === 'post', params);
|
|
852
|
-
|
|
853
|
-
params = this.omit(params, ['clientOrderId', 'cliOrdId']);
|
|
854
|
-
if ((type === 'stp' || type === 'take_profit') && stopPrice === undefined) {
|
|
855
|
-
throw new ArgumentsRequired(this.id + ' createOrder requires params.stopPrice when type is ' + type);
|
|
856
|
-
}
|
|
857
|
-
if (stopPrice !== undefined && type !== 'take_profit') {
|
|
858
|
-
type = 'stp';
|
|
859
|
-
}
|
|
860
|
-
else if (postOnly) {
|
|
852
|
+
if (postOnly) {
|
|
861
853
|
type = 'post';
|
|
862
854
|
}
|
|
863
855
|
else if (timeInForce === 'ioc') {
|
|
@@ -870,17 +862,49 @@ export default class krakenfutures extends Exchange {
|
|
|
870
862
|
type = 'mkt';
|
|
871
863
|
}
|
|
872
864
|
const request = {
|
|
873
|
-
'
|
|
874
|
-
'symbol': this.marketId(symbol),
|
|
865
|
+
'symbol': market['id'],
|
|
875
866
|
'side': side,
|
|
876
867
|
'size': amount,
|
|
877
868
|
};
|
|
878
|
-
|
|
879
|
-
request['limitPrice'] = price;
|
|
880
|
-
}
|
|
869
|
+
const clientOrderId = this.safeString2(params, 'clientOrderId', 'cliOrdId');
|
|
881
870
|
if (clientOrderId !== undefined) {
|
|
882
871
|
request['cliOrdId'] = clientOrderId;
|
|
883
872
|
}
|
|
873
|
+
const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
|
|
874
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
875
|
+
const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
|
|
876
|
+
const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
|
|
877
|
+
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
878
|
+
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
879
|
+
const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
|
|
880
|
+
const triggerSignal = this.safeString(params, 'triggerSignal', 'last');
|
|
881
|
+
let reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
882
|
+
if (isStopLossOrTakeProfitTrigger || isTriggerOrder) {
|
|
883
|
+
request['triggerSignal'] = triggerSignal;
|
|
884
|
+
}
|
|
885
|
+
if (isTriggerOrder) {
|
|
886
|
+
type = 'stp';
|
|
887
|
+
request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
888
|
+
}
|
|
889
|
+
else if (isStopLossOrTakeProfitTrigger) {
|
|
890
|
+
reduceOnly = true;
|
|
891
|
+
if (isStopLossTriggerOrder) {
|
|
892
|
+
type = 'stp';
|
|
893
|
+
request['stopPrice'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
894
|
+
}
|
|
895
|
+
else if (isTakeProfitTriggerOrder) {
|
|
896
|
+
type = 'take_profit';
|
|
897
|
+
request['stopPrice'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
if (reduceOnly) {
|
|
901
|
+
request['reduceOnly'] = true;
|
|
902
|
+
}
|
|
903
|
+
request['orderType'] = type;
|
|
904
|
+
if (price !== undefined) {
|
|
905
|
+
request['limitPrice'] = price;
|
|
906
|
+
}
|
|
907
|
+
params = this.omit(params, ['clientOrderId', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
884
908
|
return this.extend(request, params);
|
|
885
909
|
}
|
|
886
910
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -888,19 +912,22 @@ export default class krakenfutures extends Exchange {
|
|
|
888
912
|
* @method
|
|
889
913
|
* @name krakenfutures#createOrder
|
|
890
914
|
* @description Create an order on the exchange
|
|
891
|
-
* @
|
|
892
|
-
* @param {string}
|
|
893
|
-
* @param {string}
|
|
894
|
-
* @param {
|
|
895
|
-
* @param {float}
|
|
896
|
-
* @param {float} [
|
|
897
|
-
* @param {bool} [params.reduceOnly]
|
|
898
|
-
* @param {bool} [params.postOnly]
|
|
899
|
-
* @param {string} [params.triggerSignal] If placing a stp or take_profit, the signal used for trigger, One of: 'mark', 'index', 'last', last is market price
|
|
900
|
-
* @param {string} [params.cliOrdId] UUID The order identity that is specified from the user, It must be globally unique
|
|
915
|
+
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-send-order
|
|
916
|
+
* @param {string} symbol unified market symbol
|
|
917
|
+
* @param {string} type 'limit' or 'market'
|
|
918
|
+
* @param {string} side 'buy' or 'sell'
|
|
919
|
+
* @param {float} amount number of contracts
|
|
920
|
+
* @param {float} [price] limit order price
|
|
921
|
+
* @param {bool} [params.reduceOnly] set as true if you wish the order to only reduce an existing position, any order which increases an existing position will be rejected, default is false
|
|
922
|
+
* @param {bool} [params.postOnly] set as true if you wish to make a postOnly order, default is false
|
|
901
923
|
* @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
|
|
924
|
+
* @param {float} [params.triggerPrice] the price that a stop order is triggered at
|
|
925
|
+
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
|
|
926
|
+
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
|
|
927
|
+
* @param {string} [params.triggerSignal] for triggerPrice, stopLossPrice and takeProfitPrice orders, the trigger price type, 'last', 'mark' or 'index', default is 'last'
|
|
902
928
|
*/
|
|
903
929
|
await this.loadMarkets();
|
|
930
|
+
const market = this.market(symbol);
|
|
904
931
|
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
905
932
|
const response = await this.privatePostSendorder(orderRequest);
|
|
906
933
|
//
|
|
@@ -936,7 +963,7 @@ export default class krakenfutures extends Exchange {
|
|
|
936
963
|
const sendStatus = this.safeValue(response, 'sendStatus');
|
|
937
964
|
const status = this.safeString(sendStatus, 'status');
|
|
938
965
|
this.verifyOrderActionSuccess(status, 'createOrder', ['filled']);
|
|
939
|
-
return this.parseOrder(sendStatus);
|
|
966
|
+
return this.parseOrder(sendStatus, market);
|
|
940
967
|
}
|
|
941
968
|
async createOrders(orders, params = {}) {
|
|
942
969
|
/**
|
package/js/src/kucoin.d.ts
CHANGED
|
@@ -78,6 +78,9 @@ export default class kucoin extends Exchange {
|
|
|
78
78
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
79
79
|
handleTriggerPrices(params: any): any[];
|
|
80
80
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
81
|
+
createMarketOrderWithCost(symbol: string, side: OrderSide, cost: any, params?: {}): Promise<Order>;
|
|
82
|
+
createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
83
|
+
createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
81
84
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
82
85
|
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
83
86
|
editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
|
package/js/src/kucoin.js
CHANGED
|
@@ -47,6 +47,9 @@ export default class kucoin extends Exchange {
|
|
|
47
47
|
'createStopLimitOrder': true,
|
|
48
48
|
'createStopMarketOrder': true,
|
|
49
49
|
'createStopOrder': true,
|
|
50
|
+
'createMarketBuyOrderWithCost': true,
|
|
51
|
+
'createMarketOrderWithCost': true,
|
|
52
|
+
'createMarketSellOrderWithCost': true,
|
|
50
53
|
'editOrder': true,
|
|
51
54
|
'fetchAccounts': true,
|
|
52
55
|
'fetchBalance': true,
|
|
@@ -208,6 +211,10 @@ export default class kucoin extends Exchange {
|
|
|
208
211
|
'stop-order': 8,
|
|
209
212
|
'stop-order/{orderId}': 3,
|
|
210
213
|
'stop-order/queryOrderByClientOid': 3,
|
|
214
|
+
'oco/order/{orderId}': 2,
|
|
215
|
+
'oco/order/details/{orderId}': 2,
|
|
216
|
+
'oco/client-order/{clientOid}': 2,
|
|
217
|
+
'oco/orders': 2,
|
|
211
218
|
// margin trading
|
|
212
219
|
'hf/margin/orders/active': 4,
|
|
213
220
|
'hf/margin/orders/done': 10,
|
|
@@ -215,6 +222,7 @@ export default class kucoin extends Exchange {
|
|
|
215
222
|
'hf/margin/orders/client-order/{clientOid}': 5,
|
|
216
223
|
'hf/margin/fills': 5,
|
|
217
224
|
'etf/info': 25,
|
|
225
|
+
'margin/currencies': 20,
|
|
218
226
|
'risk/limit/strategy': 20,
|
|
219
227
|
'isolated/symbols': 20,
|
|
220
228
|
'isolated/account/{symbol}': 50,
|
|
@@ -250,6 +258,7 @@ export default class kucoin extends Exchange {
|
|
|
250
258
|
'orders/test': 2,
|
|
251
259
|
'orders/multi': 3,
|
|
252
260
|
'stop-order': 2,
|
|
261
|
+
'oco/order': 2,
|
|
253
262
|
// margin trading
|
|
254
263
|
'hf/margin/order': 5,
|
|
255
264
|
'hf/margin/order/test': 5,
|
|
@@ -275,12 +284,16 @@ export default class kucoin extends Exchange {
|
|
|
275
284
|
'hf/orders/sync/client-order/{clientOid}': 1,
|
|
276
285
|
'hf/orders/cancel/{orderId}': 2,
|
|
277
286
|
'hf/orders': 2,
|
|
287
|
+
'hf/orders/cancelAll': 30,
|
|
278
288
|
'orders/{orderId}': 3,
|
|
279
289
|
'order/client-order/{clientOid}': 5,
|
|
280
290
|
'orders': 20,
|
|
281
291
|
'stop-order/{orderId}': 3,
|
|
282
292
|
'stop-order/cancelOrderByClientOid': 5,
|
|
283
293
|
'stop-order/cancel': 3,
|
|
294
|
+
'oco/order/{orderId}': 3,
|
|
295
|
+
'oco/client-order/{clientOid}': 3,
|
|
296
|
+
'oco/orders': 3,
|
|
284
297
|
// margin trading
|
|
285
298
|
'hf/margin/orders/{orderId}': 5,
|
|
286
299
|
'hf/margin/orders/client-order/{clientOid}': 5,
|
|
@@ -301,6 +314,7 @@ export default class kucoin extends Exchange {
|
|
|
301
314
|
'index/query': 3,
|
|
302
315
|
'mark-price/{symbol}/current': 4.5,
|
|
303
316
|
'premium/query': 4.5,
|
|
317
|
+
'trade-statistics': 4.5,
|
|
304
318
|
'funding-rate/{symbol}/current': 3,
|
|
305
319
|
'timestamp': 3,
|
|
306
320
|
'status': 6,
|
|
@@ -349,6 +363,7 @@ export default class kucoin extends Exchange {
|
|
|
349
363
|
},
|
|
350
364
|
'delete': {
|
|
351
365
|
'orders/{orderId}': 1.5,
|
|
366
|
+
'orders/client-order/{clientOid}': 1.5,
|
|
352
367
|
'orders': 45,
|
|
353
368
|
'stopOrders': 22.5, // 15FW
|
|
354
369
|
},
|
|
@@ -536,6 +551,10 @@ export default class kucoin extends Exchange {
|
|
|
536
551
|
'market/orderbook/level2': 'v3',
|
|
537
552
|
'market/orderbook/level3': 'v3',
|
|
538
553
|
'market/orderbook/level{level}': 'v3',
|
|
554
|
+
'oco/order/{orderId}': 'v3',
|
|
555
|
+
'oco/order/details/{orderId}': 'v3',
|
|
556
|
+
'oco/client-order/{clientOid}': 'v3',
|
|
557
|
+
'oco/orders': 'v3',
|
|
539
558
|
// margin trading
|
|
540
559
|
'hf/margin/orders/active': 'v3',
|
|
541
560
|
'hf/margin/orders/done': 'v3',
|
|
@@ -543,6 +562,7 @@ export default class kucoin extends Exchange {
|
|
|
543
562
|
'hf/margin/orders/client-order/{clientOid}': 'v3',
|
|
544
563
|
'hf/margin/fills': 'v3',
|
|
545
564
|
'etf/info': 'v3',
|
|
565
|
+
'margin/currencies': 'v3',
|
|
546
566
|
'margin/borrow': 'v3',
|
|
547
567
|
'margin/repay': 'v3',
|
|
548
568
|
'project/list': 'v3',
|
|
@@ -559,6 +579,7 @@ export default class kucoin extends Exchange {
|
|
|
559
579
|
'accounts/inner-transfer': 'v2',
|
|
560
580
|
'transfer-out': 'v3',
|
|
561
581
|
// spot trading
|
|
582
|
+
'oco/order': 'v3',
|
|
562
583
|
// margin trading
|
|
563
584
|
'hf/margin/order': 'v3',
|
|
564
585
|
'hf/margin/order/test': 'v3',
|
|
@@ -575,6 +596,9 @@ export default class kucoin extends Exchange {
|
|
|
575
596
|
'hf/margin/orders/{orderId}': 'v3',
|
|
576
597
|
'hf/margin/orders/client-order/{clientOid}': 'v3',
|
|
577
598
|
'hf/margin/orders': 'v3',
|
|
599
|
+
'oco/order/{orderId}': 'v3',
|
|
600
|
+
'oco/client-order/{clientOid}': 'v3',
|
|
601
|
+
'oco/orders': 'v3',
|
|
578
602
|
// margin trading
|
|
579
603
|
},
|
|
580
604
|
},
|
|
@@ -1930,6 +1954,50 @@ export default class kucoin extends Exchange {
|
|
|
1930
1954
|
const data = this.safeValue(response, 'data', {});
|
|
1931
1955
|
return this.parseOrder(data, market);
|
|
1932
1956
|
}
|
|
1957
|
+
async createMarketOrderWithCost(symbol, side, cost, params = {}) {
|
|
1958
|
+
/**
|
|
1959
|
+
* @method
|
|
1960
|
+
* @name kucoin#createMarketOrderWithCost
|
|
1961
|
+
* @description create a market order by providing the symbol, side and cost
|
|
1962
|
+
* @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
|
|
1963
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1964
|
+
* @param {string} side 'buy' or 'sell'
|
|
1965
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1966
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1967
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1968
|
+
*/
|
|
1969
|
+
await this.loadMarkets();
|
|
1970
|
+
params['cost'] = cost;
|
|
1971
|
+
return await this.createOrder(symbol, 'market', side, cost, undefined, params);
|
|
1972
|
+
}
|
|
1973
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
1974
|
+
/**
|
|
1975
|
+
* @method
|
|
1976
|
+
* @name kucoin#createMarketBuyOrderWithCost
|
|
1977
|
+
* @description create a market buy order by providing the symbol and cost
|
|
1978
|
+
* @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
|
|
1979
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1980
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1981
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1982
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1983
|
+
*/
|
|
1984
|
+
await this.loadMarkets();
|
|
1985
|
+
return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
|
|
1986
|
+
}
|
|
1987
|
+
async createMarketSellOrderWithCost(symbol, cost, params = {}) {
|
|
1988
|
+
/**
|
|
1989
|
+
* @method
|
|
1990
|
+
* @name kucoin#createMarketSellOrderWithCost
|
|
1991
|
+
* @description create a market sell order by providing the symbol and cost
|
|
1992
|
+
* @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
|
|
1993
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1994
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1995
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1996
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1997
|
+
*/
|
|
1998
|
+
await this.loadMarkets();
|
|
1999
|
+
return await this.createMarketOrderWithCost(symbol, 'sell', cost, params);
|
|
2000
|
+
}
|
|
1933
2001
|
async createOrders(orders, params = {}) {
|
|
1934
2002
|
/**
|
|
1935
2003
|
* @method
|
|
@@ -2228,9 +2296,11 @@ export default class kucoin extends Exchange {
|
|
|
2228
2296
|
}
|
|
2229
2297
|
else if (hf) {
|
|
2230
2298
|
if (symbol === undefined) {
|
|
2231
|
-
|
|
2299
|
+
response = await this.privateDeleteHfOrdersCancelAll(this.extend(request, query));
|
|
2300
|
+
}
|
|
2301
|
+
else {
|
|
2302
|
+
response = await this.privateDeleteHfOrders(this.extend(request, query));
|
|
2232
2303
|
}
|
|
2233
|
-
response = await this.privateDeleteHfOrders(this.extend(request, query));
|
|
2234
2304
|
}
|
|
2235
2305
|
else {
|
|
2236
2306
|
response = await this.privateDeleteOrders(this.extend(request, query));
|
|
@@ -2487,7 +2557,7 @@ export default class kucoin extends Exchange {
|
|
|
2487
2557
|
response = await this.privateGetOrdersOrderId(this.extend(request, params));
|
|
2488
2558
|
}
|
|
2489
2559
|
}
|
|
2490
|
-
let responseData = this.safeValue(response, 'data');
|
|
2560
|
+
let responseData = this.safeValue(response, 'data', {});
|
|
2491
2561
|
if (Array.isArray(responseData)) {
|
|
2492
2562
|
responseData = this.safeValue(responseData, 0);
|
|
2493
2563
|
}
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -2443,7 +2443,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
2443
2443
|
* @param {string} side not used by kucoinfutures closePositions
|
|
2444
2444
|
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
2445
2445
|
* @param {string} [params.clientOrderId] client order id of the order
|
|
2446
|
-
* @returns {[
|
|
2446
|
+
* @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2447
2447
|
*/
|
|
2448
2448
|
await this.loadMarkets();
|
|
2449
2449
|
const market = this.market(symbol);
|
package/js/src/pro/binance.js
CHANGED
|
@@ -945,14 +945,13 @@ export default class binance extends binanceRest {
|
|
|
945
945
|
event = 'ticker';
|
|
946
946
|
}
|
|
947
947
|
let timestamp = undefined;
|
|
948
|
-
const now = this.milliseconds();
|
|
949
948
|
if (event === 'bookTicker') {
|
|
950
949
|
// take the event timestamp, if available, for spot tickers it is not
|
|
951
|
-
timestamp = this.safeInteger(message, 'E'
|
|
950
|
+
timestamp = this.safeInteger(message, 'E');
|
|
952
951
|
}
|
|
953
952
|
else {
|
|
954
953
|
// take the timestamp of the closing price for candlestick streams
|
|
955
|
-
timestamp = this.safeInteger(message, 'C'
|
|
954
|
+
timestamp = this.safeInteger(message, 'C');
|
|
956
955
|
}
|
|
957
956
|
const marketId = this.safeString(message, 's');
|
|
958
957
|
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
package/js/src/pro/bitfinex.js
CHANGED
|
@@ -212,7 +212,6 @@ export default class bitfinex extends bitfinexRest {
|
|
|
212
212
|
// 220.05, // 10 LOW float Daily low
|
|
213
213
|
// ]
|
|
214
214
|
//
|
|
215
|
-
const timestamp = this.milliseconds();
|
|
216
215
|
const marketId = this.safeString(subscription, 'pair');
|
|
217
216
|
const symbol = this.safeSymbol(marketId);
|
|
218
217
|
const channel = 'ticker';
|
|
@@ -225,8 +224,8 @@ export default class bitfinex extends bitfinexRest {
|
|
|
225
224
|
}
|
|
226
225
|
const result = {
|
|
227
226
|
'symbol': symbol,
|
|
228
|
-
'timestamp':
|
|
229
|
-
'datetime':
|
|
227
|
+
'timestamp': undefined,
|
|
228
|
+
'datetime': undefined,
|
|
230
229
|
'high': this.safeFloat(message, 9),
|
|
231
230
|
'low': this.safeFloat(message, 10),
|
|
232
231
|
'bid': this.safeFloat(message, 1),
|
package/js/src/pro/cex.js
CHANGED
|
@@ -735,7 +735,7 @@ export default class cex extends cexRest {
|
|
|
735
735
|
'rate': undefined,
|
|
736
736
|
};
|
|
737
737
|
}
|
|
738
|
-
const timestamp = this.safeInteger(data, 'time'
|
|
738
|
+
const timestamp = this.safeInteger(data, 'time');
|
|
739
739
|
order['timestamp'] = timestamp;
|
|
740
740
|
order['datetime'] = this.iso8601(timestamp);
|
|
741
741
|
order = this.safeOrder(order);
|
package/js/src/pro/gate.js
CHANGED
|
@@ -723,7 +723,7 @@ export default class gate extends gateRest {
|
|
|
723
723
|
// }
|
|
724
724
|
//
|
|
725
725
|
const result = this.safeValue(message, 'result', []);
|
|
726
|
-
const timestamp = this.safeInteger(message, '
|
|
726
|
+
const timestamp = this.safeInteger(message, 'time_ms');
|
|
727
727
|
this.balance['info'] = result;
|
|
728
728
|
this.balance['timestamp'] = timestamp;
|
|
729
729
|
this.balance['datetime'] = this.iso8601(timestamp);
|
|
@@ -799,7 +799,7 @@ export default class gate extends gateRest {
|
|
|
799
799
|
if (this.newUpdates) {
|
|
800
800
|
return positions;
|
|
801
801
|
}
|
|
802
|
-
return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
|
|
802
|
+
return this.filterBySymbolsSinceLimit(this.positions[type], symbols, since, limit, true);
|
|
803
803
|
}
|
|
804
804
|
setPositionsCache(client, type, symbols = undefined) {
|
|
805
805
|
if (this.positions === undefined) {
|