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/js/src/gate.js
CHANGED
|
@@ -135,6 +135,8 @@ export default class gate extends Exchange {
|
|
|
135
135
|
'fetchOpenInterest': false,
|
|
136
136
|
'fetchOpenInterestHistory': true,
|
|
137
137
|
'fetchOpenOrders': true,
|
|
138
|
+
'fetchOption': true,
|
|
139
|
+
'fetchOptionChain': true,
|
|
138
140
|
'fetchOrder': true,
|
|
139
141
|
'fetchOrderBook': true,
|
|
140
142
|
'fetchPosition': true,
|
|
@@ -7205,6 +7207,190 @@ export default class gate extends Exchange {
|
|
|
7205
7207
|
'shortLeverage': leverageValue,
|
|
7206
7208
|
};
|
|
7207
7209
|
}
|
|
7210
|
+
async fetchOption(symbol, params = {}) {
|
|
7211
|
+
/**
|
|
7212
|
+
* @method
|
|
7213
|
+
* @name gate#fetchOption
|
|
7214
|
+
* @description fetches option data that is commonly found in an option chain
|
|
7215
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#query-specified-contract-detail
|
|
7216
|
+
* @param {string} symbol unified market symbol
|
|
7217
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7218
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7219
|
+
*/
|
|
7220
|
+
await this.loadMarkets();
|
|
7221
|
+
const market = this.market(symbol);
|
|
7222
|
+
const request = {
|
|
7223
|
+
'contract': market['id'],
|
|
7224
|
+
};
|
|
7225
|
+
const response = await this.publicOptionsGetContractsContract(this.extend(request, params));
|
|
7226
|
+
//
|
|
7227
|
+
// {
|
|
7228
|
+
// "is_active": true,
|
|
7229
|
+
// "mark_price_round": "0.01",
|
|
7230
|
+
// "settle_fee_rate": "0.00015",
|
|
7231
|
+
// "bid1_size": 30,
|
|
7232
|
+
// "taker_fee_rate": "0.0003",
|
|
7233
|
+
// "price_limit_fee_rate": "0.1",
|
|
7234
|
+
// "order_price_round": "0.1",
|
|
7235
|
+
// "tag": "month",
|
|
7236
|
+
// "ref_rebate_rate": "0",
|
|
7237
|
+
// "name": "ETH_USDT-20240628-4500-C",
|
|
7238
|
+
// "strike_price": "4500",
|
|
7239
|
+
// "ask1_price": "280.5",
|
|
7240
|
+
// "ref_discount_rate": "0",
|
|
7241
|
+
// "order_price_deviate": "0.2",
|
|
7242
|
+
// "ask1_size": -19,
|
|
7243
|
+
// "mark_price_down": "155.45",
|
|
7244
|
+
// "orderbook_id": 11724695,
|
|
7245
|
+
// "is_call": true,
|
|
7246
|
+
// "last_price": "188.7",
|
|
7247
|
+
// "mark_price": "274.26",
|
|
7248
|
+
// "underlying": "ETH_USDT",
|
|
7249
|
+
// "create_time": 1688024882,
|
|
7250
|
+
// "settle_limit_fee_rate": "0.1",
|
|
7251
|
+
// "orders_limit": 10,
|
|
7252
|
+
// "mark_price_up": "403.83",
|
|
7253
|
+
// "position_size": 80,
|
|
7254
|
+
// "order_size_max": 10000,
|
|
7255
|
+
// "position_limit": 100000,
|
|
7256
|
+
// "multiplier": "0.01",
|
|
7257
|
+
// "order_size_min": 1,
|
|
7258
|
+
// "trade_size": 229,
|
|
7259
|
+
// "underlying_price": "3326.6",
|
|
7260
|
+
// "maker_fee_rate": "0.0003",
|
|
7261
|
+
// "expiration_time": 1719561600,
|
|
7262
|
+
// "trade_id": 15,
|
|
7263
|
+
// "bid1_price": "269.3"
|
|
7264
|
+
// }
|
|
7265
|
+
//
|
|
7266
|
+
return this.parseOption(response, undefined, market);
|
|
7267
|
+
}
|
|
7268
|
+
async fetchOptionChain(code, params = {}) {
|
|
7269
|
+
/**
|
|
7270
|
+
* @method
|
|
7271
|
+
* @name gate#fetchOptionChain
|
|
7272
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
7273
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
|
|
7274
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
7275
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7276
|
+
* @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
|
|
7277
|
+
* @param {int} [params.expiration] unix timestamp of the expiration time
|
|
7278
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7279
|
+
*/
|
|
7280
|
+
await this.loadMarkets();
|
|
7281
|
+
const currency = this.currency(code);
|
|
7282
|
+
const request = {
|
|
7283
|
+
'underlying': currency['code'] + '_USDT',
|
|
7284
|
+
};
|
|
7285
|
+
const response = await this.publicOptionsGetContracts(this.extend(request, params));
|
|
7286
|
+
//
|
|
7287
|
+
// [
|
|
7288
|
+
// {
|
|
7289
|
+
// "is_active": true,
|
|
7290
|
+
// "mark_price_round": "0.1",
|
|
7291
|
+
// "settle_fee_rate": "0.00015",
|
|
7292
|
+
// "bid1_size": 434,
|
|
7293
|
+
// "taker_fee_rate": "0.0003",
|
|
7294
|
+
// "price_limit_fee_rate": "0.1",
|
|
7295
|
+
// "order_price_round": "1",
|
|
7296
|
+
// "tag": "day",
|
|
7297
|
+
// "ref_rebate_rate": "0",
|
|
7298
|
+
// "name": "BTC_USDT-20240324-63500-P",
|
|
7299
|
+
// "strike_price": "63500",
|
|
7300
|
+
// "ask1_price": "387",
|
|
7301
|
+
// "ref_discount_rate": "0",
|
|
7302
|
+
// "order_price_deviate": "0.15",
|
|
7303
|
+
// "ask1_size": -454,
|
|
7304
|
+
// "mark_price_down": "124.3",
|
|
7305
|
+
// "orderbook_id": 29600,
|
|
7306
|
+
// "is_call": false,
|
|
7307
|
+
// "last_price": "0",
|
|
7308
|
+
// "mark_price": "366.6",
|
|
7309
|
+
// "underlying": "BTC_USDT",
|
|
7310
|
+
// "create_time": 1711118829,
|
|
7311
|
+
// "settle_limit_fee_rate": "0.1",
|
|
7312
|
+
// "orders_limit": 10,
|
|
7313
|
+
// "mark_price_up": "630",
|
|
7314
|
+
// "position_size": 0,
|
|
7315
|
+
// "order_size_max": 10000,
|
|
7316
|
+
// "position_limit": 10000,
|
|
7317
|
+
// "multiplier": "0.01",
|
|
7318
|
+
// "order_size_min": 1,
|
|
7319
|
+
// "trade_size": 0,
|
|
7320
|
+
// "underlying_price": "64084.65",
|
|
7321
|
+
// "maker_fee_rate": "0.0003",
|
|
7322
|
+
// "expiration_time": 1711267200,
|
|
7323
|
+
// "trade_id": 0,
|
|
7324
|
+
// "bid1_price": "307"
|
|
7325
|
+
// },
|
|
7326
|
+
// ]
|
|
7327
|
+
//
|
|
7328
|
+
return this.parseOptionChain(response, undefined, 'name');
|
|
7329
|
+
}
|
|
7330
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
7331
|
+
//
|
|
7332
|
+
// {
|
|
7333
|
+
// "is_active": true,
|
|
7334
|
+
// "mark_price_round": "0.1",
|
|
7335
|
+
// "settle_fee_rate": "0.00015",
|
|
7336
|
+
// "bid1_size": 434,
|
|
7337
|
+
// "taker_fee_rate": "0.0003",
|
|
7338
|
+
// "price_limit_fee_rate": "0.1",
|
|
7339
|
+
// "order_price_round": "1",
|
|
7340
|
+
// "tag": "day",
|
|
7341
|
+
// "ref_rebate_rate": "0",
|
|
7342
|
+
// "name": "BTC_USDT-20240324-63500-P",
|
|
7343
|
+
// "strike_price": "63500",
|
|
7344
|
+
// "ask1_price": "387",
|
|
7345
|
+
// "ref_discount_rate": "0",
|
|
7346
|
+
// "order_price_deviate": "0.15",
|
|
7347
|
+
// "ask1_size": -454,
|
|
7348
|
+
// "mark_price_down": "124.3",
|
|
7349
|
+
// "orderbook_id": 29600,
|
|
7350
|
+
// "is_call": false,
|
|
7351
|
+
// "last_price": "0",
|
|
7352
|
+
// "mark_price": "366.6",
|
|
7353
|
+
// "underlying": "BTC_USDT",
|
|
7354
|
+
// "create_time": 1711118829,
|
|
7355
|
+
// "settle_limit_fee_rate": "0.1",
|
|
7356
|
+
// "orders_limit": 10,
|
|
7357
|
+
// "mark_price_up": "630",
|
|
7358
|
+
// "position_size": 0,
|
|
7359
|
+
// "order_size_max": 10000,
|
|
7360
|
+
// "position_limit": 10000,
|
|
7361
|
+
// "multiplier": "0.01",
|
|
7362
|
+
// "order_size_min": 1,
|
|
7363
|
+
// "trade_size": 0,
|
|
7364
|
+
// "underlying_price": "64084.65",
|
|
7365
|
+
// "maker_fee_rate": "0.0003",
|
|
7366
|
+
// "expiration_time": 1711267200,
|
|
7367
|
+
// "trade_id": 0,
|
|
7368
|
+
// "bid1_price": "307"
|
|
7369
|
+
// }
|
|
7370
|
+
//
|
|
7371
|
+
const marketId = this.safeString(chain, 'name');
|
|
7372
|
+
market = this.safeMarket(marketId, market);
|
|
7373
|
+
const timestamp = this.safeTimestamp(chain, 'create_time');
|
|
7374
|
+
return {
|
|
7375
|
+
'info': chain,
|
|
7376
|
+
'currency': undefined,
|
|
7377
|
+
'symbol': market['symbol'],
|
|
7378
|
+
'timestamp': timestamp,
|
|
7379
|
+
'datetime': this.iso8601(timestamp),
|
|
7380
|
+
'impliedVolatility': undefined,
|
|
7381
|
+
'openInterest': undefined,
|
|
7382
|
+
'bidPrice': this.safeNumber(chain, 'bid1_price'),
|
|
7383
|
+
'askPrice': this.safeNumber(chain, 'ask1_price'),
|
|
7384
|
+
'midPrice': undefined,
|
|
7385
|
+
'markPrice': this.safeNumber(chain, 'mark_price'),
|
|
7386
|
+
'lastPrice': this.safeNumber(chain, 'last_price'),
|
|
7387
|
+
'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
|
|
7388
|
+
'change': undefined,
|
|
7389
|
+
'percentage': undefined,
|
|
7390
|
+
'baseVolume': undefined,
|
|
7391
|
+
'quoteVolume': undefined,
|
|
7392
|
+
};
|
|
7393
|
+
}
|
|
7208
7394
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7209
7395
|
if (response === undefined) {
|
|
7210
7396
|
return undefined;
|
package/js/src/hyperliquid.js
CHANGED
|
@@ -47,7 +47,7 @@ export default class hyperliquid extends Exchange {
|
|
|
47
47
|
'createMarketSellOrderWithCost': false,
|
|
48
48
|
'createOrder': true,
|
|
49
49
|
'createOrders': true,
|
|
50
|
-
'createReduceOnlyOrder':
|
|
50
|
+
'createReduceOnlyOrder': true,
|
|
51
51
|
'editOrder': true,
|
|
52
52
|
'fetchAccounts': false,
|
|
53
53
|
'fetchBalance': true,
|
|
@@ -884,7 +884,7 @@ export default class hyperliquid extends Exchange {
|
|
|
884
884
|
'tif': timeInForce,
|
|
885
885
|
};
|
|
886
886
|
}
|
|
887
|
-
orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id']);
|
|
887
|
+
orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly']);
|
|
888
888
|
const orderObj = {
|
|
889
889
|
'a': this.parseToInt(market['baseId']),
|
|
890
890
|
'b': isBuy,
|
|
@@ -2037,10 +2037,10 @@ export default class hyperliquid extends Exchange {
|
|
|
2037
2037
|
[userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
|
|
2038
2038
|
let user = userAux;
|
|
2039
2039
|
[user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux);
|
|
2040
|
-
if (user !== undefined) {
|
|
2040
|
+
if ((user !== undefined) && (user !== '')) {
|
|
2041
2041
|
return [user, params];
|
|
2042
2042
|
}
|
|
2043
|
-
if (this.walletAddress !== undefined) {
|
|
2043
|
+
if ((this.walletAddress !== undefined) && (this.walletAddress !== '')) {
|
|
2044
2044
|
return [this.walletAddress, params];
|
|
2045
2045
|
}
|
|
2046
2046
|
throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set');
|
package/js/src/okx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/okx.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class okx
|
|
5
5
|
* @augments Exchange
|
|
@@ -28,7 +28,6 @@ export default class okx extends Exchange {
|
|
|
28
28
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
29
29
|
parseTicker(ticker: any, market?: Market): Ticker;
|
|
30
30
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
31
|
-
fetchTickersByType(type: any, symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
|
|
32
31
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
33
32
|
parseTrade(trade: any, market?: Market): Trade;
|
|
34
33
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
@@ -316,5 +315,26 @@ export default class okx extends Exchange {
|
|
|
316
315
|
info: any;
|
|
317
316
|
};
|
|
318
317
|
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
318
|
+
fetchOption(symbol: string, params?: {}): Promise<Option>;
|
|
319
|
+
fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
|
|
320
|
+
parseOption(chain: any, currency?: Currency, market?: Market): {
|
|
321
|
+
info: any;
|
|
322
|
+
currency: any;
|
|
323
|
+
symbol: string;
|
|
324
|
+
timestamp: number;
|
|
325
|
+
datetime: string;
|
|
326
|
+
impliedVolatility: any;
|
|
327
|
+
openInterest: any;
|
|
328
|
+
bidPrice: number;
|
|
329
|
+
askPrice: number;
|
|
330
|
+
midPrice: any;
|
|
331
|
+
markPrice: any;
|
|
332
|
+
lastPrice: number;
|
|
333
|
+
underlyingPrice: any;
|
|
334
|
+
change: any;
|
|
335
|
+
percentage: any;
|
|
336
|
+
baseVolume: number;
|
|
337
|
+
quoteVolume: any;
|
|
338
|
+
};
|
|
319
339
|
handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
320
340
|
}
|
package/js/src/okx.js
CHANGED
|
@@ -97,6 +97,8 @@ export default class okx extends Exchange {
|
|
|
97
97
|
'fetchOpenInterestHistory': true,
|
|
98
98
|
'fetchOpenOrder': undefined,
|
|
99
99
|
'fetchOpenOrders': true,
|
|
100
|
+
'fetchOption': true,
|
|
101
|
+
'fetchOptionChain': true,
|
|
100
102
|
'fetchOrder': true,
|
|
101
103
|
'fetchOrderBook': true,
|
|
102
104
|
'fetchOrderBooks': false,
|
|
@@ -1858,16 +1860,29 @@ export default class okx extends Exchange {
|
|
|
1858
1860
|
const first = this.safeValue(data, 0, {});
|
|
1859
1861
|
return this.parseTicker(first, market);
|
|
1860
1862
|
}
|
|
1861
|
-
async
|
|
1863
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
1864
|
+
/**
|
|
1865
|
+
* @method
|
|
1866
|
+
* @name okx#fetchTickers
|
|
1867
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1868
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
1869
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1870
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1871
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1872
|
+
*/
|
|
1862
1873
|
await this.loadMarkets();
|
|
1874
|
+
symbols = this.marketSymbols(symbols);
|
|
1875
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1876
|
+
let marketType = undefined;
|
|
1877
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1863
1878
|
const request = {
|
|
1864
|
-
'instType': this.convertToInstrumentType(
|
|
1879
|
+
'instType': this.convertToInstrumentType(marketType),
|
|
1865
1880
|
};
|
|
1866
|
-
if (
|
|
1881
|
+
if (marketType === 'option') {
|
|
1867
1882
|
const defaultUnderlying = this.safeValue(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
1868
1883
|
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
1869
1884
|
if (currencyId === undefined) {
|
|
1870
|
-
throw new ArgumentsRequired(this.id + '
|
|
1885
|
+
throw new ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
1871
1886
|
}
|
|
1872
1887
|
else {
|
|
1873
1888
|
request['uly'] = currencyId;
|
|
@@ -1900,29 +1915,9 @@ export default class okx extends Exchange {
|
|
|
1900
1915
|
// ]
|
|
1901
1916
|
// }
|
|
1902
1917
|
//
|
|
1903
|
-
const tickers = this.
|
|
1918
|
+
const tickers = this.safeList(response, 'data', []);
|
|
1904
1919
|
return this.parseTickers(tickers, symbols);
|
|
1905
1920
|
}
|
|
1906
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
1907
|
-
/**
|
|
1908
|
-
* @method
|
|
1909
|
-
* @name okx#fetchTickers
|
|
1910
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1911
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
1912
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1913
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1914
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1915
|
-
*/
|
|
1916
|
-
await this.loadMarkets();
|
|
1917
|
-
symbols = this.marketSymbols(symbols);
|
|
1918
|
-
const first = this.safeString(symbols, 0);
|
|
1919
|
-
let market = undefined;
|
|
1920
|
-
if (first !== undefined) {
|
|
1921
|
-
market = this.market(first);
|
|
1922
|
-
}
|
|
1923
|
-
const [type, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1924
|
-
return await this.fetchTickersByType(type, symbols, query);
|
|
1925
|
-
}
|
|
1926
1921
|
parseTrade(trade, market = undefined) {
|
|
1927
1922
|
//
|
|
1928
1923
|
// public fetchTrades
|
|
@@ -4740,23 +4735,7 @@ export default class okx extends Exchange {
|
|
|
4740
4735
|
}
|
|
4741
4736
|
}
|
|
4742
4737
|
request['fee'] = this.numberToString(fee); // withdrawals to OKCoin or OKX are fee-free, please set 0
|
|
4743
|
-
|
|
4744
|
-
request['pwd'] = params['password'];
|
|
4745
|
-
}
|
|
4746
|
-
else if ('pwd' in params) {
|
|
4747
|
-
request['pwd'] = params['pwd'];
|
|
4748
|
-
}
|
|
4749
|
-
else {
|
|
4750
|
-
const options = this.safeValue(this.options, 'withdraw', {});
|
|
4751
|
-
const password = this.safeString2(options, 'password', 'pwd');
|
|
4752
|
-
if (password !== undefined) {
|
|
4753
|
-
request['pwd'] = password;
|
|
4754
|
-
}
|
|
4755
|
-
}
|
|
4756
|
-
const query = this.omit(params, ['fee', 'password', 'pwd']);
|
|
4757
|
-
if (!('pwd' in request)) {
|
|
4758
|
-
throw new ExchangeError(this.id + ' withdraw() requires a password parameter or a pwd parameter, it must be the funding password, not the API passphrase');
|
|
4759
|
-
}
|
|
4738
|
+
const query = this.omit(params, ['fee']);
|
|
4760
4739
|
const response = await this.privatePostAssetWithdrawal(this.extend(request, query));
|
|
4761
4740
|
//
|
|
4762
4741
|
// {
|
|
@@ -7436,6 +7415,143 @@ export default class okx extends Exchange {
|
|
|
7436
7415
|
const order = this.safeValue(data, 0);
|
|
7437
7416
|
return this.parseOrder(order, market);
|
|
7438
7417
|
}
|
|
7418
|
+
async fetchOption(symbol, params = {}) {
|
|
7419
|
+
/**
|
|
7420
|
+
* @method
|
|
7421
|
+
* @name okx#fetchOption
|
|
7422
|
+
* @description fetches option data that is commonly found in an option chain
|
|
7423
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker
|
|
7424
|
+
* @param {string} symbol unified market symbol
|
|
7425
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7426
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7427
|
+
*/
|
|
7428
|
+
await this.loadMarkets();
|
|
7429
|
+
const market = this.market(symbol);
|
|
7430
|
+
const request = {
|
|
7431
|
+
'instId': market['id'],
|
|
7432
|
+
};
|
|
7433
|
+
const response = await this.publicGetMarketTicker(this.extend(request, params));
|
|
7434
|
+
//
|
|
7435
|
+
// {
|
|
7436
|
+
// "code": "0",
|
|
7437
|
+
// "msg": "",
|
|
7438
|
+
// "data": [
|
|
7439
|
+
// {
|
|
7440
|
+
// "instType": "OPTION",
|
|
7441
|
+
// "instId": "BTC-USD-241227-60000-P",
|
|
7442
|
+
// "last": "",
|
|
7443
|
+
// "lastSz": "0",
|
|
7444
|
+
// "askPx": "",
|
|
7445
|
+
// "askSz": "0",
|
|
7446
|
+
// "bidPx": "",
|
|
7447
|
+
// "bidSz": "0",
|
|
7448
|
+
// "open24h": "",
|
|
7449
|
+
// "high24h": "",
|
|
7450
|
+
// "low24h": "",
|
|
7451
|
+
// "volCcy24h": "0",
|
|
7452
|
+
// "vol24h": "0",
|
|
7453
|
+
// "ts": "1711176035035",
|
|
7454
|
+
// "sodUtc0": "",
|
|
7455
|
+
// "sodUtc8": ""
|
|
7456
|
+
// }
|
|
7457
|
+
// ]
|
|
7458
|
+
// }
|
|
7459
|
+
//
|
|
7460
|
+
const result = this.safeList(response, 'data', []);
|
|
7461
|
+
const chain = this.safeDict(result, 0, {});
|
|
7462
|
+
return this.parseOption(chain, undefined, market);
|
|
7463
|
+
}
|
|
7464
|
+
async fetchOptionChain(code, params = {}) {
|
|
7465
|
+
/**
|
|
7466
|
+
* @method
|
|
7467
|
+
* @name okx#fetchOptionChain
|
|
7468
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
7469
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
7470
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
7471
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7472
|
+
* @param {string} [params.uly] the underlying asset, can be obtained from fetchUnderlyingAssets ()
|
|
7473
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
7474
|
+
*/
|
|
7475
|
+
await this.loadMarkets();
|
|
7476
|
+
const currency = this.currency(code);
|
|
7477
|
+
const request = {
|
|
7478
|
+
'uly': currency['code'] + '-USD',
|
|
7479
|
+
'instType': 'OPTION',
|
|
7480
|
+
};
|
|
7481
|
+
const response = await this.publicGetMarketTickers(this.extend(request, params));
|
|
7482
|
+
//
|
|
7483
|
+
// {
|
|
7484
|
+
// "code": "0",
|
|
7485
|
+
// "msg": "",
|
|
7486
|
+
// "data": [
|
|
7487
|
+
// {
|
|
7488
|
+
// "instType": "OPTION",
|
|
7489
|
+
// "instId": "BTC-USD-240323-52000-C",
|
|
7490
|
+
// "last": "",
|
|
7491
|
+
// "lastSz": "0",
|
|
7492
|
+
// "askPx": "",
|
|
7493
|
+
// "askSz": "0",
|
|
7494
|
+
// "bidPx": "",
|
|
7495
|
+
// "bidSz": "0",
|
|
7496
|
+
// "open24h": "",
|
|
7497
|
+
// "high24h": "",
|
|
7498
|
+
// "low24h": "",
|
|
7499
|
+
// "volCcy24h": "0",
|
|
7500
|
+
// "vol24h": "0",
|
|
7501
|
+
// "ts": "1711176207008",
|
|
7502
|
+
// "sodUtc0": "",
|
|
7503
|
+
// "sodUtc8": ""
|
|
7504
|
+
// },
|
|
7505
|
+
// ]
|
|
7506
|
+
// }
|
|
7507
|
+
//
|
|
7508
|
+
const result = this.safeList(response, 'data', []);
|
|
7509
|
+
return this.parseOptionChain(result, undefined, 'instId');
|
|
7510
|
+
}
|
|
7511
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
7512
|
+
//
|
|
7513
|
+
// {
|
|
7514
|
+
// "instType": "OPTION",
|
|
7515
|
+
// "instId": "BTC-USD-241227-60000-P",
|
|
7516
|
+
// "last": "",
|
|
7517
|
+
// "lastSz": "0",
|
|
7518
|
+
// "askPx": "",
|
|
7519
|
+
// "askSz": "0",
|
|
7520
|
+
// "bidPx": "",
|
|
7521
|
+
// "bidSz": "0",
|
|
7522
|
+
// "open24h": "",
|
|
7523
|
+
// "high24h": "",
|
|
7524
|
+
// "low24h": "",
|
|
7525
|
+
// "volCcy24h": "0",
|
|
7526
|
+
// "vol24h": "0",
|
|
7527
|
+
// "ts": "1711176035035",
|
|
7528
|
+
// "sodUtc0": "",
|
|
7529
|
+
// "sodUtc8": ""
|
|
7530
|
+
// }
|
|
7531
|
+
//
|
|
7532
|
+
const marketId = this.safeString(chain, 'instId');
|
|
7533
|
+
market = this.safeMarket(marketId, market);
|
|
7534
|
+
const timestamp = this.safeInteger(chain, 'ts');
|
|
7535
|
+
return {
|
|
7536
|
+
'info': chain,
|
|
7537
|
+
'currency': undefined,
|
|
7538
|
+
'symbol': market['symbol'],
|
|
7539
|
+
'timestamp': timestamp,
|
|
7540
|
+
'datetime': this.iso8601(timestamp),
|
|
7541
|
+
'impliedVolatility': undefined,
|
|
7542
|
+
'openInterest': undefined,
|
|
7543
|
+
'bidPrice': this.safeNumber(chain, 'bidPx'),
|
|
7544
|
+
'askPrice': this.safeNumber(chain, 'askPx'),
|
|
7545
|
+
'midPrice': undefined,
|
|
7546
|
+
'markPrice': undefined,
|
|
7547
|
+
'lastPrice': this.safeNumber(chain, 'last'),
|
|
7548
|
+
'underlyingPrice': undefined,
|
|
7549
|
+
'change': undefined,
|
|
7550
|
+
'percentage': undefined,
|
|
7551
|
+
'baseVolume': this.safeNumber(chain, 'volCcy24h'),
|
|
7552
|
+
'quoteVolume': undefined,
|
|
7553
|
+
};
|
|
7554
|
+
}
|
|
7439
7555
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7440
7556
|
if (!response) {
|
|
7441
7557
|
return undefined; // fallback to default error handler
|
package/package.json
CHANGED