ccxt 4.2.80 → 4.2.82
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 +90 -0
- package/README.md +3 -3
- package/dist/ccxt.browser.js +764 -48
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +90 -0
- package/dist/cjs/src/bybit.js +177 -0
- package/dist/cjs/src/delta.js +147 -0
- package/dist/cjs/src/deribit.js +1 -1
- package/dist/cjs/src/gate.js +186 -0
- package/dist/cjs/src/hyperliquid.js +4 -4
- package/dist/cjs/src/okx.js +158 -42
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/binance.d.ts +21 -1
- package/js/src/binance.js +90 -0
- package/js/src/bybit.d.ts +22 -1
- package/js/src/bybit.js +177 -0
- package/js/src/delta.d.ts +21 -1
- package/js/src/delta.js +147 -0
- package/js/src/deribit.d.ts +1 -1
- package/js/src/deribit.js +1 -1
- package/js/src/gate.d.ts +22 -1
- package/js/src/gate.js +186 -0
- package/js/src/hyperliquid.js +4 -4
- package/js/src/okx.d.ts +22 -2
- package/js/src/okx.js +158 -42
- package/package.json +1 -1
package/dist/cjs/src/gate.js
CHANGED
|
@@ -132,6 +132,8 @@ class gate extends gate$1 {
|
|
|
132
132
|
'fetchOpenInterest': false,
|
|
133
133
|
'fetchOpenInterestHistory': true,
|
|
134
134
|
'fetchOpenOrders': true,
|
|
135
|
+
'fetchOption': true,
|
|
136
|
+
'fetchOptionChain': true,
|
|
135
137
|
'fetchOrder': true,
|
|
136
138
|
'fetchOrderBook': true,
|
|
137
139
|
'fetchPosition': true,
|
|
@@ -7202,6 +7204,190 @@ class gate extends gate$1 {
|
|
|
7202
7204
|
'shortLeverage': leverageValue,
|
|
7203
7205
|
};
|
|
7204
7206
|
}
|
|
7207
|
+
async fetchOption(symbol, params = {}) {
|
|
7208
|
+
/**
|
|
7209
|
+
* @method
|
|
7210
|
+
* @name gate#fetchOption
|
|
7211
|
+
* @description fetches option data that is commonly found in an option chain
|
|
7212
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#query-specified-contract-detail
|
|
7213
|
+
* @param {string} symbol unified market symbol
|
|
7214
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7215
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7216
|
+
*/
|
|
7217
|
+
await this.loadMarkets();
|
|
7218
|
+
const market = this.market(symbol);
|
|
7219
|
+
const request = {
|
|
7220
|
+
'contract': market['id'],
|
|
7221
|
+
};
|
|
7222
|
+
const response = await this.publicOptionsGetContractsContract(this.extend(request, params));
|
|
7223
|
+
//
|
|
7224
|
+
// {
|
|
7225
|
+
// "is_active": true,
|
|
7226
|
+
// "mark_price_round": "0.01",
|
|
7227
|
+
// "settle_fee_rate": "0.00015",
|
|
7228
|
+
// "bid1_size": 30,
|
|
7229
|
+
// "taker_fee_rate": "0.0003",
|
|
7230
|
+
// "price_limit_fee_rate": "0.1",
|
|
7231
|
+
// "order_price_round": "0.1",
|
|
7232
|
+
// "tag": "month",
|
|
7233
|
+
// "ref_rebate_rate": "0",
|
|
7234
|
+
// "name": "ETH_USDT-20240628-4500-C",
|
|
7235
|
+
// "strike_price": "4500",
|
|
7236
|
+
// "ask1_price": "280.5",
|
|
7237
|
+
// "ref_discount_rate": "0",
|
|
7238
|
+
// "order_price_deviate": "0.2",
|
|
7239
|
+
// "ask1_size": -19,
|
|
7240
|
+
// "mark_price_down": "155.45",
|
|
7241
|
+
// "orderbook_id": 11724695,
|
|
7242
|
+
// "is_call": true,
|
|
7243
|
+
// "last_price": "188.7",
|
|
7244
|
+
// "mark_price": "274.26",
|
|
7245
|
+
// "underlying": "ETH_USDT",
|
|
7246
|
+
// "create_time": 1688024882,
|
|
7247
|
+
// "settle_limit_fee_rate": "0.1",
|
|
7248
|
+
// "orders_limit": 10,
|
|
7249
|
+
// "mark_price_up": "403.83",
|
|
7250
|
+
// "position_size": 80,
|
|
7251
|
+
// "order_size_max": 10000,
|
|
7252
|
+
// "position_limit": 100000,
|
|
7253
|
+
// "multiplier": "0.01",
|
|
7254
|
+
// "order_size_min": 1,
|
|
7255
|
+
// "trade_size": 229,
|
|
7256
|
+
// "underlying_price": "3326.6",
|
|
7257
|
+
// "maker_fee_rate": "0.0003",
|
|
7258
|
+
// "expiration_time": 1719561600,
|
|
7259
|
+
// "trade_id": 15,
|
|
7260
|
+
// "bid1_price": "269.3"
|
|
7261
|
+
// }
|
|
7262
|
+
//
|
|
7263
|
+
return this.parseOption(response, undefined, market);
|
|
7264
|
+
}
|
|
7265
|
+
async fetchOptionChain(code, params = {}) {
|
|
7266
|
+
/**
|
|
7267
|
+
* @method
|
|
7268
|
+
* @name gate#fetchOptionChain
|
|
7269
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
7270
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
|
|
7271
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
7272
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7273
|
+
* @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
|
|
7274
|
+
* @param {int} [params.expiration] unix timestamp of the expiration time
|
|
7275
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7276
|
+
*/
|
|
7277
|
+
await this.loadMarkets();
|
|
7278
|
+
const currency = this.currency(code);
|
|
7279
|
+
const request = {
|
|
7280
|
+
'underlying': currency['code'] + '_USDT',
|
|
7281
|
+
};
|
|
7282
|
+
const response = await this.publicOptionsGetContracts(this.extend(request, params));
|
|
7283
|
+
//
|
|
7284
|
+
// [
|
|
7285
|
+
// {
|
|
7286
|
+
// "is_active": true,
|
|
7287
|
+
// "mark_price_round": "0.1",
|
|
7288
|
+
// "settle_fee_rate": "0.00015",
|
|
7289
|
+
// "bid1_size": 434,
|
|
7290
|
+
// "taker_fee_rate": "0.0003",
|
|
7291
|
+
// "price_limit_fee_rate": "0.1",
|
|
7292
|
+
// "order_price_round": "1",
|
|
7293
|
+
// "tag": "day",
|
|
7294
|
+
// "ref_rebate_rate": "0",
|
|
7295
|
+
// "name": "BTC_USDT-20240324-63500-P",
|
|
7296
|
+
// "strike_price": "63500",
|
|
7297
|
+
// "ask1_price": "387",
|
|
7298
|
+
// "ref_discount_rate": "0",
|
|
7299
|
+
// "order_price_deviate": "0.15",
|
|
7300
|
+
// "ask1_size": -454,
|
|
7301
|
+
// "mark_price_down": "124.3",
|
|
7302
|
+
// "orderbook_id": 29600,
|
|
7303
|
+
// "is_call": false,
|
|
7304
|
+
// "last_price": "0",
|
|
7305
|
+
// "mark_price": "366.6",
|
|
7306
|
+
// "underlying": "BTC_USDT",
|
|
7307
|
+
// "create_time": 1711118829,
|
|
7308
|
+
// "settle_limit_fee_rate": "0.1",
|
|
7309
|
+
// "orders_limit": 10,
|
|
7310
|
+
// "mark_price_up": "630",
|
|
7311
|
+
// "position_size": 0,
|
|
7312
|
+
// "order_size_max": 10000,
|
|
7313
|
+
// "position_limit": 10000,
|
|
7314
|
+
// "multiplier": "0.01",
|
|
7315
|
+
// "order_size_min": 1,
|
|
7316
|
+
// "trade_size": 0,
|
|
7317
|
+
// "underlying_price": "64084.65",
|
|
7318
|
+
// "maker_fee_rate": "0.0003",
|
|
7319
|
+
// "expiration_time": 1711267200,
|
|
7320
|
+
// "trade_id": 0,
|
|
7321
|
+
// "bid1_price": "307"
|
|
7322
|
+
// },
|
|
7323
|
+
// ]
|
|
7324
|
+
//
|
|
7325
|
+
return this.parseOptionChain(response, undefined, 'name');
|
|
7326
|
+
}
|
|
7327
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
7328
|
+
//
|
|
7329
|
+
// {
|
|
7330
|
+
// "is_active": true,
|
|
7331
|
+
// "mark_price_round": "0.1",
|
|
7332
|
+
// "settle_fee_rate": "0.00015",
|
|
7333
|
+
// "bid1_size": 434,
|
|
7334
|
+
// "taker_fee_rate": "0.0003",
|
|
7335
|
+
// "price_limit_fee_rate": "0.1",
|
|
7336
|
+
// "order_price_round": "1",
|
|
7337
|
+
// "tag": "day",
|
|
7338
|
+
// "ref_rebate_rate": "0",
|
|
7339
|
+
// "name": "BTC_USDT-20240324-63500-P",
|
|
7340
|
+
// "strike_price": "63500",
|
|
7341
|
+
// "ask1_price": "387",
|
|
7342
|
+
// "ref_discount_rate": "0",
|
|
7343
|
+
// "order_price_deviate": "0.15",
|
|
7344
|
+
// "ask1_size": -454,
|
|
7345
|
+
// "mark_price_down": "124.3",
|
|
7346
|
+
// "orderbook_id": 29600,
|
|
7347
|
+
// "is_call": false,
|
|
7348
|
+
// "last_price": "0",
|
|
7349
|
+
// "mark_price": "366.6",
|
|
7350
|
+
// "underlying": "BTC_USDT",
|
|
7351
|
+
// "create_time": 1711118829,
|
|
7352
|
+
// "settle_limit_fee_rate": "0.1",
|
|
7353
|
+
// "orders_limit": 10,
|
|
7354
|
+
// "mark_price_up": "630",
|
|
7355
|
+
// "position_size": 0,
|
|
7356
|
+
// "order_size_max": 10000,
|
|
7357
|
+
// "position_limit": 10000,
|
|
7358
|
+
// "multiplier": "0.01",
|
|
7359
|
+
// "order_size_min": 1,
|
|
7360
|
+
// "trade_size": 0,
|
|
7361
|
+
// "underlying_price": "64084.65",
|
|
7362
|
+
// "maker_fee_rate": "0.0003",
|
|
7363
|
+
// "expiration_time": 1711267200,
|
|
7364
|
+
// "trade_id": 0,
|
|
7365
|
+
// "bid1_price": "307"
|
|
7366
|
+
// }
|
|
7367
|
+
//
|
|
7368
|
+
const marketId = this.safeString(chain, 'name');
|
|
7369
|
+
market = this.safeMarket(marketId, market);
|
|
7370
|
+
const timestamp = this.safeTimestamp(chain, 'create_time');
|
|
7371
|
+
return {
|
|
7372
|
+
'info': chain,
|
|
7373
|
+
'currency': undefined,
|
|
7374
|
+
'symbol': market['symbol'],
|
|
7375
|
+
'timestamp': timestamp,
|
|
7376
|
+
'datetime': this.iso8601(timestamp),
|
|
7377
|
+
'impliedVolatility': undefined,
|
|
7378
|
+
'openInterest': undefined,
|
|
7379
|
+
'bidPrice': this.safeNumber(chain, 'bid1_price'),
|
|
7380
|
+
'askPrice': this.safeNumber(chain, 'ask1_price'),
|
|
7381
|
+
'midPrice': undefined,
|
|
7382
|
+
'markPrice': this.safeNumber(chain, 'mark_price'),
|
|
7383
|
+
'lastPrice': this.safeNumber(chain, 'last_price'),
|
|
7384
|
+
'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
|
|
7385
|
+
'change': undefined,
|
|
7386
|
+
'percentage': undefined,
|
|
7387
|
+
'baseVolume': undefined,
|
|
7388
|
+
'quoteVolume': undefined,
|
|
7389
|
+
};
|
|
7390
|
+
}
|
|
7205
7391
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7206
7392
|
if (response === undefined) {
|
|
7207
7393
|
return undefined;
|
|
@@ -44,7 +44,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
44
44
|
'createMarketSellOrderWithCost': false,
|
|
45
45
|
'createOrder': true,
|
|
46
46
|
'createOrders': true,
|
|
47
|
-
'createReduceOnlyOrder':
|
|
47
|
+
'createReduceOnlyOrder': true,
|
|
48
48
|
'editOrder': true,
|
|
49
49
|
'fetchAccounts': false,
|
|
50
50
|
'fetchBalance': true,
|
|
@@ -881,7 +881,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
881
881
|
'tif': timeInForce,
|
|
882
882
|
};
|
|
883
883
|
}
|
|
884
|
-
orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id']);
|
|
884
|
+
orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly']);
|
|
885
885
|
const orderObj = {
|
|
886
886
|
'a': this.parseToInt(market['baseId']),
|
|
887
887
|
'b': isBuy,
|
|
@@ -2034,10 +2034,10 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2034
2034
|
[userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
|
|
2035
2035
|
let user = userAux;
|
|
2036
2036
|
[user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux);
|
|
2037
|
-
if (user !== undefined) {
|
|
2037
|
+
if ((user !== undefined) && (user !== '')) {
|
|
2038
2038
|
return [user, params];
|
|
2039
2039
|
}
|
|
2040
|
-
if (this.walletAddress !== undefined) {
|
|
2040
|
+
if ((this.walletAddress !== undefined) && (this.walletAddress !== '')) {
|
|
2041
2041
|
return [this.walletAddress, params];
|
|
2042
2042
|
}
|
|
2043
2043
|
throw new errors.ArgumentsRequired(this.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set');
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -94,6 +94,8 @@ class okx extends okx$1 {
|
|
|
94
94
|
'fetchOpenInterestHistory': true,
|
|
95
95
|
'fetchOpenOrder': undefined,
|
|
96
96
|
'fetchOpenOrders': true,
|
|
97
|
+
'fetchOption': true,
|
|
98
|
+
'fetchOptionChain': true,
|
|
97
99
|
'fetchOrder': true,
|
|
98
100
|
'fetchOrderBook': true,
|
|
99
101
|
'fetchOrderBooks': false,
|
|
@@ -1855,16 +1857,29 @@ class okx extends okx$1 {
|
|
|
1855
1857
|
const first = this.safeValue(data, 0, {});
|
|
1856
1858
|
return this.parseTicker(first, market);
|
|
1857
1859
|
}
|
|
1858
|
-
async
|
|
1860
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
1861
|
+
/**
|
|
1862
|
+
* @method
|
|
1863
|
+
* @name okx#fetchTickers
|
|
1864
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1865
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
1866
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1867
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1868
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1869
|
+
*/
|
|
1859
1870
|
await this.loadMarkets();
|
|
1871
|
+
symbols = this.marketSymbols(symbols);
|
|
1872
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1873
|
+
let marketType = undefined;
|
|
1874
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1860
1875
|
const request = {
|
|
1861
|
-
'instType': this.convertToInstrumentType(
|
|
1876
|
+
'instType': this.convertToInstrumentType(marketType),
|
|
1862
1877
|
};
|
|
1863
|
-
if (
|
|
1878
|
+
if (marketType === 'option') {
|
|
1864
1879
|
const defaultUnderlying = this.safeValue(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
1865
1880
|
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
1866
1881
|
if (currencyId === undefined) {
|
|
1867
|
-
throw new errors.ArgumentsRequired(this.id + '
|
|
1882
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
1868
1883
|
}
|
|
1869
1884
|
else {
|
|
1870
1885
|
request['uly'] = currencyId;
|
|
@@ -1897,29 +1912,9 @@ class okx extends okx$1 {
|
|
|
1897
1912
|
// ]
|
|
1898
1913
|
// }
|
|
1899
1914
|
//
|
|
1900
|
-
const tickers = this.
|
|
1915
|
+
const tickers = this.safeList(response, 'data', []);
|
|
1901
1916
|
return this.parseTickers(tickers, symbols);
|
|
1902
1917
|
}
|
|
1903
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
1904
|
-
/**
|
|
1905
|
-
* @method
|
|
1906
|
-
* @name okx#fetchTickers
|
|
1907
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1908
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
1909
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1910
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1911
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1912
|
-
*/
|
|
1913
|
-
await this.loadMarkets();
|
|
1914
|
-
symbols = this.marketSymbols(symbols);
|
|
1915
|
-
const first = this.safeString(symbols, 0);
|
|
1916
|
-
let market = undefined;
|
|
1917
|
-
if (first !== undefined) {
|
|
1918
|
-
market = this.market(first);
|
|
1919
|
-
}
|
|
1920
|
-
const [type, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1921
|
-
return await this.fetchTickersByType(type, symbols, query);
|
|
1922
|
-
}
|
|
1923
1918
|
parseTrade(trade, market = undefined) {
|
|
1924
1919
|
//
|
|
1925
1920
|
// public fetchTrades
|
|
@@ -4737,23 +4732,7 @@ class okx extends okx$1 {
|
|
|
4737
4732
|
}
|
|
4738
4733
|
}
|
|
4739
4734
|
request['fee'] = this.numberToString(fee); // withdrawals to OKCoin or OKX are fee-free, please set 0
|
|
4740
|
-
|
|
4741
|
-
request['pwd'] = params['password'];
|
|
4742
|
-
}
|
|
4743
|
-
else if ('pwd' in params) {
|
|
4744
|
-
request['pwd'] = params['pwd'];
|
|
4745
|
-
}
|
|
4746
|
-
else {
|
|
4747
|
-
const options = this.safeValue(this.options, 'withdraw', {});
|
|
4748
|
-
const password = this.safeString2(options, 'password', 'pwd');
|
|
4749
|
-
if (password !== undefined) {
|
|
4750
|
-
request['pwd'] = password;
|
|
4751
|
-
}
|
|
4752
|
-
}
|
|
4753
|
-
const query = this.omit(params, ['fee', 'password', 'pwd']);
|
|
4754
|
-
if (!('pwd' in request)) {
|
|
4755
|
-
throw new errors.ExchangeError(this.id + ' withdraw() requires a password parameter or a pwd parameter, it must be the funding password, not the API passphrase');
|
|
4756
|
-
}
|
|
4735
|
+
const query = this.omit(params, ['fee']);
|
|
4757
4736
|
const response = await this.privatePostAssetWithdrawal(this.extend(request, query));
|
|
4758
4737
|
//
|
|
4759
4738
|
// {
|
|
@@ -7433,6 +7412,143 @@ class okx extends okx$1 {
|
|
|
7433
7412
|
const order = this.safeValue(data, 0);
|
|
7434
7413
|
return this.parseOrder(order, market);
|
|
7435
7414
|
}
|
|
7415
|
+
async fetchOption(symbol, params = {}) {
|
|
7416
|
+
/**
|
|
7417
|
+
* @method
|
|
7418
|
+
* @name okx#fetchOption
|
|
7419
|
+
* @description fetches option data that is commonly found in an option chain
|
|
7420
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker
|
|
7421
|
+
* @param {string} symbol unified market symbol
|
|
7422
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7423
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7424
|
+
*/
|
|
7425
|
+
await this.loadMarkets();
|
|
7426
|
+
const market = this.market(symbol);
|
|
7427
|
+
const request = {
|
|
7428
|
+
'instId': market['id'],
|
|
7429
|
+
};
|
|
7430
|
+
const response = await this.publicGetMarketTicker(this.extend(request, params));
|
|
7431
|
+
//
|
|
7432
|
+
// {
|
|
7433
|
+
// "code": "0",
|
|
7434
|
+
// "msg": "",
|
|
7435
|
+
// "data": [
|
|
7436
|
+
// {
|
|
7437
|
+
// "instType": "OPTION",
|
|
7438
|
+
// "instId": "BTC-USD-241227-60000-P",
|
|
7439
|
+
// "last": "",
|
|
7440
|
+
// "lastSz": "0",
|
|
7441
|
+
// "askPx": "",
|
|
7442
|
+
// "askSz": "0",
|
|
7443
|
+
// "bidPx": "",
|
|
7444
|
+
// "bidSz": "0",
|
|
7445
|
+
// "open24h": "",
|
|
7446
|
+
// "high24h": "",
|
|
7447
|
+
// "low24h": "",
|
|
7448
|
+
// "volCcy24h": "0",
|
|
7449
|
+
// "vol24h": "0",
|
|
7450
|
+
// "ts": "1711176035035",
|
|
7451
|
+
// "sodUtc0": "",
|
|
7452
|
+
// "sodUtc8": ""
|
|
7453
|
+
// }
|
|
7454
|
+
// ]
|
|
7455
|
+
// }
|
|
7456
|
+
//
|
|
7457
|
+
const result = this.safeList(response, 'data', []);
|
|
7458
|
+
const chain = this.safeDict(result, 0, {});
|
|
7459
|
+
return this.parseOption(chain, undefined, market);
|
|
7460
|
+
}
|
|
7461
|
+
async fetchOptionChain(code, params = {}) {
|
|
7462
|
+
/**
|
|
7463
|
+
* @method
|
|
7464
|
+
* @name okx#fetchOptionChain
|
|
7465
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
7466
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
7467
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
7468
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7469
|
+
* @param {string} [params.uly] the underlying asset, can be obtained from fetchUnderlyingAssets ()
|
|
7470
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7471
|
+
*/
|
|
7472
|
+
await this.loadMarkets();
|
|
7473
|
+
const currency = this.currency(code);
|
|
7474
|
+
const request = {
|
|
7475
|
+
'uly': currency['code'] + '-USD',
|
|
7476
|
+
'instType': 'OPTION',
|
|
7477
|
+
};
|
|
7478
|
+
const response = await this.publicGetMarketTickers(this.extend(request, params));
|
|
7479
|
+
//
|
|
7480
|
+
// {
|
|
7481
|
+
// "code": "0",
|
|
7482
|
+
// "msg": "",
|
|
7483
|
+
// "data": [
|
|
7484
|
+
// {
|
|
7485
|
+
// "instType": "OPTION",
|
|
7486
|
+
// "instId": "BTC-USD-240323-52000-C",
|
|
7487
|
+
// "last": "",
|
|
7488
|
+
// "lastSz": "0",
|
|
7489
|
+
// "askPx": "",
|
|
7490
|
+
// "askSz": "0",
|
|
7491
|
+
// "bidPx": "",
|
|
7492
|
+
// "bidSz": "0",
|
|
7493
|
+
// "open24h": "",
|
|
7494
|
+
// "high24h": "",
|
|
7495
|
+
// "low24h": "",
|
|
7496
|
+
// "volCcy24h": "0",
|
|
7497
|
+
// "vol24h": "0",
|
|
7498
|
+
// "ts": "1711176207008",
|
|
7499
|
+
// "sodUtc0": "",
|
|
7500
|
+
// "sodUtc8": ""
|
|
7501
|
+
// },
|
|
7502
|
+
// ]
|
|
7503
|
+
// }
|
|
7504
|
+
//
|
|
7505
|
+
const result = this.safeList(response, 'data', []);
|
|
7506
|
+
return this.parseOptionChain(result, undefined, 'instId');
|
|
7507
|
+
}
|
|
7508
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
7509
|
+
//
|
|
7510
|
+
// {
|
|
7511
|
+
// "instType": "OPTION",
|
|
7512
|
+
// "instId": "BTC-USD-241227-60000-P",
|
|
7513
|
+
// "last": "",
|
|
7514
|
+
// "lastSz": "0",
|
|
7515
|
+
// "askPx": "",
|
|
7516
|
+
// "askSz": "0",
|
|
7517
|
+
// "bidPx": "",
|
|
7518
|
+
// "bidSz": "0",
|
|
7519
|
+
// "open24h": "",
|
|
7520
|
+
// "high24h": "",
|
|
7521
|
+
// "low24h": "",
|
|
7522
|
+
// "volCcy24h": "0",
|
|
7523
|
+
// "vol24h": "0",
|
|
7524
|
+
// "ts": "1711176035035",
|
|
7525
|
+
// "sodUtc0": "",
|
|
7526
|
+
// "sodUtc8": ""
|
|
7527
|
+
// }
|
|
7528
|
+
//
|
|
7529
|
+
const marketId = this.safeString(chain, 'instId');
|
|
7530
|
+
market = this.safeMarket(marketId, market);
|
|
7531
|
+
const timestamp = this.safeInteger(chain, 'ts');
|
|
7532
|
+
return {
|
|
7533
|
+
'info': chain,
|
|
7534
|
+
'currency': undefined,
|
|
7535
|
+
'symbol': market['symbol'],
|
|
7536
|
+
'timestamp': timestamp,
|
|
7537
|
+
'datetime': this.iso8601(timestamp),
|
|
7538
|
+
'impliedVolatility': undefined,
|
|
7539
|
+
'openInterest': undefined,
|
|
7540
|
+
'bidPrice': this.safeNumber(chain, 'bidPx'),
|
|
7541
|
+
'askPrice': this.safeNumber(chain, 'askPx'),
|
|
7542
|
+
'midPrice': undefined,
|
|
7543
|
+
'markPrice': undefined,
|
|
7544
|
+
'lastPrice': this.safeNumber(chain, 'last'),
|
|
7545
|
+
'underlyingPrice': undefined,
|
|
7546
|
+
'change': undefined,
|
|
7547
|
+
'percentage': undefined,
|
|
7548
|
+
'baseVolume': this.safeNumber(chain, 'volCcy24h'),
|
|
7549
|
+
'quoteVolume': undefined,
|
|
7550
|
+
};
|
|
7551
|
+
}
|
|
7436
7552
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7437
7553
|
if (!response) {
|
|
7438
7554
|
return undefined; // fallback to default error handler
|
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, Leverage, Leverages, Option, OptionChain } 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.2.
|
|
7
|
+
declare const version = "4.2.81";
|
|
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.2.
|
|
41
|
+
const version = '4.2.82';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/binance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/binance.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @augments Exchange
|
|
@@ -436,4 +436,24 @@ export default class binance extends Exchange {
|
|
|
436
436
|
}>;
|
|
437
437
|
fetchMarginModes(symbols?: string[], params?: {}): Promise<MarginModes>;
|
|
438
438
|
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
439
|
+
fetchOption(symbol: string, params?: {}): Promise<Option>;
|
|
440
|
+
parseOption(chain: any, currency?: Currency, market?: Market): {
|
|
441
|
+
info: any;
|
|
442
|
+
currency: any;
|
|
443
|
+
symbol: string;
|
|
444
|
+
timestamp: any;
|
|
445
|
+
datetime: any;
|
|
446
|
+
impliedVolatility: any;
|
|
447
|
+
openInterest: any;
|
|
448
|
+
bidPrice: number;
|
|
449
|
+
askPrice: number;
|
|
450
|
+
midPrice: any;
|
|
451
|
+
markPrice: any;
|
|
452
|
+
lastPrice: number;
|
|
453
|
+
underlyingPrice: number;
|
|
454
|
+
change: number;
|
|
455
|
+
percentage: number;
|
|
456
|
+
baseVolume: number;
|
|
457
|
+
quoteVolume: any;
|
|
458
|
+
};
|
|
439
459
|
}
|
package/js/src/binance.js
CHANGED
|
@@ -114,6 +114,8 @@ export default class binance extends Exchange {
|
|
|
114
114
|
'fetchOpenInterestHistory': true,
|
|
115
115
|
'fetchOpenOrder': true,
|
|
116
116
|
'fetchOpenOrders': true,
|
|
117
|
+
'fetchOption': true,
|
|
118
|
+
'fetchOptionChain': false,
|
|
117
119
|
'fetchOrder': true,
|
|
118
120
|
'fetchOrderBook': true,
|
|
119
121
|
'fetchOrderBooks': false,
|
|
@@ -12411,4 +12413,92 @@ export default class binance extends Exchange {
|
|
|
12411
12413
|
'marginMode': isIsolated ? 'isolated' : 'cross',
|
|
12412
12414
|
};
|
|
12413
12415
|
}
|
|
12416
|
+
async fetchOption(symbol, params = {}) {
|
|
12417
|
+
/**
|
|
12418
|
+
* @method
|
|
12419
|
+
* @name binance#fetchOption
|
|
12420
|
+
* @description fetches option data that is commonly found in an option chain
|
|
12421
|
+
* @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics
|
|
12422
|
+
* @param {string} symbol unified market symbol
|
|
12423
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
12424
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
12425
|
+
*/
|
|
12426
|
+
await this.loadMarkets();
|
|
12427
|
+
const market = this.market(symbol);
|
|
12428
|
+
const request = {
|
|
12429
|
+
'symbol': market['id'],
|
|
12430
|
+
};
|
|
12431
|
+
const response = await this.eapiPublicGetTicker(this.extend(request, params));
|
|
12432
|
+
//
|
|
12433
|
+
// [
|
|
12434
|
+
// {
|
|
12435
|
+
// "symbol": "BTC-241227-80000-C",
|
|
12436
|
+
// "priceChange": "0",
|
|
12437
|
+
// "priceChangePercent": "0",
|
|
12438
|
+
// "lastPrice": "2750",
|
|
12439
|
+
// "lastQty": "0",
|
|
12440
|
+
// "open": "2750",
|
|
12441
|
+
// "high": "2750",
|
|
12442
|
+
// "low": "2750",
|
|
12443
|
+
// "volume": "0",
|
|
12444
|
+
// "amount": "0",
|
|
12445
|
+
// "bidPrice": "4880",
|
|
12446
|
+
// "askPrice": "0",
|
|
12447
|
+
// "openTime": 0,
|
|
12448
|
+
// "closeTime": 0,
|
|
12449
|
+
// "firstTradeId": 0,
|
|
12450
|
+
// "tradeCount": 0,
|
|
12451
|
+
// "strikePrice": "80000",
|
|
12452
|
+
// "exercisePrice": "63944.09893617"
|
|
12453
|
+
// }
|
|
12454
|
+
// ]
|
|
12455
|
+
//
|
|
12456
|
+
const chain = this.safeDict(response, 0, {});
|
|
12457
|
+
return this.parseOption(chain, undefined, market);
|
|
12458
|
+
}
|
|
12459
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
12460
|
+
//
|
|
12461
|
+
// {
|
|
12462
|
+
// "symbol": "BTC-241227-80000-C",
|
|
12463
|
+
// "priceChange": "0",
|
|
12464
|
+
// "priceChangePercent": "0",
|
|
12465
|
+
// "lastPrice": "2750",
|
|
12466
|
+
// "lastQty": "0",
|
|
12467
|
+
// "open": "2750",
|
|
12468
|
+
// "high": "2750",
|
|
12469
|
+
// "low": "2750",
|
|
12470
|
+
// "volume": "0",
|
|
12471
|
+
// "amount": "0",
|
|
12472
|
+
// "bidPrice": "4880",
|
|
12473
|
+
// "askPrice": "0",
|
|
12474
|
+
// "openTime": 0,
|
|
12475
|
+
// "closeTime": 0,
|
|
12476
|
+
// "firstTradeId": 0,
|
|
12477
|
+
// "tradeCount": 0,
|
|
12478
|
+
// "strikePrice": "80000",
|
|
12479
|
+
// "exercisePrice": "63944.09893617"
|
|
12480
|
+
// }
|
|
12481
|
+
//
|
|
12482
|
+
const marketId = this.safeString(chain, 'symbol');
|
|
12483
|
+
market = this.safeMarket(marketId, market);
|
|
12484
|
+
return {
|
|
12485
|
+
'info': chain,
|
|
12486
|
+
'currency': undefined,
|
|
12487
|
+
'symbol': market['symbol'],
|
|
12488
|
+
'timestamp': undefined,
|
|
12489
|
+
'datetime': undefined,
|
|
12490
|
+
'impliedVolatility': undefined,
|
|
12491
|
+
'openInterest': undefined,
|
|
12492
|
+
'bidPrice': this.safeNumber(chain, 'bidPrice'),
|
|
12493
|
+
'askPrice': this.safeNumber(chain, 'askPrice'),
|
|
12494
|
+
'midPrice': undefined,
|
|
12495
|
+
'markPrice': undefined,
|
|
12496
|
+
'lastPrice': this.safeNumber(chain, 'lastPrice'),
|
|
12497
|
+
'underlyingPrice': this.safeNumber(chain, 'exercisePrice'),
|
|
12498
|
+
'change': this.safeNumber(chain, 'priceChange'),
|
|
12499
|
+
'percentage': this.safeNumber(chain, 'priceChangePercent'),
|
|
12500
|
+
'baseVolume': this.safeNumber(chain, 'volume'),
|
|
12501
|
+
'quoteVolume': undefined,
|
|
12502
|
+
};
|
|
12503
|
+
}
|
|
12414
12504
|
}
|