ccxt 4.3.79 → 4.3.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +40 -47
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bitmart.js +4 -3
- package/dist/cjs/src/bybit.js +93 -52
- package/dist/cjs/src/poloniex.js +4 -2
- package/dist/cjs/src/yobit.js +1 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/base/Exchange.js +40 -47
- package/js/src/binance.js +1 -1
- package/js/src/bitmart.js +4 -3
- package/js/src/bybit.d.ts +3 -0
- package/js/src/bybit.js +93 -52
- package/js/src/coinbaseexchange.d.ts +1 -1
- package/js/src/poloniex.js +4 -2
- package/js/src/static_dependencies/starknet/index.d.ts +0 -4
- package/js/src/static_dependencies/starknet/index.js +0 -41
- package/js/src/static_dependencies/starknet/utils/hash/classHash.js +4 -5
- package/js/src/yobit.js +1 -0
- package/package.json +1 -1
package/js/src/base/Exchange.js
CHANGED
|
@@ -379,16 +379,6 @@ export default class Exchange {
|
|
|
379
379
|
}
|
|
380
380
|
return result;
|
|
381
381
|
}
|
|
382
|
-
checkAddress(address) {
|
|
383
|
-
if (address === undefined) {
|
|
384
|
-
throw new InvalidAddress(this.id + ' address is undefined');
|
|
385
|
-
}
|
|
386
|
-
// check the address is not the same letter like 'aaaaa' nor too short nor has a space
|
|
387
|
-
if ((this.unique(address).length === 1) || address.length < this.minFundingAddressLength || address.includes(' ')) {
|
|
388
|
-
throw new InvalidAddress(this.id + ' address is invalid or has less than ' + this.minFundingAddressLength.toString() + ' characters: "' + this.json(address) + '"');
|
|
389
|
-
}
|
|
390
|
-
return address;
|
|
391
|
-
}
|
|
392
382
|
initRestRateLimiter() {
|
|
393
383
|
if (this.rateLimit === undefined) {
|
|
394
384
|
throw new Error(this.id + '.rateLimit property is not configured');
|
|
@@ -1758,55 +1748,43 @@ export default class Exchange {
|
|
|
1758
1748
|
let httpsProxy = undefined;
|
|
1759
1749
|
let socksProxy = undefined;
|
|
1760
1750
|
// httpProxy
|
|
1761
|
-
|
|
1751
|
+
const isHttpProxyDefined = this.valueIsDefined(this.httpProxy);
|
|
1752
|
+
const isHttp_proxy_defined = this.valueIsDefined(this.http_proxy);
|
|
1753
|
+
if (isHttpProxyDefined || isHttp_proxy_defined) {
|
|
1762
1754
|
usedProxies.push('httpProxy');
|
|
1763
|
-
httpProxy = this.httpProxy;
|
|
1764
|
-
}
|
|
1765
|
-
if (this.valueIsDefined(this.http_proxy)) {
|
|
1766
|
-
usedProxies.push('http_proxy');
|
|
1767
|
-
httpProxy = this.http_proxy;
|
|
1755
|
+
httpProxy = isHttpProxyDefined ? this.httpProxy : this.http_proxy;
|
|
1768
1756
|
}
|
|
1769
|
-
|
|
1757
|
+
const ishttpProxyCallbackDefined = this.valueIsDefined(this.httpProxyCallback);
|
|
1758
|
+
const ishttp_proxy_callback_defined = this.valueIsDefined(this.http_proxy_callback);
|
|
1759
|
+
if (ishttpProxyCallbackDefined || ishttp_proxy_callback_defined) {
|
|
1770
1760
|
usedProxies.push('httpProxyCallback');
|
|
1771
|
-
httpProxy = this.httpProxyCallback(url, method, headers, body);
|
|
1772
|
-
}
|
|
1773
|
-
if (this.http_proxy_callback !== undefined) {
|
|
1774
|
-
usedProxies.push('http_proxy_callback');
|
|
1775
|
-
httpProxy = this.http_proxy_callback(url, method, headers, body);
|
|
1761
|
+
httpProxy = ishttpProxyCallbackDefined ? this.httpProxyCallback(url, method, headers, body) : this.http_proxy_callback(url, method, headers, body);
|
|
1776
1762
|
}
|
|
1777
1763
|
// httpsProxy
|
|
1778
|
-
|
|
1764
|
+
const isHttpsProxyDefined = this.valueIsDefined(this.httpsProxy);
|
|
1765
|
+
const isHttps_proxy_defined = this.valueIsDefined(this.https_proxy);
|
|
1766
|
+
if (isHttpsProxyDefined || isHttps_proxy_defined) {
|
|
1779
1767
|
usedProxies.push('httpsProxy');
|
|
1780
|
-
httpsProxy = this.httpsProxy;
|
|
1768
|
+
httpsProxy = isHttpsProxyDefined ? this.httpsProxy : this.https_proxy;
|
|
1781
1769
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
}
|
|
1786
|
-
if (this.httpsProxyCallback !== undefined) {
|
|
1770
|
+
const ishttpsProxyCallbackDefined = this.valueIsDefined(this.httpsProxyCallback);
|
|
1771
|
+
const ishttps_proxy_callback_defined = this.valueIsDefined(this.https_proxy_callback);
|
|
1772
|
+
if (ishttpsProxyCallbackDefined || ishttps_proxy_callback_defined) {
|
|
1787
1773
|
usedProxies.push('httpsProxyCallback');
|
|
1788
|
-
httpsProxy = this.httpsProxyCallback(url, method, headers, body);
|
|
1789
|
-
}
|
|
1790
|
-
if (this.https_proxy_callback !== undefined) {
|
|
1791
|
-
usedProxies.push('https_proxy_callback');
|
|
1792
|
-
httpsProxy = this.https_proxy_callback(url, method, headers, body);
|
|
1774
|
+
httpsProxy = ishttpsProxyCallbackDefined ? this.httpsProxyCallback(url, method, headers, body) : this.https_proxy_callback(url, method, headers, body);
|
|
1793
1775
|
}
|
|
1794
1776
|
// socksProxy
|
|
1795
|
-
|
|
1777
|
+
const isSocksProxyDefined = this.valueIsDefined(this.socksProxy);
|
|
1778
|
+
const isSocks_proxy_defined = this.valueIsDefined(this.socks_proxy);
|
|
1779
|
+
if (isSocksProxyDefined || isSocks_proxy_defined) {
|
|
1796
1780
|
usedProxies.push('socksProxy');
|
|
1797
|
-
socksProxy = this.socksProxy;
|
|
1781
|
+
socksProxy = isSocksProxyDefined ? this.socksProxy : this.socks_proxy;
|
|
1798
1782
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
}
|
|
1803
|
-
if (this.socksProxyCallback !== undefined) {
|
|
1783
|
+
const issocksProxyCallbackDefined = this.valueIsDefined(this.socksProxyCallback);
|
|
1784
|
+
const issocks_proxy_callback_defined = this.valueIsDefined(this.socks_proxy_callback);
|
|
1785
|
+
if (issocksProxyCallbackDefined || issocks_proxy_callback_defined) {
|
|
1804
1786
|
usedProxies.push('socksProxyCallback');
|
|
1805
|
-
socksProxy = this.socksProxyCallback(url, method, headers, body);
|
|
1806
|
-
}
|
|
1807
|
-
if (this.socks_proxy_callback !== undefined) {
|
|
1808
|
-
usedProxies.push('socks_proxy_callback');
|
|
1809
|
-
socksProxy = this.socks_proxy_callback(url, method, headers, body);
|
|
1787
|
+
socksProxy = issocksProxyCallbackDefined ? this.socksProxyCallback(url, method, headers, body) : this.socks_proxy_callback(url, method, headers, body);
|
|
1810
1788
|
}
|
|
1811
1789
|
// check
|
|
1812
1790
|
const length = usedProxies.length;
|
|
@@ -1861,6 +1839,18 @@ export default class Exchange {
|
|
|
1861
1839
|
throw new InvalidProxySettings(this.id + ' you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy');
|
|
1862
1840
|
}
|
|
1863
1841
|
}
|
|
1842
|
+
checkAddress(address = undefined) {
|
|
1843
|
+
if (address === undefined) {
|
|
1844
|
+
throw new InvalidAddress(this.id + ' address is undefined');
|
|
1845
|
+
}
|
|
1846
|
+
// check the address is not the same letter like 'aaaaa' nor too short nor has a space
|
|
1847
|
+
const uniqChars = (this.unique(this.stringToCharsArray(address)));
|
|
1848
|
+
const length = uniqChars.length; // py transpiler trick
|
|
1849
|
+
if (length === 1 || address.length < this.minFundingAddressLength || address.indexOf(' ') > -1) {
|
|
1850
|
+
throw new InvalidAddress(this.id + ' address is invalid or has less than ' + this.minFundingAddressLength.toString() + ' characters: "' + address.toString() + '"');
|
|
1851
|
+
}
|
|
1852
|
+
return address;
|
|
1853
|
+
}
|
|
1864
1854
|
findMessageHashes(client, element) {
|
|
1865
1855
|
const result = [];
|
|
1866
1856
|
const messageHashes = Object.keys(client.futures);
|
|
@@ -3827,7 +3817,10 @@ export default class Exchange {
|
|
|
3827
3817
|
];
|
|
3828
3818
|
}
|
|
3829
3819
|
getListFromObjectValues(objects, key) {
|
|
3830
|
-
|
|
3820
|
+
let newArray = objects;
|
|
3821
|
+
if (!Array.isArray(objects)) {
|
|
3822
|
+
newArray = this.toArray(objects);
|
|
3823
|
+
}
|
|
3831
3824
|
const results = [];
|
|
3832
3825
|
for (let i = 0; i < newArray.length; i++) {
|
|
3833
3826
|
results.push(newArray[i][key]);
|
package/js/src/binance.js
CHANGED
|
@@ -54,7 +54,7 @@ export default class binance extends Exchange {
|
|
|
54
54
|
'createMarketSellOrderWithCost': true,
|
|
55
55
|
'createOrder': true,
|
|
56
56
|
'createOrders': true,
|
|
57
|
-
'createOrderWithTakeProfitAndStopLoss':
|
|
57
|
+
'createOrderWithTakeProfitAndStopLoss': false,
|
|
58
58
|
'createPostOnlyOrder': true,
|
|
59
59
|
'createReduceOnlyOrder': true,
|
|
60
60
|
'createStopLimitOrder': true,
|
package/js/src/bitmart.js
CHANGED
|
@@ -2464,8 +2464,6 @@ export default class bitmart extends Exchange {
|
|
|
2464
2464
|
* @see https://developer-pro.bitmart.com/en/spot/#place-margin-order
|
|
2465
2465
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2466
2466
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
|
|
2467
|
-
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2468
|
-
* @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
|
|
2469
2467
|
* @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
|
|
2470
2468
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2471
2469
|
* @param {string} type 'market', 'limit' or 'trailing' for swap markets only
|
|
@@ -2612,6 +2610,7 @@ export default class bitmart extends Exchange {
|
|
|
2612
2610
|
* @description create a trade order
|
|
2613
2611
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2614
2612
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
|
|
2613
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
|
|
2615
2614
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2616
2615
|
* @param {string} type 'market', 'limit' or 'trailing'
|
|
2617
2616
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2671,7 +2670,9 @@ export default class bitmart extends Exchange {
|
|
|
2671
2670
|
request['activation_price_type'] = this.safeInteger(params, 'activation_price_type', 1);
|
|
2672
2671
|
}
|
|
2673
2672
|
if (isTriggerOrder) {
|
|
2674
|
-
|
|
2673
|
+
if (isLimitOrder || price !== undefined) {
|
|
2674
|
+
request['executive_price'] = this.priceToPrecision(symbol, price);
|
|
2675
|
+
}
|
|
2675
2676
|
request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
|
|
2676
2677
|
request['price_type'] = this.safeInteger(params, 'price_type', 1);
|
|
2677
2678
|
if (side === 'buy') {
|
package/js/src/bybit.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export default class bybit extends Exchange {
|
|
|
15
15
|
createExpiredOptionMarket(symbol: string): MarketInterface;
|
|
16
16
|
safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
|
|
17
17
|
getBybitType(method: any, market: any, params?: {}): any[];
|
|
18
|
+
getAmount(symbol: string, amount: number): string;
|
|
19
|
+
getPrice(symbol: string, price: string): string;
|
|
20
|
+
getCost(symbol: string, cost: string): string;
|
|
18
21
|
fetchTime(params?: {}): Promise<number>;
|
|
19
22
|
fetchCurrencies(params?: {}): Promise<Currencies>;
|
|
20
23
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
package/js/src/bybit.js
CHANGED
|
@@ -1212,6 +1212,21 @@ export default class bybit extends Exchange {
|
|
|
1212
1212
|
const optionType = this.safeString(optionParts, 3);
|
|
1213
1213
|
const datetime = this.convertExpireDate(expiry);
|
|
1214
1214
|
const timestamp = this.parse8601(datetime);
|
|
1215
|
+
let amountPrecision = undefined;
|
|
1216
|
+
let pricePrecision = undefined;
|
|
1217
|
+
// hard coded amount and price precisions from fetchOptionMarkets
|
|
1218
|
+
if (base === 'BTC') {
|
|
1219
|
+
amountPrecision = this.parseNumber('0.01');
|
|
1220
|
+
pricePrecision = this.parseNumber('5');
|
|
1221
|
+
}
|
|
1222
|
+
else if (base === 'ETH') {
|
|
1223
|
+
amountPrecision = this.parseNumber('0.1');
|
|
1224
|
+
pricePrecision = this.parseNumber('0.1');
|
|
1225
|
+
}
|
|
1226
|
+
else if (base === 'SOL') {
|
|
1227
|
+
amountPrecision = this.parseNumber('1');
|
|
1228
|
+
pricePrecision = this.parseNumber('0.01');
|
|
1229
|
+
}
|
|
1215
1230
|
return {
|
|
1216
1231
|
'id': base + '-' + this.convertExpireDateToMarketIdDate(expiry) + '-' + strike + '-' + optionType,
|
|
1217
1232
|
'symbol': base + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
|
|
@@ -1231,14 +1246,14 @@ export default class bybit extends Exchange {
|
|
|
1231
1246
|
'option': true,
|
|
1232
1247
|
'margin': false,
|
|
1233
1248
|
'contract': true,
|
|
1234
|
-
'contractSize':
|
|
1249
|
+
'contractSize': this.parseNumber('1'),
|
|
1235
1250
|
'expiry': timestamp,
|
|
1236
1251
|
'expiryDatetime': datetime,
|
|
1237
1252
|
'optionType': (optionType === 'C') ? 'call' : 'put',
|
|
1238
1253
|
'strike': this.parseNumber(strike),
|
|
1239
1254
|
'precision': {
|
|
1240
|
-
'amount':
|
|
1241
|
-
'price':
|
|
1255
|
+
'amount': amountPrecision,
|
|
1256
|
+
'price': pricePrecision,
|
|
1242
1257
|
},
|
|
1243
1258
|
'limits': {
|
|
1244
1259
|
'amount': {
|
|
@@ -1275,6 +1290,33 @@ export default class bybit extends Exchange {
|
|
|
1275
1290
|
}
|
|
1276
1291
|
return [subType, params];
|
|
1277
1292
|
}
|
|
1293
|
+
getAmount(symbol, amount) {
|
|
1294
|
+
// some markets like options might not have the precision available
|
|
1295
|
+
// and we shouldn't crash in those cases
|
|
1296
|
+
const market = this.market(symbol);
|
|
1297
|
+
const emptyPrecisionAmount = (market['precision']['amount'] === undefined);
|
|
1298
|
+
const amountString = this.numberToString(amount);
|
|
1299
|
+
if (!emptyPrecisionAmount && (amountString !== '0')) {
|
|
1300
|
+
return this.amountToPrecision(symbol, amount);
|
|
1301
|
+
}
|
|
1302
|
+
return amountString;
|
|
1303
|
+
}
|
|
1304
|
+
getPrice(symbol, price) {
|
|
1305
|
+
const market = this.market(symbol);
|
|
1306
|
+
const emptyPrecisionPrice = (market['precision']['price'] === undefined);
|
|
1307
|
+
if (!emptyPrecisionPrice) {
|
|
1308
|
+
return this.priceToPrecision(symbol, price);
|
|
1309
|
+
}
|
|
1310
|
+
return price;
|
|
1311
|
+
}
|
|
1312
|
+
getCost(symbol, cost) {
|
|
1313
|
+
const market = this.market(symbol);
|
|
1314
|
+
const emptyPrecisionPrice = (market['precision']['price'] === undefined);
|
|
1315
|
+
if (!emptyPrecisionPrice) {
|
|
1316
|
+
return this.costToPrecision(symbol, cost);
|
|
1317
|
+
}
|
|
1318
|
+
return cost;
|
|
1319
|
+
}
|
|
1278
1320
|
async fetchTime(params = {}) {
|
|
1279
1321
|
/**
|
|
1280
1322
|
* @method
|
|
@@ -1899,7 +1941,7 @@ export default class bybit extends Exchange {
|
|
|
1899
1941
|
'inverse': undefined,
|
|
1900
1942
|
'taker': this.safeNumber(market, 'takerFee', this.parseNumber('0.0006')),
|
|
1901
1943
|
'maker': this.safeNumber(market, 'makerFee', this.parseNumber('0.0001')),
|
|
1902
|
-
'contractSize': this.
|
|
1944
|
+
'contractSize': this.parseNumber('1'),
|
|
1903
1945
|
'expiry': expiry,
|
|
1904
1946
|
'expiryDatetime': this.iso8601(expiry),
|
|
1905
1947
|
'strike': this.parseNumber(strike),
|
|
@@ -3665,27 +3707,29 @@ export default class bybit extends Exchange {
|
|
|
3665
3707
|
const isLimit = lowerCaseType === 'limit';
|
|
3666
3708
|
const isBuy = side === 'buy';
|
|
3667
3709
|
const isAlternativeEndpoint = defaultMethod === 'privatePostV5PositionTradingStop';
|
|
3710
|
+
const amountString = this.getAmount(symbol, amount);
|
|
3711
|
+
const priceString = (price !== undefined) ? this.getPrice(symbol, this.numberToString(price)) : undefined;
|
|
3668
3712
|
if (isTrailingAmountOrder || isAlternativeEndpoint) {
|
|
3669
3713
|
if (isStopLoss || isTakeProfit || isTriggerOrder || market['spot']) {
|
|
3670
3714
|
throw new InvalidOrder(this.id + ' the API endpoint used only supports contract trailingAmount, stopLossPrice and takeProfitPrice orders');
|
|
3671
3715
|
}
|
|
3672
3716
|
if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
3673
3717
|
if (isStopLossTriggerOrder) {
|
|
3674
|
-
request['stopLoss'] = this.
|
|
3718
|
+
request['stopLoss'] = this.getPrice(symbol, stopLossTriggerPrice);
|
|
3675
3719
|
if (isLimit) {
|
|
3676
3720
|
request['tpslMode'] = 'Partial';
|
|
3677
3721
|
request['slOrderType'] = 'Limit';
|
|
3678
|
-
request['slLimitPrice'] =
|
|
3679
|
-
request['slSize'] =
|
|
3722
|
+
request['slLimitPrice'] = priceString;
|
|
3723
|
+
request['slSize'] = amountString;
|
|
3680
3724
|
}
|
|
3681
3725
|
}
|
|
3682
3726
|
else if (isTakeProfitTriggerOrder) {
|
|
3683
|
-
request['takeProfit'] = this.
|
|
3727
|
+
request['takeProfit'] = this.getPrice(symbol, takeProfitTriggerPrice);
|
|
3684
3728
|
if (isLimit) {
|
|
3685
3729
|
request['tpslMode'] = 'Partial';
|
|
3686
3730
|
request['tpOrderType'] = 'Limit';
|
|
3687
|
-
request['tpLimitPrice'] =
|
|
3688
|
-
request['tpSize'] =
|
|
3731
|
+
request['tpLimitPrice'] = priceString;
|
|
3732
|
+
request['tpSize'] = amountString;
|
|
3689
3733
|
}
|
|
3690
3734
|
}
|
|
3691
3735
|
}
|
|
@@ -3726,7 +3770,7 @@ export default class bybit extends Exchange {
|
|
|
3726
3770
|
request['orderLinkId'] = this.uuid16();
|
|
3727
3771
|
}
|
|
3728
3772
|
if (isLimit) {
|
|
3729
|
-
request['price'] =
|
|
3773
|
+
request['price'] = priceString;
|
|
3730
3774
|
}
|
|
3731
3775
|
}
|
|
3732
3776
|
if (market['spot']) {
|
|
@@ -3754,16 +3798,14 @@ export default class bybit extends Exchange {
|
|
|
3754
3798
|
orderCost = cost;
|
|
3755
3799
|
}
|
|
3756
3800
|
else {
|
|
3757
|
-
const amountString = this.numberToString(amount);
|
|
3758
|
-
const priceString = this.numberToString(price);
|
|
3759
3801
|
const quoteAmount = Precise.stringMul(amountString, priceString);
|
|
3760
3802
|
orderCost = quoteAmount;
|
|
3761
3803
|
}
|
|
3762
|
-
request['qty'] = this.
|
|
3804
|
+
request['qty'] = this.getCost(symbol, orderCost);
|
|
3763
3805
|
}
|
|
3764
3806
|
else {
|
|
3765
3807
|
request['marketUnit'] = 'baseCoin';
|
|
3766
|
-
request['qty'] =
|
|
3808
|
+
request['qty'] = amountString;
|
|
3767
3809
|
}
|
|
3768
3810
|
}
|
|
3769
3811
|
else if (market['spot'] && (type === 'market') && (side === 'buy')) {
|
|
@@ -3776,30 +3818,23 @@ export default class bybit extends Exchange {
|
|
|
3776
3818
|
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 in the amount argument');
|
|
3777
3819
|
}
|
|
3778
3820
|
else {
|
|
3779
|
-
const amountString = this.numberToString(amount);
|
|
3780
|
-
const priceString = this.numberToString(price);
|
|
3781
3821
|
const quoteAmount = Precise.stringMul(amountString, priceString);
|
|
3782
3822
|
const costRequest = (cost !== undefined) ? cost : quoteAmount;
|
|
3783
|
-
request['qty'] = this.
|
|
3823
|
+
request['qty'] = this.getCost(symbol, costRequest);
|
|
3784
3824
|
}
|
|
3785
3825
|
}
|
|
3786
3826
|
else {
|
|
3787
|
-
request['qty'] = this.
|
|
3827
|
+
request['qty'] = this.getCost(symbol, this.numberToString(amount));
|
|
3788
3828
|
}
|
|
3789
3829
|
}
|
|
3790
3830
|
else {
|
|
3791
3831
|
if (!isTrailingAmountOrder && !isAlternativeEndpoint) {
|
|
3792
|
-
|
|
3793
|
-
request['qty'] = this.numberToString(amount);
|
|
3794
|
-
}
|
|
3795
|
-
else {
|
|
3796
|
-
request['qty'] = this.amountToPrecision(symbol, amount);
|
|
3797
|
-
}
|
|
3832
|
+
request['qty'] = amountString;
|
|
3798
3833
|
}
|
|
3799
3834
|
}
|
|
3800
3835
|
if (isTrailingAmountOrder) {
|
|
3801
3836
|
if (trailingTriggerPrice !== undefined) {
|
|
3802
|
-
request['activePrice'] = this.
|
|
3837
|
+
request['activePrice'] = this.getPrice(symbol, trailingTriggerPrice);
|
|
3803
3838
|
}
|
|
3804
3839
|
request['trailingStop'] = trailingAmount;
|
|
3805
3840
|
}
|
|
@@ -3818,7 +3853,7 @@ export default class bybit extends Exchange {
|
|
|
3818
3853
|
const isAsending = ((triggerDirection === 'above') || (triggerDirection === '1'));
|
|
3819
3854
|
request['triggerDirection'] = isAsending ? 1 : 2;
|
|
3820
3855
|
}
|
|
3821
|
-
request['triggerPrice'] = this.
|
|
3856
|
+
request['triggerPrice'] = this.getPrice(symbol, triggerPrice);
|
|
3822
3857
|
}
|
|
3823
3858
|
else if ((isStopLossTriggerOrder || isTakeProfitTriggerOrder) && !isAlternativeEndpoint) {
|
|
3824
3859
|
if (isBuy) {
|
|
@@ -3828,28 +3863,28 @@ export default class bybit extends Exchange {
|
|
|
3828
3863
|
request['triggerDirection'] = isStopLossTriggerOrder ? 2 : 1;
|
|
3829
3864
|
}
|
|
3830
3865
|
triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
|
|
3831
|
-
request['triggerPrice'] = this.
|
|
3866
|
+
request['triggerPrice'] = this.getPrice(symbol, triggerPrice);
|
|
3832
3867
|
request['reduceOnly'] = true;
|
|
3833
3868
|
}
|
|
3834
3869
|
if ((isStopLoss || isTakeProfit) && !isAlternativeEndpoint) {
|
|
3835
3870
|
if (isStopLoss) {
|
|
3836
3871
|
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
3837
|
-
request['stopLoss'] = this.
|
|
3872
|
+
request['stopLoss'] = this.getPrice(symbol, slTriggerPrice);
|
|
3838
3873
|
const slLimitPrice = this.safeValue(stopLoss, 'price');
|
|
3839
3874
|
if (slLimitPrice !== undefined) {
|
|
3840
3875
|
request['tpslMode'] = 'Partial';
|
|
3841
3876
|
request['slOrderType'] = 'Limit';
|
|
3842
|
-
request['slLimitPrice'] = this.
|
|
3877
|
+
request['slLimitPrice'] = this.getPrice(symbol, slLimitPrice);
|
|
3843
3878
|
}
|
|
3844
3879
|
}
|
|
3845
3880
|
if (isTakeProfit) {
|
|
3846
3881
|
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
3847
|
-
request['takeProfit'] = this.
|
|
3882
|
+
request['takeProfit'] = this.getPrice(symbol, tpTriggerPrice);
|
|
3848
3883
|
const tpLimitPrice = this.safeValue(takeProfit, 'price');
|
|
3849
3884
|
if (tpLimitPrice !== undefined) {
|
|
3850
3885
|
request['tpslMode'] = 'Partial';
|
|
3851
3886
|
request['tpOrderType'] = 'Limit';
|
|
3852
|
-
request['tpLimitPrice'] = this.
|
|
3887
|
+
request['tpLimitPrice'] = this.getPrice(symbol, tpLimitPrice);
|
|
3853
3888
|
}
|
|
3854
3889
|
}
|
|
3855
3890
|
}
|
|
@@ -3960,7 +3995,7 @@ export default class bybit extends Exchange {
|
|
|
3960
3995
|
'side': this.capitalize(side),
|
|
3961
3996
|
'orderType': this.capitalize(lowerCaseType),
|
|
3962
3997
|
'timeInForce': 'GoodTillCancel',
|
|
3963
|
-
'orderQty': this.
|
|
3998
|
+
'orderQty': this.getAmount(symbol, amount),
|
|
3964
3999
|
// 'takeProfit': 123.45, // take profit price, only take effect upon opening the position
|
|
3965
4000
|
// 'stopLoss': 123.45, // stop loss price, only take effect upon opening the position
|
|
3966
4001
|
// 'reduceOnly': false, // reduce only, required for linear orders
|
|
@@ -3978,7 +4013,7 @@ export default class bybit extends Exchange {
|
|
|
3978
4013
|
const isMarket = lowerCaseType === 'market';
|
|
3979
4014
|
const isLimit = lowerCaseType === 'limit';
|
|
3980
4015
|
if (isLimit !== undefined) {
|
|
3981
|
-
request['orderPrice'] = this.
|
|
4016
|
+
request['orderPrice'] = this.getPrice(symbol, this.numberToString(price));
|
|
3982
4017
|
}
|
|
3983
4018
|
const exchangeSpecificParam = this.safeString(params, 'time_in_force');
|
|
3984
4019
|
const timeInForce = this.safeStringLower(params, 'timeInForce');
|
|
@@ -4010,7 +4045,7 @@ export default class bybit extends Exchange {
|
|
|
4010
4045
|
request['orderFilter'] = 'StopOrder';
|
|
4011
4046
|
request['trigger_by'] = 'LastPrice';
|
|
4012
4047
|
const stopPx = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
|
|
4013
|
-
const preciseStopPrice = this.
|
|
4048
|
+
const preciseStopPrice = this.getPrice(symbol, stopPx);
|
|
4014
4049
|
request['triggerPrice'] = preciseStopPrice;
|
|
4015
4050
|
const delta = this.numberToString(market['precision']['price']);
|
|
4016
4051
|
request['basePrice'] = isStopLossTriggerOrder ? Precise.stringSub(preciseStopPrice, delta) : Precise.stringAdd(preciseStopPrice, delta);
|
|
@@ -4018,11 +4053,11 @@ export default class bybit extends Exchange {
|
|
|
4018
4053
|
else if (isStopLoss || isTakeProfit) {
|
|
4019
4054
|
if (isStopLoss) {
|
|
4020
4055
|
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
4021
|
-
request['stopLoss'] = this.
|
|
4056
|
+
request['stopLoss'] = this.getPrice(symbol, slTriggerPrice);
|
|
4022
4057
|
}
|
|
4023
4058
|
if (isTakeProfit) {
|
|
4024
4059
|
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
4025
|
-
request['takeProfit'] = this.
|
|
4060
|
+
request['takeProfit'] = this.getPrice(symbol, tpTriggerPrice);
|
|
4026
4061
|
}
|
|
4027
4062
|
}
|
|
4028
4063
|
else {
|
|
@@ -4081,10 +4116,10 @@ export default class bybit extends Exchange {
|
|
|
4081
4116
|
'orderId': id,
|
|
4082
4117
|
};
|
|
4083
4118
|
if (amount !== undefined) {
|
|
4084
|
-
request['orderQty'] = this.
|
|
4119
|
+
request['orderQty'] = this.getAmount(symbol, amount);
|
|
4085
4120
|
}
|
|
4086
4121
|
if (price !== undefined) {
|
|
4087
|
-
request['orderPrice'] = this.
|
|
4122
|
+
request['orderPrice'] = this.getPrice(symbol, price);
|
|
4088
4123
|
}
|
|
4089
4124
|
let response = undefined;
|
|
4090
4125
|
if (market['option']) {
|
|
@@ -4101,13 +4136,13 @@ export default class bybit extends Exchange {
|
|
|
4101
4136
|
if (isStopOrder) {
|
|
4102
4137
|
request['orderFilter'] = isStop ? 'StopOrder' : 'Order';
|
|
4103
4138
|
if (triggerPrice !== undefined) {
|
|
4104
|
-
request['triggerPrice'] = this.
|
|
4139
|
+
request['triggerPrice'] = this.getPrice(symbol, triggerPrice);
|
|
4105
4140
|
}
|
|
4106
4141
|
if (stopLossPrice !== undefined) {
|
|
4107
|
-
request['stopLoss'] = this.
|
|
4142
|
+
request['stopLoss'] = this.getPrice(symbol, stopLossPrice);
|
|
4108
4143
|
}
|
|
4109
4144
|
if (takeProfitPrice !== undefined) {
|
|
4110
|
-
request['takeProfit'] = this.
|
|
4145
|
+
request['takeProfit'] = this.getPrice(symbol, takeProfitPrice);
|
|
4111
4146
|
}
|
|
4112
4147
|
}
|
|
4113
4148
|
params = this.omit(params, ['stop', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
@@ -4157,13 +4192,10 @@ export default class bybit extends Exchange {
|
|
|
4157
4192
|
request['category'] = 'option';
|
|
4158
4193
|
}
|
|
4159
4194
|
if (amount !== undefined) {
|
|
4160
|
-
request['qty'] = this.
|
|
4195
|
+
request['qty'] = this.getAmount(symbol, amount);
|
|
4161
4196
|
}
|
|
4162
4197
|
if (price !== undefined) {
|
|
4163
|
-
request['price'] = this.
|
|
4164
|
-
}
|
|
4165
|
-
if (amount !== undefined) {
|
|
4166
|
-
request['qty'] = this.amountToPrecision(symbol, amount);
|
|
4198
|
+
request['price'] = this.getPrice(symbol, this.numberToString(price));
|
|
4167
4199
|
}
|
|
4168
4200
|
let triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
|
|
4169
4201
|
const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
|
|
@@ -4178,7 +4210,7 @@ export default class bybit extends Exchange {
|
|
|
4178
4210
|
triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
|
|
4179
4211
|
}
|
|
4180
4212
|
if (triggerPrice !== undefined) {
|
|
4181
|
-
const triggerPriceRequest = (triggerPrice === '0') ? triggerPrice : this.
|
|
4213
|
+
const triggerPriceRequest = (triggerPrice === '0') ? triggerPrice : this.getPrice(symbol, triggerPrice);
|
|
4182
4214
|
request['triggerPrice'] = triggerPriceRequest;
|
|
4183
4215
|
const triggerBy = this.safeString(params, 'triggerBy', 'LastPrice');
|
|
4184
4216
|
request['triggerBy'] = triggerBy;
|
|
@@ -4186,14 +4218,14 @@ export default class bybit extends Exchange {
|
|
|
4186
4218
|
if (isStopLoss || isTakeProfit) {
|
|
4187
4219
|
if (isStopLoss) {
|
|
4188
4220
|
const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
4189
|
-
const stopLossRequest = (slTriggerPrice === '0') ? slTriggerPrice : this.
|
|
4221
|
+
const stopLossRequest = (slTriggerPrice === '0') ? slTriggerPrice : this.getPrice(symbol, slTriggerPrice);
|
|
4190
4222
|
request['stopLoss'] = stopLossRequest;
|
|
4191
4223
|
const slTriggerBy = this.safeString(params, 'slTriggerBy', 'LastPrice');
|
|
4192
4224
|
request['slTriggerBy'] = slTriggerBy;
|
|
4193
4225
|
}
|
|
4194
4226
|
if (isTakeProfit) {
|
|
4195
4227
|
const tpTriggerPrice = this.safeString2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
4196
|
-
const takeProfitRequest = (tpTriggerPrice === '0') ? tpTriggerPrice : this.
|
|
4228
|
+
const takeProfitRequest = (tpTriggerPrice === '0') ? tpTriggerPrice : this.getPrice(symbol, tpTriggerPrice);
|
|
4197
4229
|
request['takeProfit'] = takeProfitRequest;
|
|
4198
4230
|
const tpTriggerBy = this.safeString(params, 'tpTriggerBy', 'LastPrice');
|
|
4199
4231
|
request['tpTriggerBy'] = tpTriggerBy;
|
|
@@ -4234,10 +4266,10 @@ export default class bybit extends Exchange {
|
|
|
4234
4266
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4235
4267
|
*/
|
|
4236
4268
|
await this.loadMarkets();
|
|
4269
|
+
const market = this.market(symbol);
|
|
4237
4270
|
if (symbol === undefined) {
|
|
4238
4271
|
throw new ArgumentsRequired(this.id + ' editOrder() requires a symbol argument');
|
|
4239
4272
|
}
|
|
4240
|
-
const market = this.market(symbol);
|
|
4241
4273
|
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
4242
4274
|
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
4243
4275
|
const isUsdcSettled = market['settle'] === 'USDC';
|
|
@@ -5892,10 +5924,12 @@ export default class bybit extends Exchange {
|
|
|
5892
5924
|
* @name bybit#fetchLedger
|
|
5893
5925
|
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
|
|
5894
5926
|
* @see https://bybit-exchange.github.io/docs/v5/account/transaction-log
|
|
5927
|
+
* @see https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
|
|
5895
5928
|
* @param {string} code unified currency code, default is undefined
|
|
5896
5929
|
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
5897
5930
|
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
5898
5931
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5932
|
+
* @param {string} [params.subType] if inverse will use v5/account/contract-transaction-log
|
|
5899
5933
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
5900
5934
|
*/
|
|
5901
5935
|
await this.loadMarkets();
|
|
@@ -5939,9 +5973,16 @@ export default class bybit extends Exchange {
|
|
|
5939
5973
|
if (limit !== undefined) {
|
|
5940
5974
|
request['limit'] = limit;
|
|
5941
5975
|
}
|
|
5976
|
+
let subType = undefined;
|
|
5977
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
|
|
5942
5978
|
let response = undefined;
|
|
5943
5979
|
if (enableUnified[1]) {
|
|
5944
|
-
|
|
5980
|
+
if (subType === 'inverse') {
|
|
5981
|
+
response = await this.privateGetV5AccountContractTransactionLog(this.extend(request, params));
|
|
5982
|
+
}
|
|
5983
|
+
else {
|
|
5984
|
+
response = await this.privateGetV5AccountTransactionLog(this.extend(request, params));
|
|
5985
|
+
}
|
|
5945
5986
|
}
|
|
5946
5987
|
else {
|
|
5947
5988
|
response = await this.privateGetV2PrivateWalletFundRecords(this.extend(request, params));
|
|
@@ -66,7 +66,7 @@ export default class coinbaseexchange extends Exchange {
|
|
|
66
66
|
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
67
67
|
createDepositAddress(code: string, params?: {}): Promise<{
|
|
68
68
|
currency: string;
|
|
69
|
-
address:
|
|
69
|
+
address: string;
|
|
70
70
|
tag: string;
|
|
71
71
|
info: any;
|
|
72
72
|
}>;
|
package/js/src/poloniex.js
CHANGED
|
@@ -1108,8 +1108,10 @@ export default class poloniex extends Exchange {
|
|
|
1108
1108
|
market = this.safeMarket(marketId, market, '_');
|
|
1109
1109
|
const symbol = market['symbol'];
|
|
1110
1110
|
let resultingTrades = this.safeValue(order, 'resultingTrades');
|
|
1111
|
-
if (
|
|
1112
|
-
|
|
1111
|
+
if (resultingTrades !== undefined) {
|
|
1112
|
+
if (!Array.isArray(resultingTrades)) {
|
|
1113
|
+
resultingTrades = this.safeValue(resultingTrades, this.safeString(market, 'id', marketId));
|
|
1114
|
+
}
|
|
1113
1115
|
}
|
|
1114
1116
|
const price = this.safeString2(order, 'price', 'rate');
|
|
1115
1117
|
const amount = this.safeString(order, 'quantity');
|
|
@@ -7,44 +7,3 @@
|
|
|
7
7
|
export * as hash from './utils/hash/index.js';
|
|
8
8
|
export * from './utils/calldata/index.js';
|
|
9
9
|
export * as typedData from './utils/typedData.js';
|
|
10
|
-
// /**
|
|
11
|
-
// * Main
|
|
12
|
-
// */
|
|
13
|
-
// export * from './account/index.js';
|
|
14
|
-
// export * from './contract/index.js';
|
|
15
|
-
// export * from './types/index.js';
|
|
16
|
-
// /**
|
|
17
|
-
// * Utils
|
|
18
|
-
// */
|
|
19
|
-
// export * as constants from './constants.js';
|
|
20
|
-
// export * as encode from './utils/encode.js';
|
|
21
|
-
// export * as v3hash from './utils/hash/transactionHash/v3.js';
|
|
22
|
-
// export * as v2hash from './utils/hash/transactionHash/v2.js';
|
|
23
|
-
// export * as num from './utils/num.js';
|
|
24
|
-
// export * as transaction from './utils/transaction.js';
|
|
25
|
-
// export * as stark from './utils/stark.js';
|
|
26
|
-
// export * as eth from './utils/eth.js';
|
|
27
|
-
// export * as merkle from './utils/merkle.js';
|
|
28
|
-
// export * as uint256 from './utils/uint256.js';
|
|
29
|
-
// export * as shortString from './utils/shortString.js';
|
|
30
|
-
// export * as starknetId from './utils/starknetId.js';
|
|
31
|
-
// export * as events from './utils/events/index.js';
|
|
32
|
-
// export * from './utils/cairoDataTypes/uint256.js';
|
|
33
|
-
// export * from './utils/cairoDataTypes/uint512.js';
|
|
34
|
-
// export * from './utils/address.js';
|
|
35
|
-
// export * from './utils/url.js';
|
|
36
|
-
// export * from './utils/calldata/enum/index.js';
|
|
37
|
-
// export * from './utils/contract.js';
|
|
38
|
-
// export * from './utils/transactionReceipt.js';
|
|
39
|
-
/**
|
|
40
|
-
* Deprecated
|
|
41
|
-
*/
|
|
42
|
-
/* eslint-disable import/first */
|
|
43
|
-
// import * as num from './utils/num/index.js';
|
|
44
|
-
/** @deprecated prefer the 'num' naming */
|
|
45
|
-
// export const number = num;
|
|
46
|
-
// export * from './utils/events/index.js';
|
|
47
|
-
// export * as types from './types/index.js';
|
|
48
|
-
// export * as json from './utils/json.js';
|
|
49
|
-
// export * as provider from './utils/provider.js';
|
|
50
|
-
// export * as selector from './utils/selector/index.js';
|