ccxt 4.1.88 → 4.1.89
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/CHANGELOG.md +8309 -5710
- package/README.md +3 -3
- package/changelog.js +101 -0
- package/dist/ccxt.browser.js +254 -76
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +8 -1
- package/dist/cjs/src/coinex.js +14 -1
- package/dist/cjs/src/okcoin.js +57 -16
- package/dist/cjs/src/phemex.js +105 -29
- package/dist/cjs/src/tokocrypto.js +28 -14
- package/dist/cjs/src/woo.js +41 -14
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/phemex.d.ts +1 -0
- package/js/src/bigone.js +9 -2
- package/js/src/coinex.js +14 -1
- package/js/src/okcoin.d.ts +1 -0
- package/js/src/okcoin.js +58 -17
- package/js/src/phemex.d.ts +2 -108
- package/js/src/phemex.js +105 -29
- package/js/src/tokocrypto.js +28 -14
- package/js/src/woo.d.ts +1 -0
- package/js/src/woo.js +42 -15
- package/package.json +2 -2
package/dist/cjs/src/woo.js
CHANGED
|
@@ -37,7 +37,10 @@ class woo extends woo$1 {
|
|
|
37
37
|
'closeAllPositions': false,
|
|
38
38
|
'closePosition': false,
|
|
39
39
|
'createDepositAddress': false,
|
|
40
|
+
'createMarketBuyOrderWithCost': true,
|
|
40
41
|
'createMarketOrder': false,
|
|
42
|
+
'createMarketOrderWithCost': false,
|
|
43
|
+
'createMarketSellOrderWithCost': false,
|
|
41
44
|
'createOrder': true,
|
|
42
45
|
'createReduceOnlyOrder': true,
|
|
43
46
|
'createStopLimitOrder': false,
|
|
@@ -739,6 +742,25 @@ class woo extends woo$1 {
|
|
|
739
742
|
}
|
|
740
743
|
return result;
|
|
741
744
|
}
|
|
745
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
746
|
+
/**
|
|
747
|
+
* @method
|
|
748
|
+
* @name woo#createMarketBuyOrderWithCost
|
|
749
|
+
* @description create a market buy order by providing the symbol and cost
|
|
750
|
+
* @see https://docs.woo.org/#send-order
|
|
751
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
752
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
753
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
754
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
755
|
+
*/
|
|
756
|
+
await this.loadMarkets();
|
|
757
|
+
const market = this.market(symbol);
|
|
758
|
+
if (!market['spot']) {
|
|
759
|
+
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
760
|
+
}
|
|
761
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
762
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
763
|
+
}
|
|
742
764
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
743
765
|
/**
|
|
744
766
|
* @method
|
|
@@ -758,9 +780,11 @@ class woo extends woo$1 {
|
|
|
758
780
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
|
759
781
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
760
782
|
* @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
783
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
761
784
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
762
785
|
*/
|
|
763
786
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
787
|
+
params = this.omit(params, ['reduceOnly', 'reduce_only']);
|
|
764
788
|
const orderType = type.toUpperCase();
|
|
765
789
|
await this.loadMarkets();
|
|
766
790
|
const market = this.market(symbol);
|
|
@@ -803,26 +827,29 @@ class woo extends woo$1 {
|
|
|
803
827
|
if (isMarket && !isStop) {
|
|
804
828
|
// for market buy it requires the amount of quote currency to spend
|
|
805
829
|
if (market['spot'] && orderSide === 'BUY') {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
830
|
+
let quoteAmount = undefined;
|
|
831
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
832
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
833
|
+
const cost = this.safeNumber2(params, 'cost', 'order_amount');
|
|
834
|
+
params = this.omit(params, ['cost', 'order_amount']);
|
|
835
|
+
if (cost !== undefined) {
|
|
836
|
+
quoteAmount = this.costToPrecision(symbol, cost);
|
|
837
|
+
}
|
|
838
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
839
|
+
if (price === undefined) {
|
|
840
|
+
throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
|
|
818
841
|
}
|
|
819
842
|
else {
|
|
820
|
-
|
|
843
|
+
const amountString = this.numberToString(amount);
|
|
844
|
+
const priceString = this.numberToString(price);
|
|
845
|
+
const costRequest = Precise["default"].stringMul(amountString, priceString);
|
|
846
|
+
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
821
847
|
}
|
|
822
848
|
}
|
|
823
849
|
else {
|
|
824
|
-
|
|
850
|
+
quoteAmount = this.costToPrecision(symbol, amount);
|
|
825
851
|
}
|
|
852
|
+
request['order_amount'] = quoteAmount;
|
|
826
853
|
}
|
|
827
854
|
else {
|
|
828
855
|
request['order_quantity'] = this.amountToPrecision(symbol, amount);
|
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.1.
|
|
7
|
+
declare const version = "4.1.88";
|
|
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.1.
|
|
41
|
+
const version = '4.1.89';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -22,6 +22,7 @@ interface Exchange {
|
|
|
22
22
|
v1GetMdSpotTicker24hrAll(params?: {}): Promise<implicitReturnType>;
|
|
23
23
|
v1GetExchangePublicProducts(params?: {}): Promise<implicitReturnType>;
|
|
24
24
|
v1GetApiDataPublicDataFundingRateHistory(params?: {}): Promise<implicitReturnType>;
|
|
25
|
+
v2GetPublicProducts(params?: {}): Promise<implicitReturnType>;
|
|
25
26
|
v2GetMdV2Orderbook(params?: {}): Promise<implicitReturnType>;
|
|
26
27
|
v2GetMdV2Trade(params?: {}): Promise<implicitReturnType>;
|
|
27
28
|
v2GetMdV2Ticker24hr(params?: {}): Promise<implicitReturnType>;
|
package/js/src/bigone.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/bigone.js';
|
|
9
|
-
import { ExchangeError, AuthenticationError, InsufficientFunds, PermissionDenied, BadRequest, BadSymbol, RateLimitExceeded, InvalidOrder, ArgumentsRequired } from './base/errors.js';
|
|
9
|
+
import { ExchangeError, AuthenticationError, InsufficientFunds, PermissionDenied, BadRequest, BadSymbol, RateLimitExceeded, InvalidOrder, ArgumentsRequired, NotSupported } from './base/errors.js';
|
|
10
10
|
import { TICK_SIZE } from './base/functions/number.js';
|
|
11
11
|
import { jwt } from './base/functions/rsa.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
@@ -34,6 +34,7 @@ export default class bigone extends Exchange {
|
|
|
34
34
|
'cancelAllOrders': true,
|
|
35
35
|
'cancelOrder': true,
|
|
36
36
|
'createMarketBuyOrderWithCost': true,
|
|
37
|
+
'createMarketOrderWithCost': false,
|
|
37
38
|
'createMarketSellOrderWithCost': false,
|
|
38
39
|
'createOrder': true,
|
|
39
40
|
'createPostOnlyOrder': true,
|
|
@@ -1161,13 +1162,18 @@ export default class bigone extends Exchange {
|
|
|
1161
1162
|
/**
|
|
1162
1163
|
* @method
|
|
1163
1164
|
* @name bigone#createMarketBuyOrderWithCost
|
|
1164
|
-
* @see https://open.big.one/docs/spot_orders.html#create-order
|
|
1165
1165
|
* @description create a market buy order by providing the symbol and cost
|
|
1166
|
+
* @see https://open.big.one/docs/spot_orders.html#create-order
|
|
1166
1167
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
1167
1168
|
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1168
1169
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1169
1170
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1170
1171
|
*/
|
|
1172
|
+
await this.loadMarkets();
|
|
1173
|
+
const market = this.market(symbol);
|
|
1174
|
+
if (!market['spot']) {
|
|
1175
|
+
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
1176
|
+
}
|
|
1171
1177
|
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
1172
1178
|
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
1173
1179
|
}
|
|
@@ -1186,6 +1192,7 @@ export default class bigone extends Exchange {
|
|
|
1186
1192
|
* @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
|
|
1187
1193
|
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
|
|
1188
1194
|
* @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
|
|
1195
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
1189
1196
|
*
|
|
1190
1197
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
1191
1198
|
* @param {string} operator *stop order only* GTE or LTE (default)
|
package/js/src/coinex.js
CHANGED
|
@@ -49,6 +49,8 @@ export default class coinex extends Exchange {
|
|
|
49
49
|
'cancelOrders': true,
|
|
50
50
|
'createDepositAddress': true,
|
|
51
51
|
'createMarketBuyOrderWithCost': true,
|
|
52
|
+
'createMarketOrderWithCost': false,
|
|
53
|
+
'createMarketSellOrderWithCost': false,
|
|
52
54
|
'createOrder': true,
|
|
53
55
|
'createOrders': true,
|
|
54
56
|
'createReduceOnlyOrder': true,
|
|
@@ -1929,13 +1931,19 @@ export default class coinex extends Exchange {
|
|
|
1929
1931
|
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
1930
1932
|
/**
|
|
1931
1933
|
* @method
|
|
1932
|
-
* @name coinex#
|
|
1934
|
+
* @name coinex#createMarketBuyOrderWithCost
|
|
1933
1935
|
* @description create a market buy order by providing the symbol and cost
|
|
1936
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
|
|
1934
1937
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
1935
1938
|
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1936
1939
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1937
1940
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1938
1941
|
*/
|
|
1942
|
+
await this.loadMarkets();
|
|
1943
|
+
const market = this.market(symbol);
|
|
1944
|
+
if (!market['spot']) {
|
|
1945
|
+
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
1946
|
+
}
|
|
1939
1947
|
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
1940
1948
|
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
1941
1949
|
}
|
|
@@ -2101,6 +2109,11 @@ export default class coinex extends Exchange {
|
|
|
2101
2109
|
* @method
|
|
2102
2110
|
* @name coinex#createOrder
|
|
2103
2111
|
* @description create a trade order
|
|
2112
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade001_limit_order
|
|
2113
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
|
|
2114
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade004_IOC_order
|
|
2115
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade005_stop_limit_order
|
|
2116
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade006_stop_market_order
|
|
2104
2117
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
|
|
2105
2118
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
|
|
2106
2119
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
|
package/js/src/okcoin.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export default class okcoin extends Exchange {
|
|
|
23
23
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
24
24
|
parseTradingBalance(response: any): Balances;
|
|
25
25
|
parseFundingBalance(response: any): Balances;
|
|
26
|
+
createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
26
27
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
27
28
|
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
28
29
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
|
package/js/src/okcoin.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/okcoin.js';
|
|
9
|
-
import { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, NetworkError, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, AccountNotEnabled, BadSymbol, RateLimitExceeded } from './base/errors.js';
|
|
9
|
+
import { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, NetworkError, InsufficientFunds, InvalidNonce, CancelPending, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, AccountNotEnabled, BadSymbol, RateLimitExceeded, NotSupported } from './base/errors.js';
|
|
10
10
|
import { Precise } from './base/Precise.js';
|
|
11
11
|
import { TICK_SIZE } from './base/functions/number.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
@@ -34,8 +34,17 @@ export default class okcoin extends Exchange {
|
|
|
34
34
|
'future': true,
|
|
35
35
|
'option': undefined,
|
|
36
36
|
'cancelOrder': true,
|
|
37
|
+
'createMarketBuyOrderWithCost': true,
|
|
38
|
+
'createMarketOrderWithCost': false,
|
|
39
|
+
'createMarketSellOrderWithCost': false,
|
|
37
40
|
'createOrder': true,
|
|
38
41
|
'fetchBalance': true,
|
|
42
|
+
'fetchBorrowInterest': false,
|
|
43
|
+
'fetchBorrowRate': false,
|
|
44
|
+
'fetchBorrowRateHistories': false,
|
|
45
|
+
'fetchBorrowRateHistory': false,
|
|
46
|
+
'fetchBorrowRates': false,
|
|
47
|
+
'fetchBorrowRatesPerSymbol': false,
|
|
39
48
|
'fetchClosedOrders': true,
|
|
40
49
|
'fetchCurrencies': true,
|
|
41
50
|
'fetchDepositAddress': true,
|
|
@@ -57,6 +66,10 @@ export default class okcoin extends Exchange {
|
|
|
57
66
|
'fetchTrades': true,
|
|
58
67
|
'fetchTransactions': undefined,
|
|
59
68
|
'fetchWithdrawals': true,
|
|
69
|
+
'reduceMargin': false,
|
|
70
|
+
'repayCrossMargin': false,
|
|
71
|
+
'repayIsolatedMargin': false,
|
|
72
|
+
'setMargin': false,
|
|
60
73
|
'transfer': true,
|
|
61
74
|
'withdraw': true,
|
|
62
75
|
},
|
|
@@ -1256,6 +1269,26 @@ export default class okcoin extends Exchange {
|
|
|
1256
1269
|
}
|
|
1257
1270
|
return this.safeBalance(result);
|
|
1258
1271
|
}
|
|
1272
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
1273
|
+
/**
|
|
1274
|
+
* @method
|
|
1275
|
+
* @name okcoin#createMarketBuyOrderWithCost
|
|
1276
|
+
* @description create a market buy order by providing the symbol and cost
|
|
1277
|
+
* @see https://www.okcoin.com/docs-v5/en/#rest-api-trade-place-order
|
|
1278
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1279
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1280
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1281
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1282
|
+
*/
|
|
1283
|
+
await this.loadMarkets();
|
|
1284
|
+
const market = this.market(symbol);
|
|
1285
|
+
if (!market['spot']) {
|
|
1286
|
+
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
1287
|
+
}
|
|
1288
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
1289
|
+
params['tgtCcy'] = 'quote_ccy';
|
|
1290
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
1291
|
+
}
|
|
1259
1292
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1260
1293
|
/**
|
|
1261
1294
|
* @method
|
|
@@ -1282,6 +1315,7 @@ export default class okcoin extends Exchange {
|
|
|
1282
1315
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
1283
1316
|
* @param {float} [params.stopLoss.price] used for stop loss limit orders, not used for stop loss market price orders
|
|
1284
1317
|
* @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
|
|
1318
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
1285
1319
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1286
1320
|
*/
|
|
1287
1321
|
await this.loadMarkets();
|
|
@@ -1330,7 +1364,7 @@ export default class okcoin extends Exchange {
|
|
|
1330
1364
|
'ordType': type,
|
|
1331
1365
|
// 'ordType': type, // privatePostTradeOrder: market, limit, post_only, fok, ioc, optimal_limit_ioc
|
|
1332
1366
|
// 'ordType': type, // privatePostTradeOrderAlgo: conditional, oco, trigger, move_order_stop, iceberg, twap
|
|
1333
|
-
'sz': this.amountToPrecision(symbol, amount),
|
|
1367
|
+
// 'sz': this.amountToPrecision (symbol, amount),
|
|
1334
1368
|
// 'px': this.priceToPrecision (symbol, price), // limit orders only
|
|
1335
1369
|
// 'reduceOnly': false,
|
|
1336
1370
|
//
|
|
@@ -1397,30 +1431,37 @@ export default class okcoin extends Exchange {
|
|
|
1397
1431
|
// see documentation: https://www.okx.com/docs-v5/en/#rest-api-trade-place-order
|
|
1398
1432
|
if (tgtCcy === 'quote_ccy') {
|
|
1399
1433
|
// quote_ccy: sz refers to units of quote currency
|
|
1400
|
-
let
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1434
|
+
let quoteAmount = undefined;
|
|
1435
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
1436
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
1437
|
+
const cost = this.safeNumber2(params, 'cost', 'sz');
|
|
1438
|
+
params = this.omit(params, ['cost', 'sz']);
|
|
1439
|
+
if (cost !== undefined) {
|
|
1440
|
+
quoteAmount = this.costToPrecision(symbol, cost);
|
|
1441
|
+
}
|
|
1442
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
1443
|
+
if (price === undefined) {
|
|
1444
|
+
throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
|
|
1410
1445
|
}
|
|
1411
|
-
else
|
|
1412
|
-
|
|
1446
|
+
else {
|
|
1447
|
+
const amountString = this.numberToString(amount);
|
|
1448
|
+
const priceString = this.numberToString(price);
|
|
1449
|
+
const costRequest = Precise.stringMul(amountString, priceString);
|
|
1450
|
+
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
1413
1451
|
}
|
|
1414
1452
|
}
|
|
1415
1453
|
else {
|
|
1416
|
-
|
|
1454
|
+
quoteAmount = this.costToPrecision(symbol, amount);
|
|
1417
1455
|
}
|
|
1418
|
-
request['sz'] =
|
|
1419
|
-
|
|
1456
|
+
request['sz'] = quoteAmount;
|
|
1457
|
+
}
|
|
1458
|
+
else {
|
|
1459
|
+
request['sz'] = this.amountToPrecision(symbol, amount);
|
|
1420
1460
|
}
|
|
1421
1461
|
}
|
|
1422
1462
|
}
|
|
1423
1463
|
else {
|
|
1464
|
+
request['sz'] = this.amountToPrecision(symbol, amount);
|
|
1424
1465
|
if ((!trigger) && (!conditional)) {
|
|
1425
1466
|
request['px'] = this.priceToPrecision(symbol, price);
|
|
1426
1467
|
}
|
package/js/src/phemex.d.ts
CHANGED
|
@@ -7,114 +7,8 @@ import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Marke
|
|
|
7
7
|
export default class phemex extends Exchange {
|
|
8
8
|
describe(): any;
|
|
9
9
|
parseSafeNumber(value?: any): any;
|
|
10
|
-
parseSwapMarket(market: any):
|
|
11
|
-
|
|
12
|
-
symbol: string;
|
|
13
|
-
base: string;
|
|
14
|
-
quote: string;
|
|
15
|
-
settle: string;
|
|
16
|
-
baseId: string;
|
|
17
|
-
quoteId: string;
|
|
18
|
-
settleId: string;
|
|
19
|
-
type: string;
|
|
20
|
-
spot: boolean;
|
|
21
|
-
margin: boolean;
|
|
22
|
-
swap: boolean;
|
|
23
|
-
future: boolean;
|
|
24
|
-
option: boolean;
|
|
25
|
-
active: boolean;
|
|
26
|
-
contract: boolean;
|
|
27
|
-
linear: boolean;
|
|
28
|
-
inverse: boolean;
|
|
29
|
-
taker: number;
|
|
30
|
-
maker: number;
|
|
31
|
-
contractSize: number;
|
|
32
|
-
expiry: any;
|
|
33
|
-
expiryDatetime: any;
|
|
34
|
-
strike: any;
|
|
35
|
-
optionType: any;
|
|
36
|
-
priceScale: number;
|
|
37
|
-
valueScale: number;
|
|
38
|
-
ratioScale: number;
|
|
39
|
-
precision: {
|
|
40
|
-
amount: number;
|
|
41
|
-
price: number;
|
|
42
|
-
};
|
|
43
|
-
limits: {
|
|
44
|
-
leverage: {
|
|
45
|
-
min: number;
|
|
46
|
-
max: number;
|
|
47
|
-
};
|
|
48
|
-
amount: {
|
|
49
|
-
min: any;
|
|
50
|
-
max: any;
|
|
51
|
-
};
|
|
52
|
-
price: {
|
|
53
|
-
min: number;
|
|
54
|
-
max: number;
|
|
55
|
-
};
|
|
56
|
-
cost: {
|
|
57
|
-
min: any;
|
|
58
|
-
max: number;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
created: any;
|
|
62
|
-
info: any;
|
|
63
|
-
};
|
|
64
|
-
parseSpotMarket(market: any): {
|
|
65
|
-
id: string;
|
|
66
|
-
symbol: string;
|
|
67
|
-
base: string;
|
|
68
|
-
quote: string;
|
|
69
|
-
settle: any;
|
|
70
|
-
baseId: string;
|
|
71
|
-
quoteId: string;
|
|
72
|
-
settleId: any;
|
|
73
|
-
type: string;
|
|
74
|
-
spot: boolean;
|
|
75
|
-
margin: boolean;
|
|
76
|
-
swap: boolean;
|
|
77
|
-
future: boolean;
|
|
78
|
-
option: boolean;
|
|
79
|
-
active: boolean;
|
|
80
|
-
contract: boolean;
|
|
81
|
-
linear: any;
|
|
82
|
-
inverse: any;
|
|
83
|
-
taker: number;
|
|
84
|
-
maker: number;
|
|
85
|
-
contractSize: any;
|
|
86
|
-
expiry: any;
|
|
87
|
-
expiryDatetime: any;
|
|
88
|
-
strike: any;
|
|
89
|
-
optionType: any;
|
|
90
|
-
priceScale: number;
|
|
91
|
-
valueScale: number;
|
|
92
|
-
ratioScale: number;
|
|
93
|
-
precision: {
|
|
94
|
-
amount: any;
|
|
95
|
-
price: any;
|
|
96
|
-
};
|
|
97
|
-
limits: {
|
|
98
|
-
leverage: {
|
|
99
|
-
min: any;
|
|
100
|
-
max: any;
|
|
101
|
-
};
|
|
102
|
-
amount: {
|
|
103
|
-
min: any;
|
|
104
|
-
max: any;
|
|
105
|
-
};
|
|
106
|
-
price: {
|
|
107
|
-
min: any;
|
|
108
|
-
max: any;
|
|
109
|
-
};
|
|
110
|
-
cost: {
|
|
111
|
-
min: any;
|
|
112
|
-
max: any;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
created: any;
|
|
116
|
-
info: any;
|
|
117
|
-
};
|
|
10
|
+
parseSwapMarket(market: any): import("./base/types.js").MarketInterface;
|
|
11
|
+
parseSpotMarket(market: any): import("./base/types.js").MarketInterface;
|
|
118
12
|
fetchMarkets(params?: {}): Promise<any[]>;
|
|
119
13
|
fetchCurrencies(params?: {}): Promise<{}>;
|
|
120
14
|
customParseBidAsk(bidask: any, priceKey?: number, amountKey?: number, market?: Market): number[];
|