ccxt 4.2.80 → 4.2.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.js +473 -43
- 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/gate.js +186 -0
- package/dist/cjs/src/okx.js +19 -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/gate.d.ts +22 -1
- package/js/src/gate.js +186 -0
- package/js/src/okx.d.ts +0 -1
- package/js/src/okx.js +19 -42
- package/package.json +1 -1
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
|
}
|
package/js/src/bybit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bybit.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bybit
|
|
5
5
|
* @augments Exchange
|
|
@@ -267,6 +267,27 @@ export default class bybit extends Exchange {
|
|
|
267
267
|
amount: number;
|
|
268
268
|
rate: number;
|
|
269
269
|
};
|
|
270
|
+
fetchOption(symbol: string, params?: {}): Promise<Option>;
|
|
271
|
+
fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
|
|
272
|
+
parseOption(chain: any, currency?: Currency, market?: Market): {
|
|
273
|
+
info: any;
|
|
274
|
+
currency: any;
|
|
275
|
+
symbol: string;
|
|
276
|
+
timestamp: any;
|
|
277
|
+
datetime: any;
|
|
278
|
+
impliedVolatility: number;
|
|
279
|
+
openInterest: number;
|
|
280
|
+
bidPrice: number;
|
|
281
|
+
askPrice: number;
|
|
282
|
+
midPrice: any;
|
|
283
|
+
markPrice: number;
|
|
284
|
+
lastPrice: number;
|
|
285
|
+
underlyingPrice: number;
|
|
286
|
+
change: number;
|
|
287
|
+
percentage: any;
|
|
288
|
+
baseVolume: number;
|
|
289
|
+
quoteVolume: any;
|
|
290
|
+
};
|
|
270
291
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
271
292
|
url: string;
|
|
272
293
|
method: string;
|
package/js/src/bybit.js
CHANGED
|
@@ -95,6 +95,8 @@ export default class bybit extends Exchange {
|
|
|
95
95
|
'fetchOpenInterestHistory': true,
|
|
96
96
|
'fetchOpenOrder': true,
|
|
97
97
|
'fetchOpenOrders': true,
|
|
98
|
+
'fetchOption': true,
|
|
99
|
+
'fetchOptionChain': true,
|
|
98
100
|
'fetchOrder': false,
|
|
99
101
|
'fetchOrderBook': true,
|
|
100
102
|
'fetchOrders': false,
|
|
@@ -8214,6 +8216,181 @@ export default class bybit extends Exchange {
|
|
|
8214
8216
|
'rate': this.safeNumber(income, 'feeRate'),
|
|
8215
8217
|
};
|
|
8216
8218
|
}
|
|
8219
|
+
async fetchOption(symbol, params = {}) {
|
|
8220
|
+
/**
|
|
8221
|
+
* @method
|
|
8222
|
+
* @name bybit#fetchOption
|
|
8223
|
+
* @description fetches option data that is commonly found in an option chain
|
|
8224
|
+
* @see https://bybit-exchange.github.io/docs/v5/market/tickers
|
|
8225
|
+
* @param {string} symbol unified market symbol
|
|
8226
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8227
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
8228
|
+
*/
|
|
8229
|
+
await this.loadMarkets();
|
|
8230
|
+
const market = this.market(symbol);
|
|
8231
|
+
const request = {
|
|
8232
|
+
'category': 'option',
|
|
8233
|
+
'symbol': market['id'],
|
|
8234
|
+
};
|
|
8235
|
+
const response = await this.publicGetV5MarketTickers(this.extend(request, params));
|
|
8236
|
+
//
|
|
8237
|
+
// {
|
|
8238
|
+
// "retCode": 0,
|
|
8239
|
+
// "retMsg": "SUCCESS",
|
|
8240
|
+
// "result": {
|
|
8241
|
+
// "category": "option",
|
|
8242
|
+
// "list": [
|
|
8243
|
+
// {
|
|
8244
|
+
// "symbol": "BTC-27DEC24-55000-P",
|
|
8245
|
+
// "bid1Price": "0",
|
|
8246
|
+
// "bid1Size": "0",
|
|
8247
|
+
// "bid1Iv": "0",
|
|
8248
|
+
// "ask1Price": "0",
|
|
8249
|
+
// "ask1Size": "0",
|
|
8250
|
+
// "ask1Iv": "0",
|
|
8251
|
+
// "lastPrice": "10980",
|
|
8252
|
+
// "highPrice24h": "0",
|
|
8253
|
+
// "lowPrice24h": "0",
|
|
8254
|
+
// "markPrice": "11814.66756236",
|
|
8255
|
+
// "indexPrice": "63838.92",
|
|
8256
|
+
// "markIv": "0.8866",
|
|
8257
|
+
// "underlyingPrice": "71690.55303594",
|
|
8258
|
+
// "openInterest": "0.01",
|
|
8259
|
+
// "turnover24h": "0",
|
|
8260
|
+
// "volume24h": "0",
|
|
8261
|
+
// "totalVolume": "2",
|
|
8262
|
+
// "totalTurnover": "78719",
|
|
8263
|
+
// "delta": "-0.23284954",
|
|
8264
|
+
// "gamma": "0.0000055",
|
|
8265
|
+
// "vega": "191.70757975",
|
|
8266
|
+
// "theta": "-30.43617927",
|
|
8267
|
+
// "predictedDeliveryPrice": "0",
|
|
8268
|
+
// "change24h": "0"
|
|
8269
|
+
// }
|
|
8270
|
+
// ]
|
|
8271
|
+
// },
|
|
8272
|
+
// "retExtInfo": {},
|
|
8273
|
+
// "time": 1711162003672
|
|
8274
|
+
// }
|
|
8275
|
+
//
|
|
8276
|
+
const result = this.safeDict(response, 'result', {});
|
|
8277
|
+
const resultList = this.safeList(result, 'list', []);
|
|
8278
|
+
const chain = this.safeDict(resultList, 0, {});
|
|
8279
|
+
return this.parseOption(chain, undefined, market);
|
|
8280
|
+
}
|
|
8281
|
+
async fetchOptionChain(code, params = {}) {
|
|
8282
|
+
/**
|
|
8283
|
+
* @method
|
|
8284
|
+
* @name bybit#fetchOptionChain
|
|
8285
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
8286
|
+
* @see https://bybit-exchange.github.io/docs/v5/market/tickers
|
|
8287
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
8288
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8289
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
8290
|
+
*/
|
|
8291
|
+
await this.loadMarkets();
|
|
8292
|
+
const currency = this.currency(code);
|
|
8293
|
+
const request = {
|
|
8294
|
+
'category': 'option',
|
|
8295
|
+
'baseCoin': currency['id'],
|
|
8296
|
+
};
|
|
8297
|
+
const response = await this.publicGetV5MarketTickers(this.extend(request, params));
|
|
8298
|
+
//
|
|
8299
|
+
// {
|
|
8300
|
+
// "retCode": 0,
|
|
8301
|
+
// "retMsg": "SUCCESS",
|
|
8302
|
+
// "result": {
|
|
8303
|
+
// "category": "option",
|
|
8304
|
+
// "list": [
|
|
8305
|
+
// {
|
|
8306
|
+
// "symbol": "BTC-27DEC24-55000-P",
|
|
8307
|
+
// "bid1Price": "0",
|
|
8308
|
+
// "bid1Size": "0",
|
|
8309
|
+
// "bid1Iv": "0",
|
|
8310
|
+
// "ask1Price": "0",
|
|
8311
|
+
// "ask1Size": "0",
|
|
8312
|
+
// "ask1Iv": "0",
|
|
8313
|
+
// "lastPrice": "10980",
|
|
8314
|
+
// "highPrice24h": "0",
|
|
8315
|
+
// "lowPrice24h": "0",
|
|
8316
|
+
// "markPrice": "11814.66756236",
|
|
8317
|
+
// "indexPrice": "63838.92",
|
|
8318
|
+
// "markIv": "0.8866",
|
|
8319
|
+
// "underlyingPrice": "71690.55303594",
|
|
8320
|
+
// "openInterest": "0.01",
|
|
8321
|
+
// "turnover24h": "0",
|
|
8322
|
+
// "volume24h": "0",
|
|
8323
|
+
// "totalVolume": "2",
|
|
8324
|
+
// "totalTurnover": "78719",
|
|
8325
|
+
// "delta": "-0.23284954",
|
|
8326
|
+
// "gamma": "0.0000055",
|
|
8327
|
+
// "vega": "191.70757975",
|
|
8328
|
+
// "theta": "-30.43617927",
|
|
8329
|
+
// "predictedDeliveryPrice": "0",
|
|
8330
|
+
// "change24h": "0"
|
|
8331
|
+
// },
|
|
8332
|
+
// ]
|
|
8333
|
+
// },
|
|
8334
|
+
// "retExtInfo": {},
|
|
8335
|
+
// "time": 1711162003672
|
|
8336
|
+
// }
|
|
8337
|
+
//
|
|
8338
|
+
const result = this.safeDict(response, 'result', {});
|
|
8339
|
+
const resultList = this.safeList(result, 'list', []);
|
|
8340
|
+
return this.parseOptionChain(resultList, undefined, 'symbol');
|
|
8341
|
+
}
|
|
8342
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
8343
|
+
//
|
|
8344
|
+
// {
|
|
8345
|
+
// "symbol": "BTC-27DEC24-55000-P",
|
|
8346
|
+
// "bid1Price": "0",
|
|
8347
|
+
// "bid1Size": "0",
|
|
8348
|
+
// "bid1Iv": "0",
|
|
8349
|
+
// "ask1Price": "0",
|
|
8350
|
+
// "ask1Size": "0",
|
|
8351
|
+
// "ask1Iv": "0",
|
|
8352
|
+
// "lastPrice": "10980",
|
|
8353
|
+
// "highPrice24h": "0",
|
|
8354
|
+
// "lowPrice24h": "0",
|
|
8355
|
+
// "markPrice": "11814.66756236",
|
|
8356
|
+
// "indexPrice": "63838.92",
|
|
8357
|
+
// "markIv": "0.8866",
|
|
8358
|
+
// "underlyingPrice": "71690.55303594",
|
|
8359
|
+
// "openInterest": "0.01",
|
|
8360
|
+
// "turnover24h": "0",
|
|
8361
|
+
// "volume24h": "0",
|
|
8362
|
+
// "totalVolume": "2",
|
|
8363
|
+
// "totalTurnover": "78719",
|
|
8364
|
+
// "delta": "-0.23284954",
|
|
8365
|
+
// "gamma": "0.0000055",
|
|
8366
|
+
// "vega": "191.70757975",
|
|
8367
|
+
// "theta": "-30.43617927",
|
|
8368
|
+
// "predictedDeliveryPrice": "0",
|
|
8369
|
+
// "change24h": "0"
|
|
8370
|
+
// }
|
|
8371
|
+
//
|
|
8372
|
+
const marketId = this.safeString(chain, 'symbol');
|
|
8373
|
+
market = this.safeMarket(marketId, market);
|
|
8374
|
+
return {
|
|
8375
|
+
'info': chain,
|
|
8376
|
+
'currency': undefined,
|
|
8377
|
+
'symbol': market['symbol'],
|
|
8378
|
+
'timestamp': undefined,
|
|
8379
|
+
'datetime': undefined,
|
|
8380
|
+
'impliedVolatility': this.safeNumber(chain, 'markIv'),
|
|
8381
|
+
'openInterest': this.safeNumber(chain, 'openInterest'),
|
|
8382
|
+
'bidPrice': this.safeNumber(chain, 'bid1Price'),
|
|
8383
|
+
'askPrice': this.safeNumber(chain, 'ask1Price'),
|
|
8384
|
+
'midPrice': undefined,
|
|
8385
|
+
'markPrice': this.safeNumber(chain, 'markPrice'),
|
|
8386
|
+
'lastPrice': this.safeNumber(chain, 'lastPrice'),
|
|
8387
|
+
'underlyingPrice': this.safeNumber(chain, 'underlyingPrice'),
|
|
8388
|
+
'change': this.safeNumber(chain, 'change24h'),
|
|
8389
|
+
'percentage': undefined,
|
|
8390
|
+
'baseVolume': this.safeNumber(chain, 'totalVolume'),
|
|
8391
|
+
'quoteVolume': undefined,
|
|
8392
|
+
};
|
|
8393
|
+
}
|
|
8217
8394
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
8218
8395
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
8219
8396
|
if (api === 'public') {
|
package/js/src/gate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/gate.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Leverage, Leverages, Num } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Leverage, Leverages, Num, OptionChain, Option } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class gate
|
|
5
5
|
* @augments Exchange
|
|
@@ -364,5 +364,26 @@ export default class gate extends Exchange {
|
|
|
364
364
|
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
365
365
|
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
366
366
|
parseLeverage(leverage: any, market?: any): Leverage;
|
|
367
|
+
fetchOption(symbol: string, params?: {}): Promise<Option>;
|
|
368
|
+
fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
|
|
369
|
+
parseOption(chain: any, currency?: Currency, market?: Market): {
|
|
370
|
+
info: any;
|
|
371
|
+
currency: any;
|
|
372
|
+
symbol: string;
|
|
373
|
+
timestamp: number;
|
|
374
|
+
datetime: string;
|
|
375
|
+
impliedVolatility: any;
|
|
376
|
+
openInterest: any;
|
|
377
|
+
bidPrice: number;
|
|
378
|
+
askPrice: number;
|
|
379
|
+
midPrice: any;
|
|
380
|
+
markPrice: number;
|
|
381
|
+
lastPrice: number;
|
|
382
|
+
underlyingPrice: number;
|
|
383
|
+
change: any;
|
|
384
|
+
percentage: any;
|
|
385
|
+
baseVolume: any;
|
|
386
|
+
quoteVolume: any;
|
|
387
|
+
};
|
|
367
388
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
368
389
|
}
|
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/okx.d.ts
CHANGED
|
@@ -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[]>;
|
package/js/src/okx.js
CHANGED
|
@@ -1858,16 +1858,29 @@ export default class okx extends Exchange {
|
|
|
1858
1858
|
const first = this.safeValue(data, 0, {});
|
|
1859
1859
|
return this.parseTicker(first, market);
|
|
1860
1860
|
}
|
|
1861
|
-
async
|
|
1861
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
1862
|
+
/**
|
|
1863
|
+
* @method
|
|
1864
|
+
* @name okx#fetchTickers
|
|
1865
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1866
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
1867
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1868
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1869
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1870
|
+
*/
|
|
1862
1871
|
await this.loadMarkets();
|
|
1872
|
+
symbols = this.marketSymbols(symbols);
|
|
1873
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1874
|
+
let marketType = undefined;
|
|
1875
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1863
1876
|
const request = {
|
|
1864
|
-
'instType': this.convertToInstrumentType(
|
|
1877
|
+
'instType': this.convertToInstrumentType(marketType),
|
|
1865
1878
|
};
|
|
1866
|
-
if (
|
|
1879
|
+
if (marketType === 'option') {
|
|
1867
1880
|
const defaultUnderlying = this.safeValue(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
1868
1881
|
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
1869
1882
|
if (currencyId === undefined) {
|
|
1870
|
-
throw new ArgumentsRequired(this.id + '
|
|
1883
|
+
throw new ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
1871
1884
|
}
|
|
1872
1885
|
else {
|
|
1873
1886
|
request['uly'] = currencyId;
|
|
@@ -1900,29 +1913,9 @@ export default class okx extends Exchange {
|
|
|
1900
1913
|
// ]
|
|
1901
1914
|
// }
|
|
1902
1915
|
//
|
|
1903
|
-
const tickers = this.
|
|
1916
|
+
const tickers = this.safeList(response, 'data', []);
|
|
1904
1917
|
return this.parseTickers(tickers, symbols);
|
|
1905
1918
|
}
|
|
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
1919
|
parseTrade(trade, market = undefined) {
|
|
1927
1920
|
//
|
|
1928
1921
|
// public fetchTrades
|
|
@@ -4740,23 +4733,7 @@ export default class okx extends Exchange {
|
|
|
4740
4733
|
}
|
|
4741
4734
|
}
|
|
4742
4735
|
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
|
-
}
|
|
4736
|
+
const query = this.omit(params, ['fee']);
|
|
4760
4737
|
const response = await this.privatePostAssetWithdrawal(this.extend(request, query));
|
|
4761
4738
|
//
|
|
4762
4739
|
// {
|