ccxt 4.2.78 → 4.2.80
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 +5 -5
- package/dist/ccxt.browser.js +517 -79
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +35 -3
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bingx.js +39 -5
- package/dist/cjs/src/bitstamp.js +21 -26
- package/dist/cjs/src/bybit.js +101 -0
- package/dist/cjs/src/coinbaseinternational.js +2 -2
- package/dist/cjs/src/deribit.js +155 -0
- package/dist/cjs/src/gate.js +15 -4
- package/dist/cjs/src/hyperliquid.js +54 -10
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/binance.js +5 -5
- package/dist/cjs/src/pro/bitfinex2.js +1 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bitmex.js +1 -1
- package/dist/cjs/src/pro/bitopro.js +2 -1
- package/dist/cjs/src/pro/blockchaincom.js +1 -1
- package/dist/cjs/src/pro/bybit.js +16 -1
- package/dist/cjs/src/pro/cex.js +9 -5
- package/dist/cjs/src/pro/cryptocom.js +1 -1
- package/dist/cjs/src/pro/gemini.js +3 -2
- package/dist/cjs/src/pro/hitbtc.js +1 -1
- package/dist/cjs/src/pro/htx.js +1 -1
- package/dist/cjs/src/pro/okcoin.js +1 -1
- package/dist/cjs/src/pro/onetrading.js +1 -1
- package/dist/cjs/src/pro/phemex.js +7 -2
- package/dist/cjs/src/pro/woo.js +38 -0
- package/dist/cjs/src/upbit.js +2 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/gate.d.ts +1 -0
- package/js/src/abstract/gateio.d.ts +1 -0
- package/js/src/abstract/upbit.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +14 -5
- package/js/src/base/Exchange.js +35 -3
- package/js/src/base/types.d.ts +21 -0
- package/js/src/binance.d.ts +2 -2
- package/js/src/binance.js +1 -1
- package/js/src/bingx.js +39 -5
- package/js/src/bitstamp.js +21 -26
- package/js/src/bybit.d.ts +12 -1
- package/js/src/bybit.js +101 -0
- package/js/src/coinbaseinternational.js +2 -2
- package/js/src/deribit.d.ts +22 -1
- package/js/src/deribit.js +155 -0
- package/js/src/gate.js +15 -4
- package/js/src/hyperliquid.d.ts +1 -0
- package/js/src/hyperliquid.js +54 -10
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/binance.js +5 -5
- package/js/src/pro/bitfinex2.js +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.js +1 -1
- package/js/src/pro/bitmex.js +1 -1
- package/js/src/pro/bitopro.js +2 -1
- package/js/src/pro/blockchaincom.js +1 -1
- package/js/src/pro/bybit.js +16 -1
- package/js/src/pro/cex.js +9 -5
- package/js/src/pro/cryptocom.js +1 -1
- package/js/src/pro/gemini.d.ts +2 -2
- package/js/src/pro/gemini.js +3 -2
- package/js/src/pro/hitbtc.js +1 -1
- package/js/src/pro/htx.js +1 -1
- package/js/src/pro/okcoin.js +1 -1
- package/js/src/pro/onetrading.js +1 -1
- package/js/src/pro/phemex.js +7 -2
- package/js/src/pro/woo.js +38 -0
- package/js/src/upbit.js +2 -0
- package/package.json +1 -1
- package/skip-tests.json +7 -2
package/js/src/deribit.js
CHANGED
|
@@ -73,6 +73,8 @@ export default class deribit extends Exchange {
|
|
|
73
73
|
'fetchMyTrades': true,
|
|
74
74
|
'fetchOHLCV': true,
|
|
75
75
|
'fetchOpenOrders': true,
|
|
76
|
+
'fetchOption': true,
|
|
77
|
+
'fetchOptionChain': true,
|
|
76
78
|
'fetchOrder': true,
|
|
77
79
|
'fetchOrderBook': true,
|
|
78
80
|
'fetchOrders': false,
|
|
@@ -3459,6 +3461,159 @@ export default class deribit extends Exchange {
|
|
|
3459
3461
|
'info': greeks,
|
|
3460
3462
|
};
|
|
3461
3463
|
}
|
|
3464
|
+
async fetchOption(symbol, params = {}) {
|
|
3465
|
+
/**
|
|
3466
|
+
* @method
|
|
3467
|
+
* @name deribit#fetchOption
|
|
3468
|
+
* @description fetches option data that is commonly found in an option chain
|
|
3469
|
+
* @see https://docs.deribit.com/#public-get_book_summary_by_instrument
|
|
3470
|
+
* @param {string} symbol unified market symbol
|
|
3471
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3472
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
3473
|
+
*/
|
|
3474
|
+
await this.loadMarkets();
|
|
3475
|
+
const market = this.market(symbol);
|
|
3476
|
+
const request = {
|
|
3477
|
+
'instrument_name': market['id'],
|
|
3478
|
+
};
|
|
3479
|
+
const response = await this.publicGetGetBookSummaryByInstrument(this.extend(request, params));
|
|
3480
|
+
//
|
|
3481
|
+
// {
|
|
3482
|
+
// "jsonrpc": "2.0",
|
|
3483
|
+
// "result": [
|
|
3484
|
+
// {
|
|
3485
|
+
// "mid_price": 0.04025,
|
|
3486
|
+
// "volume_usd": 11045.12,
|
|
3487
|
+
// "quote_currency": "BTC",
|
|
3488
|
+
// "estimated_delivery_price": 65444.72,
|
|
3489
|
+
// "creation_timestamp": 1711100949273,
|
|
3490
|
+
// "base_currency": "BTC",
|
|
3491
|
+
// "underlying_index": "BTC-27DEC24",
|
|
3492
|
+
// "underlying_price": 73742.14,
|
|
3493
|
+
// "volume": 4.0,
|
|
3494
|
+
// "interest_rate": 0.0,
|
|
3495
|
+
// "price_change": -6.9767,
|
|
3496
|
+
// "open_interest": 274.2,
|
|
3497
|
+
// "ask_price": 0.042,
|
|
3498
|
+
// "bid_price": 0.0385,
|
|
3499
|
+
// "instrument_name": "BTC-27DEC24-240000-C",
|
|
3500
|
+
// "mark_price": 0.04007735,
|
|
3501
|
+
// "last": 0.04,
|
|
3502
|
+
// "low": 0.04,
|
|
3503
|
+
// "high": 0.043
|
|
3504
|
+
// }
|
|
3505
|
+
// ],
|
|
3506
|
+
// "usIn": 1711100949273223,
|
|
3507
|
+
// "usOut": 1711100949273580,
|
|
3508
|
+
// "usDiff": 357,
|
|
3509
|
+
// "testnet": false
|
|
3510
|
+
// }
|
|
3511
|
+
//
|
|
3512
|
+
const result = this.safeList(response, 'result', []);
|
|
3513
|
+
const chain = this.safeDict(result, 0, {});
|
|
3514
|
+
return this.parseOption(chain, undefined, market);
|
|
3515
|
+
}
|
|
3516
|
+
async fetchOptionChain(code, params = {}) {
|
|
3517
|
+
/**
|
|
3518
|
+
* @method
|
|
3519
|
+
* @name deribit#fetchOptionChain
|
|
3520
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
3521
|
+
* @see https://docs.deribit.com/#public-get_book_summary_by_currency
|
|
3522
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
3523
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3524
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
3525
|
+
*/
|
|
3526
|
+
await this.loadMarkets();
|
|
3527
|
+
const currency = this.currency(code);
|
|
3528
|
+
const request = {
|
|
3529
|
+
'currency': currency['id'],
|
|
3530
|
+
'kind': 'option',
|
|
3531
|
+
};
|
|
3532
|
+
const response = await this.publicGetGetBookSummaryByCurrency(this.extend(request, params));
|
|
3533
|
+
//
|
|
3534
|
+
// {
|
|
3535
|
+
// "jsonrpc": "2.0",
|
|
3536
|
+
// "result": [
|
|
3537
|
+
// {
|
|
3538
|
+
// "mid_price": 0.4075,
|
|
3539
|
+
// "volume_usd": 2836.83,
|
|
3540
|
+
// "quote_currency": "BTC",
|
|
3541
|
+
// "estimated_delivery_price": 65479.26,
|
|
3542
|
+
// "creation_timestamp": 1711101594477,
|
|
3543
|
+
// "base_currency": "BTC",
|
|
3544
|
+
// "underlying_index": "BTC-28JUN24",
|
|
3545
|
+
// "underlying_price": 68827.27,
|
|
3546
|
+
// "volume": 0.1,
|
|
3547
|
+
// "interest_rate": 0.0,
|
|
3548
|
+
// "price_change": 0.0,
|
|
3549
|
+
// "open_interest": 364.1,
|
|
3550
|
+
// "ask_price": 0.411,
|
|
3551
|
+
// "bid_price": 0.404,
|
|
3552
|
+
// "instrument_name": "BTC-28JUN24-42000-C",
|
|
3553
|
+
// "mark_price": 0.40752052,
|
|
3554
|
+
// "last": 0.423,
|
|
3555
|
+
// "low": 0.423,
|
|
3556
|
+
// "high": 0.423
|
|
3557
|
+
// }
|
|
3558
|
+
// ],
|
|
3559
|
+
// "usIn": 1711101594456388,
|
|
3560
|
+
// "usOut": 1711101594484065,
|
|
3561
|
+
// "usDiff": 27677,
|
|
3562
|
+
// "testnet": false
|
|
3563
|
+
// }
|
|
3564
|
+
//
|
|
3565
|
+
const result = this.safeList(response, 'result', []);
|
|
3566
|
+
return this.parseOptionChain(result, 'base_currency', 'instrument_name');
|
|
3567
|
+
}
|
|
3568
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
3569
|
+
//
|
|
3570
|
+
// {
|
|
3571
|
+
// "mid_price": 0.04025,
|
|
3572
|
+
// "volume_usd": 11045.12,
|
|
3573
|
+
// "quote_currency": "BTC",
|
|
3574
|
+
// "estimated_delivery_price": 65444.72,
|
|
3575
|
+
// "creation_timestamp": 1711100949273,
|
|
3576
|
+
// "base_currency": "BTC",
|
|
3577
|
+
// "underlying_index": "BTC-27DEC24",
|
|
3578
|
+
// "underlying_price": 73742.14,
|
|
3579
|
+
// "volume": 4.0,
|
|
3580
|
+
// "interest_rate": 0.0,
|
|
3581
|
+
// "price_change": -6.9767,
|
|
3582
|
+
// "open_interest": 274.2,
|
|
3583
|
+
// "ask_price": 0.042,
|
|
3584
|
+
// "bid_price": 0.0385,
|
|
3585
|
+
// "instrument_name": "BTC-27DEC24-240000-C",
|
|
3586
|
+
// "mark_price": 0.04007735,
|
|
3587
|
+
// "last": 0.04,
|
|
3588
|
+
// "low": 0.04,
|
|
3589
|
+
// "high": 0.043
|
|
3590
|
+
// }
|
|
3591
|
+
//
|
|
3592
|
+
const marketId = this.safeString(chain, 'instrument_name');
|
|
3593
|
+
market = this.safeMarket(marketId, market);
|
|
3594
|
+
const currencyId = this.safeString(chain, 'base_currency');
|
|
3595
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
3596
|
+
const timestamp = this.safeInteger(chain, 'timestamp');
|
|
3597
|
+
return {
|
|
3598
|
+
'info': chain,
|
|
3599
|
+
'currency': code['code'],
|
|
3600
|
+
'symbol': market['symbol'],
|
|
3601
|
+
'timestamp': timestamp,
|
|
3602
|
+
'datetime': this.iso8601(timestamp),
|
|
3603
|
+
'impliedVolatility': undefined,
|
|
3604
|
+
'openInterest': this.safeNumber(chain, 'open_interest'),
|
|
3605
|
+
'bidPrice': this.safeNumber(chain, 'bid_price'),
|
|
3606
|
+
'askPrice': this.safeNumber(chain, 'ask_price'),
|
|
3607
|
+
'midPrice': this.safeNumber(chain, 'mid_price'),
|
|
3608
|
+
'markPrice': this.safeNumber(chain, 'mark_price'),
|
|
3609
|
+
'lastPrice': this.safeNumber(chain, 'last'),
|
|
3610
|
+
'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
|
|
3611
|
+
'change': undefined,
|
|
3612
|
+
'percentage': this.safeNumber(chain, 'price_change'),
|
|
3613
|
+
'baseVolume': this.safeNumber(chain, 'volume'),
|
|
3614
|
+
'quoteVolume': this.safeNumber(chain, 'volume_usd'),
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3462
3617
|
nonce() {
|
|
3463
3618
|
return this.milliseconds();
|
|
3464
3619
|
}
|
package/js/src/gate.js
CHANGED
|
@@ -313,6 +313,7 @@ export default class gate extends Exchange {
|
|
|
313
313
|
'loan_records': 20 / 15,
|
|
314
314
|
'interest_records': 20 / 15,
|
|
315
315
|
'estimate_rate': 20 / 15,
|
|
316
|
+
'currency_discount_tiers': 20 / 15,
|
|
316
317
|
},
|
|
317
318
|
'post': {
|
|
318
319
|
'account_mode': 20 / 15,
|
|
@@ -4233,7 +4234,17 @@ export default class gate extends Exchange {
|
|
|
4233
4234
|
'account': account,
|
|
4234
4235
|
};
|
|
4235
4236
|
if (amount !== undefined) {
|
|
4236
|
-
|
|
4237
|
+
if (market['spot']) {
|
|
4238
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
4239
|
+
}
|
|
4240
|
+
else {
|
|
4241
|
+
if (side === 'sell') {
|
|
4242
|
+
request['size'] = Precise.stringNeg(this.amountToPrecision(symbol, amount));
|
|
4243
|
+
}
|
|
4244
|
+
else {
|
|
4245
|
+
request['size'] = this.amountToPrecision(symbol, amount);
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4237
4248
|
}
|
|
4238
4249
|
if (price !== undefined) {
|
|
4239
4250
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
@@ -5031,8 +5042,8 @@ export default class gate extends Exchange {
|
|
|
5031
5042
|
*/
|
|
5032
5043
|
await this.loadMarkets();
|
|
5033
5044
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5034
|
-
const stop = this.
|
|
5035
|
-
params = this.omit(params, 'stop');
|
|
5045
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
5046
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
5036
5047
|
const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
|
|
5037
5048
|
const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
5038
5049
|
let response = undefined;
|
|
@@ -5360,7 +5371,7 @@ export default class gate extends Exchange {
|
|
|
5360
5371
|
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
5361
5372
|
'realizedPnl': this.safeNumber(position, 'realised_pnl'),
|
|
5362
5373
|
'contracts': this.parseNumber(Precise.stringAbs(size)),
|
|
5363
|
-
'contractSize': this.
|
|
5374
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
5364
5375
|
// 'realisedPnl': position['realised_pnl'],
|
|
5365
5376
|
'marginRatio': undefined,
|
|
5366
5377
|
'liquidationPrice': this.safeNumber(position, 'liq_price'),
|
package/js/src/hyperliquid.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export default class hyperliquid extends Exchange {
|
|
|
73
73
|
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<any>;
|
|
74
74
|
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
|
|
75
75
|
withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<any>;
|
|
76
|
+
formatVaultAddress(address?: Str): string;
|
|
76
77
|
handlePublicAddress(methodName: string, params: Dict): any[];
|
|
77
78
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
78
79
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
package/js/src/hyperliquid.js
CHANGED
|
@@ -771,6 +771,8 @@ export default class hyperliquid extends Exchange {
|
|
|
771
771
|
*/
|
|
772
772
|
await this.loadMarkets();
|
|
773
773
|
const market = this.market(symbol);
|
|
774
|
+
const vaultAddress = this.safeString(params, 'vaultAddress');
|
|
775
|
+
params = this.omit(params, 'vaultAddress');
|
|
774
776
|
symbol = market['symbol'];
|
|
775
777
|
const order = {
|
|
776
778
|
'symbol': symbol,
|
|
@@ -780,7 +782,11 @@ export default class hyperliquid extends Exchange {
|
|
|
780
782
|
'price': price,
|
|
781
783
|
'params': params,
|
|
782
784
|
};
|
|
783
|
-
const
|
|
785
|
+
const globalParams = {};
|
|
786
|
+
if (vaultAddress !== undefined) {
|
|
787
|
+
globalParams['vaultAddress'] = vaultAddress;
|
|
788
|
+
}
|
|
789
|
+
const response = await this.createOrders([order], globalParams);
|
|
784
790
|
const first = this.safeDict(response, 0);
|
|
785
791
|
return first;
|
|
786
792
|
}
|
|
@@ -831,7 +837,6 @@ export default class hyperliquid extends Exchange {
|
|
|
831
837
|
const amount = this.safeString(rawOrder, 'amount');
|
|
832
838
|
const price = this.safeString(rawOrder, 'price');
|
|
833
839
|
let orderParams = this.safeDict(rawOrder, 'params', {});
|
|
834
|
-
orderParams = this.extend(params, orderParams);
|
|
835
840
|
const clientOrderId = this.safeString2(orderParams, 'clientOrderId', 'client_id');
|
|
836
841
|
const slippage = this.safeString(orderParams, 'slippage', defaultSlippage);
|
|
837
842
|
let defaultTimeInForce = (isMarket) ? 'ioc' : 'gtc';
|
|
@@ -879,6 +884,7 @@ export default class hyperliquid extends Exchange {
|
|
|
879
884
|
'tif': timeInForce,
|
|
880
885
|
};
|
|
881
886
|
}
|
|
887
|
+
orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id']);
|
|
882
888
|
const orderObj = {
|
|
883
889
|
'a': this.parseToInt(market['baseId']),
|
|
884
890
|
'b': isBuy,
|
|
@@ -891,9 +897,9 @@ export default class hyperliquid extends Exchange {
|
|
|
891
897
|
if (clientOrderId !== undefined) {
|
|
892
898
|
orderObj['c'] = clientOrderId;
|
|
893
899
|
}
|
|
894
|
-
orderReq.push(orderObj);
|
|
900
|
+
orderReq.push(this.extend(orderObj, orderParams));
|
|
895
901
|
}
|
|
896
|
-
const vaultAddress = this.safeString(params, 'vaultAddress');
|
|
902
|
+
const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
|
|
897
903
|
const orderAction = {
|
|
898
904
|
'type': 'order',
|
|
899
905
|
'orders': orderReq,
|
|
@@ -910,6 +916,10 @@ export default class hyperliquid extends Exchange {
|
|
|
910
916
|
'signature': signature,
|
|
911
917
|
// 'vaultAddress': vaultAddress,
|
|
912
918
|
};
|
|
919
|
+
if (vaultAddress !== undefined) {
|
|
920
|
+
params = this.omit(params, 'vaultAddress');
|
|
921
|
+
request['vaultAddress'] = vaultAddress;
|
|
922
|
+
}
|
|
913
923
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
914
924
|
//
|
|
915
925
|
// {
|
|
@@ -1002,10 +1012,14 @@ export default class hyperliquid extends Exchange {
|
|
|
1002
1012
|
}
|
|
1003
1013
|
}
|
|
1004
1014
|
cancelAction['cancels'] = cancelReq;
|
|
1005
|
-
const vaultAddress = this.safeString(params, 'vaultAddress');
|
|
1015
|
+
const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
|
|
1006
1016
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1007
1017
|
request['action'] = cancelAction;
|
|
1008
1018
|
request['signature'] = signature;
|
|
1019
|
+
if (vaultAddress !== undefined) {
|
|
1020
|
+
params = this.omit(params, 'vaultAddress');
|
|
1021
|
+
request['vaultAddress'] = vaultAddress;
|
|
1022
|
+
}
|
|
1009
1023
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
1010
1024
|
//
|
|
1011
1025
|
// {
|
|
@@ -1123,7 +1137,7 @@ export default class hyperliquid extends Exchange {
|
|
|
1123
1137
|
'type': 'batchModify',
|
|
1124
1138
|
'modifies': [modifyReq],
|
|
1125
1139
|
};
|
|
1126
|
-
const vaultAddress = this.safeString(params, 'vaultAddress');
|
|
1140
|
+
const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
|
|
1127
1141
|
const signature = this.signL1Action(modifyAction, nonce, vaultAddress);
|
|
1128
1142
|
const request = {
|
|
1129
1143
|
'action': modifyAction,
|
|
@@ -1131,6 +1145,10 @@ export default class hyperliquid extends Exchange {
|
|
|
1131
1145
|
'signature': signature,
|
|
1132
1146
|
// 'vaultAddress': vaultAddress,
|
|
1133
1147
|
};
|
|
1148
|
+
if (vaultAddress !== undefined) {
|
|
1149
|
+
params = this.omit(params, 'vaultAddress');
|
|
1150
|
+
request['vaultAddress'] = vaultAddress;
|
|
1151
|
+
}
|
|
1134
1152
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
1135
1153
|
//
|
|
1136
1154
|
// {
|
|
@@ -1729,7 +1747,7 @@ export default class hyperliquid extends Exchange {
|
|
|
1729
1747
|
'isolated': isIsolated,
|
|
1730
1748
|
'hedged': undefined,
|
|
1731
1749
|
'side': side,
|
|
1732
|
-
'contracts': this.
|
|
1750
|
+
'contracts': this.safeNumber(entry, 'szi'),
|
|
1733
1751
|
'contractSize': undefined,
|
|
1734
1752
|
'entryPrice': this.safeNumber(entry, 'entryPx'),
|
|
1735
1753
|
'markPrice': undefined,
|
|
@@ -1776,7 +1794,13 @@ export default class hyperliquid extends Exchange {
|
|
|
1776
1794
|
'isCross': isCross,
|
|
1777
1795
|
'leverage': leverage,
|
|
1778
1796
|
};
|
|
1779
|
-
|
|
1797
|
+
let vaultAddress = this.safeString(params, 'vaultAddress');
|
|
1798
|
+
if (vaultAddress !== undefined) {
|
|
1799
|
+
params = this.omit(params, 'vaultAddress');
|
|
1800
|
+
if (vaultAddress.startsWith('0x')) {
|
|
1801
|
+
vaultAddress = vaultAddress.replace('0x', '');
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1780
1804
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
1781
1805
|
const request = {
|
|
1782
1806
|
'action': updateAction,
|
|
@@ -1784,6 +1808,9 @@ export default class hyperliquid extends Exchange {
|
|
|
1784
1808
|
'signature': signature,
|
|
1785
1809
|
// 'vaultAddress': vaultAddress,
|
|
1786
1810
|
};
|
|
1811
|
+
if (vaultAddress !== undefined) {
|
|
1812
|
+
request['vaultAddress'] = vaultAddress;
|
|
1813
|
+
}
|
|
1787
1814
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
1788
1815
|
//
|
|
1789
1816
|
// {
|
|
@@ -1822,7 +1849,7 @@ export default class hyperliquid extends Exchange {
|
|
|
1822
1849
|
'isCross': isCross,
|
|
1823
1850
|
'leverage': leverage,
|
|
1824
1851
|
};
|
|
1825
|
-
const vaultAddress = this.safeString(params, 'vaultAddress');
|
|
1852
|
+
const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
|
|
1826
1853
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
1827
1854
|
const request = {
|
|
1828
1855
|
'action': updateAction,
|
|
@@ -1830,6 +1857,10 @@ export default class hyperliquid extends Exchange {
|
|
|
1830
1857
|
'signature': signature,
|
|
1831
1858
|
// 'vaultAddress': vaultAddress,
|
|
1832
1859
|
};
|
|
1860
|
+
if (vaultAddress !== undefined) {
|
|
1861
|
+
params = this.omit(params, 'vaultAddress');
|
|
1862
|
+
request['vaultAddress'] = vaultAddress;
|
|
1863
|
+
}
|
|
1833
1864
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
1834
1865
|
//
|
|
1835
1866
|
// {
|
|
@@ -1882,7 +1913,7 @@ export default class hyperliquid extends Exchange {
|
|
|
1882
1913
|
'isBuy': true,
|
|
1883
1914
|
'ntli': sz,
|
|
1884
1915
|
};
|
|
1885
|
-
const vaultAddress = this.safeString(params, 'vaultAddress');
|
|
1916
|
+
const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
|
|
1886
1917
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
1887
1918
|
const request = {
|
|
1888
1919
|
'action': updateAction,
|
|
@@ -1890,6 +1921,10 @@ export default class hyperliquid extends Exchange {
|
|
|
1890
1921
|
'signature': signature,
|
|
1891
1922
|
// 'vaultAddress': vaultAddress,
|
|
1892
1923
|
};
|
|
1924
|
+
if (vaultAddress !== undefined) {
|
|
1925
|
+
params = this.omit(params, 'vaultAddress');
|
|
1926
|
+
request['vaultAddress'] = vaultAddress;
|
|
1927
|
+
}
|
|
1893
1928
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
1894
1929
|
//
|
|
1895
1930
|
// {
|
|
@@ -1988,6 +2023,15 @@ export default class hyperliquid extends Exchange {
|
|
|
1988
2023
|
const response = await this.privatePostExchange(this.extend(request, params));
|
|
1989
2024
|
return response;
|
|
1990
2025
|
}
|
|
2026
|
+
formatVaultAddress(address = undefined) {
|
|
2027
|
+
if (address === undefined) {
|
|
2028
|
+
return undefined;
|
|
2029
|
+
}
|
|
2030
|
+
if (address.startsWith('0x')) {
|
|
2031
|
+
return address.replace('0x', '');
|
|
2032
|
+
}
|
|
2033
|
+
return address;
|
|
2034
|
+
}
|
|
1991
2035
|
handlePublicAddress(methodName, params) {
|
|
1992
2036
|
let userAux = undefined;
|
|
1993
2037
|
[userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
|
package/js/src/pro/alpaca.js
CHANGED
package/js/src/pro/binance.js
CHANGED
|
@@ -87,7 +87,7 @@ export default class binance extends binanceRest {
|
|
|
87
87
|
'future': 200,
|
|
88
88
|
'delivery': 200,
|
|
89
89
|
},
|
|
90
|
-
'streamBySubscriptionsHash':
|
|
90
|
+
'streamBySubscriptionsHash': this.createSafeDictionary(),
|
|
91
91
|
'streamIndex': -1,
|
|
92
92
|
// get updates every 1000ms or 100ms
|
|
93
93
|
// or every 0ms in real-time for futures
|
|
@@ -95,7 +95,7 @@ export default class binance extends binanceRest {
|
|
|
95
95
|
'tradesLimit': 1000,
|
|
96
96
|
'ordersLimit': 1000,
|
|
97
97
|
'OHLCVLimit': 1000,
|
|
98
|
-
'requestId':
|
|
98
|
+
'requestId': this.createSafeDictionary(),
|
|
99
99
|
'watchOrderBookLimit': 1000,
|
|
100
100
|
'watchTrades': {
|
|
101
101
|
'name': 'trade', // 'trade' or 'aggTrade'
|
|
@@ -129,14 +129,14 @@ export default class binance extends binanceRest {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
requestId(url) {
|
|
132
|
-
const options = this.
|
|
132
|
+
const options = this.safeDict(this.options, 'requestId', this.createSafeDictionary());
|
|
133
133
|
const previousValue = this.safeInteger(options, url, 0);
|
|
134
134
|
const newValue = this.sum(previousValue, 1);
|
|
135
135
|
this.options['requestId'][url] = newValue;
|
|
136
136
|
return newValue;
|
|
137
137
|
}
|
|
138
138
|
stream(type, subscriptionHash, numSubscriptions = 1) {
|
|
139
|
-
const streamBySubscriptionsHash = this.
|
|
139
|
+
const streamBySubscriptionsHash = this.safeDict(this.options, 'streamBySubscriptionsHash', this.createSafeDictionary());
|
|
140
140
|
let stream = this.safeString(streamBySubscriptionsHash, subscriptionHash);
|
|
141
141
|
if (stream === undefined) {
|
|
142
142
|
let streamIndex = this.safeInteger(this.options, 'streamIndex', -1);
|
|
@@ -149,7 +149,7 @@ export default class binance extends binanceRest {
|
|
|
149
149
|
this.options['streamBySubscriptionsHash'][subscriptionHash] = stream;
|
|
150
150
|
const subscriptionsByStreams = this.safeValue(this.options, 'numSubscriptionsByStream');
|
|
151
151
|
if (subscriptionsByStreams === undefined) {
|
|
152
|
-
this.options['numSubscriptionsByStream'] =
|
|
152
|
+
this.options['numSubscriptionsByStream'] = this.createSafeDictionary();
|
|
153
153
|
}
|
|
154
154
|
const subscriptionsByStream = this.safeInteger(this.options['numSubscriptionsByStream'], stream, 0);
|
|
155
155
|
const newNumSubscriptions = subscriptionsByStream + numSubscriptions;
|
package/js/src/pro/bitfinex2.js
CHANGED
|
@@ -864,7 +864,7 @@ export default class bitfinex2 extends bitfinex2Rest {
|
|
|
864
864
|
const message = this.extend(request, params);
|
|
865
865
|
this.watch(url, messageHash, message, messageHash);
|
|
866
866
|
}
|
|
867
|
-
return future;
|
|
867
|
+
return await future;
|
|
868
868
|
}
|
|
869
869
|
handleAuthenticationMessage(client, message) {
|
|
870
870
|
const messageHash = 'authenticated';
|
package/js/src/pro/bitget.js
CHANGED
|
@@ -1610,7 +1610,7 @@ export default class bitget extends bitgetRest {
|
|
|
1610
1610
|
const message = this.extend(request, params);
|
|
1611
1611
|
this.watch(url, messageHash, message, messageHash);
|
|
1612
1612
|
}
|
|
1613
|
-
return future;
|
|
1613
|
+
return await future;
|
|
1614
1614
|
}
|
|
1615
1615
|
async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
|
|
1616
1616
|
await this.authenticate();
|
package/js/src/pro/bitmart.js
CHANGED
|
@@ -1409,7 +1409,7 @@ export default class bitmart extends bitmartRest {
|
|
|
1409
1409
|
const message = this.extend(request, params);
|
|
1410
1410
|
this.watch(url, messageHash, message, messageHash);
|
|
1411
1411
|
}
|
|
1412
|
-
return future;
|
|
1412
|
+
return await future;
|
|
1413
1413
|
}
|
|
1414
1414
|
handleSubscriptionStatus(client, message) {
|
|
1415
1415
|
//
|
package/js/src/pro/bitmex.js
CHANGED
|
@@ -612,7 +612,7 @@ export default class bitmex extends bitmexRest {
|
|
|
612
612
|
const message = this.extend(request, params);
|
|
613
613
|
this.watch(url, messageHash, message, messageHash);
|
|
614
614
|
}
|
|
615
|
-
return future;
|
|
615
|
+
return await future;
|
|
616
616
|
}
|
|
617
617
|
handleAuthenticationMessage(client, message) {
|
|
618
618
|
const authenticated = this.safeBool(message, 'success', false);
|
package/js/src/pro/bitopro.js
CHANGED
|
@@ -388,7 +388,8 @@ export default class bitopro extends bitoproRest {
|
|
|
388
388
|
},
|
|
389
389
|
},
|
|
390
390
|
};
|
|
391
|
-
this.options = this.extend(defaultOptions, this.options);
|
|
391
|
+
// this.options = this.extend (defaultOptions, this.options);
|
|
392
|
+
this.extendExchangeOptions(defaultOptions);
|
|
392
393
|
const originalHeaders = this.options['ws']['options']['headers'];
|
|
393
394
|
const headers = {
|
|
394
395
|
'X-BITOPRO-API': 'ccxt',
|
package/js/src/pro/bybit.js
CHANGED
|
@@ -1040,8 +1040,23 @@ export default class bybit extends bybitRest {
|
|
|
1040
1040
|
for (let i = 0; i < rawPositions.length; i++) {
|
|
1041
1041
|
const rawPosition = rawPositions[i];
|
|
1042
1042
|
const position = this.parsePosition(rawPosition);
|
|
1043
|
+
const side = this.safeString(position, 'side');
|
|
1044
|
+
// hacky solution to handle closing positions
|
|
1045
|
+
// without crashing, we should handle this properly later
|
|
1043
1046
|
newPositions.push(position);
|
|
1044
|
-
|
|
1047
|
+
if (side === undefined || side === '') {
|
|
1048
|
+
// closing update, adding both sides to "reset" both sides
|
|
1049
|
+
// since we don't know which side is being closed
|
|
1050
|
+
position['side'] = 'long';
|
|
1051
|
+
cache.append(position);
|
|
1052
|
+
position['side'] = 'short';
|
|
1053
|
+
cache.append(position);
|
|
1054
|
+
position['side'] = undefined;
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
// regular update
|
|
1058
|
+
cache.append(position);
|
|
1059
|
+
}
|
|
1045
1060
|
}
|
|
1046
1061
|
const messageHashes = this.findMessageHashes(client, 'positions::');
|
|
1047
1062
|
for (let i = 0; i < messageHashes.length; i++) {
|
package/js/src/pro/cex.js
CHANGED
|
@@ -160,16 +160,20 @@ export default class cex extends cexRest {
|
|
|
160
160
|
// {
|
|
161
161
|
// "e": "history",
|
|
162
162
|
// "data": [
|
|
163
|
-
//
|
|
164
|
-
//
|
|
163
|
+
// 'buy:1710255706095:444444:71222.2:14892622'
|
|
164
|
+
// 'sell:1710255658251:42530:71300:14892621'
|
|
165
|
+
// 'buy:1710252424241:87913:72800:14892620'
|
|
166
|
+
// ... timestamp descending
|
|
165
167
|
// ]
|
|
166
168
|
// }
|
|
167
169
|
//
|
|
168
|
-
const data = this.
|
|
170
|
+
const data = this.safeList(message, 'data', []);
|
|
169
171
|
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
170
172
|
const stored = new ArrayCache(limit);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
const dataLength = data.length;
|
|
174
|
+
for (let i = 0; i < dataLength; i++) {
|
|
175
|
+
const index = dataLength - 1 - i;
|
|
176
|
+
const rawTrade = data[index];
|
|
173
177
|
const parsed = this.parseWsOldTrade(rawTrade);
|
|
174
178
|
stored.append(parsed);
|
|
175
179
|
}
|
package/js/src/pro/cryptocom.js
CHANGED
|
@@ -1006,7 +1006,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
1006
1006
|
const message = this.extend(request, params);
|
|
1007
1007
|
this.watch(url, messageHash, message, messageHash);
|
|
1008
1008
|
}
|
|
1009
|
-
return future;
|
|
1009
|
+
return await future;
|
|
1010
1010
|
}
|
|
1011
1011
|
handlePing(client, message) {
|
|
1012
1012
|
this.spawn(this.pong, client, message);
|
package/js/src/pro/gemini.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import geminiRest from '../gemini.js';
|
|
2
|
-
import type { Int, Str, OrderBook, Order, Trade, OHLCV, Tickers } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, Strings, OrderBook, Order, Trade, OHLCV, Tickers } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class gemini extends geminiRest {
|
|
5
5
|
describe(): any;
|
|
@@ -14,7 +14,7 @@ export default class gemini extends geminiRest {
|
|
|
14
14
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
15
15
|
handleOrderBook(client: Client, message: any): void;
|
|
16
16
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
17
|
-
watchBidsAsks(symbols
|
|
17
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
18
18
|
handleBidsAsksForMultidata(client: Client, rawBidAskChanges: any, timestamp: Int, nonce: Int): void;
|
|
19
19
|
helperForWatchMultipleConstruct(itemHashName: string, symbols: string[], params?: {}): Promise<any>;
|
|
20
20
|
handleOrderBookForMultidata(client: Client, rawOrderBookChanges: any, timestamp: Int, nonce: Int): void;
|
package/js/src/pro/gemini.js
CHANGED
|
@@ -418,7 +418,7 @@ export default class gemini extends geminiRest {
|
|
|
418
418
|
const orderbook = await this.helperForWatchMultipleConstruct('orderbook', symbols, params);
|
|
419
419
|
return orderbook.limit();
|
|
420
420
|
}
|
|
421
|
-
async watchBidsAsks(symbols
|
|
421
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
422
422
|
/**
|
|
423
423
|
* @method
|
|
424
424
|
* @name gemini#watchBidsAsks
|
|
@@ -914,7 +914,8 @@ export default class gemini extends geminiRest {
|
|
|
914
914
|
},
|
|
915
915
|
},
|
|
916
916
|
};
|
|
917
|
-
this.options = this.extend(defaultOptions, this.options);
|
|
917
|
+
// this.options = this.extend (defaultOptions, this.options);
|
|
918
|
+
this.extendExchangeOptions(defaultOptions);
|
|
918
919
|
const originalHeaders = this.options['ws']['options']['headers'];
|
|
919
920
|
const headers = {
|
|
920
921
|
'X-GEMINI-APIKEY': this.apiKey,
|
package/js/src/pro/hitbtc.js
CHANGED
package/js/src/pro/htx.js
CHANGED
package/js/src/pro/okcoin.js
CHANGED