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/README.md
CHANGED
|
@@ -213,13 +213,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
213
213
|
|
|
214
214
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
215
215
|
|
|
216
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
217
|
-
* unpkg: https://unpkg.com/ccxt@4.2.
|
|
216
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.81/dist/ccxt.browser.js
|
|
217
|
+
* unpkg: https://unpkg.com/ccxt@4.2.81/dist/ccxt.browser.js
|
|
218
218
|
|
|
219
219
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
220
220
|
|
|
221
221
|
```HTML
|
|
222
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
222
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.81/dist/ccxt.browser.js"></script>
|
|
223
223
|
```
|
|
224
224
|
|
|
225
225
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -18559,6 +18559,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
18559
18559
|
'fetchOpenInterestHistory': true,
|
|
18560
18560
|
'fetchOpenOrder': true,
|
|
18561
18561
|
'fetchOpenOrders': true,
|
|
18562
|
+
'fetchOption': true,
|
|
18563
|
+
'fetchOptionChain': false,
|
|
18562
18564
|
'fetchOrder': true,
|
|
18563
18565
|
'fetchOrderBook': true,
|
|
18564
18566
|
'fetchOrderBooks': false,
|
|
@@ -30856,6 +30858,94 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
30856
30858
|
'marginMode': isIsolated ? 'isolated' : 'cross',
|
|
30857
30859
|
};
|
|
30858
30860
|
}
|
|
30861
|
+
async fetchOption(symbol, params = {}) {
|
|
30862
|
+
/**
|
|
30863
|
+
* @method
|
|
30864
|
+
* @name binance#fetchOption
|
|
30865
|
+
* @description fetches option data that is commonly found in an option chain
|
|
30866
|
+
* @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics
|
|
30867
|
+
* @param {string} symbol unified market symbol
|
|
30868
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
30869
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
30870
|
+
*/
|
|
30871
|
+
await this.loadMarkets();
|
|
30872
|
+
const market = this.market(symbol);
|
|
30873
|
+
const request = {
|
|
30874
|
+
'symbol': market['id'],
|
|
30875
|
+
};
|
|
30876
|
+
const response = await this.eapiPublicGetTicker(this.extend(request, params));
|
|
30877
|
+
//
|
|
30878
|
+
// [
|
|
30879
|
+
// {
|
|
30880
|
+
// "symbol": "BTC-241227-80000-C",
|
|
30881
|
+
// "priceChange": "0",
|
|
30882
|
+
// "priceChangePercent": "0",
|
|
30883
|
+
// "lastPrice": "2750",
|
|
30884
|
+
// "lastQty": "0",
|
|
30885
|
+
// "open": "2750",
|
|
30886
|
+
// "high": "2750",
|
|
30887
|
+
// "low": "2750",
|
|
30888
|
+
// "volume": "0",
|
|
30889
|
+
// "amount": "0",
|
|
30890
|
+
// "bidPrice": "4880",
|
|
30891
|
+
// "askPrice": "0",
|
|
30892
|
+
// "openTime": 0,
|
|
30893
|
+
// "closeTime": 0,
|
|
30894
|
+
// "firstTradeId": 0,
|
|
30895
|
+
// "tradeCount": 0,
|
|
30896
|
+
// "strikePrice": "80000",
|
|
30897
|
+
// "exercisePrice": "63944.09893617"
|
|
30898
|
+
// }
|
|
30899
|
+
// ]
|
|
30900
|
+
//
|
|
30901
|
+
const chain = this.safeDict(response, 0, {});
|
|
30902
|
+
return this.parseOption(chain, undefined, market);
|
|
30903
|
+
}
|
|
30904
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
30905
|
+
//
|
|
30906
|
+
// {
|
|
30907
|
+
// "symbol": "BTC-241227-80000-C",
|
|
30908
|
+
// "priceChange": "0",
|
|
30909
|
+
// "priceChangePercent": "0",
|
|
30910
|
+
// "lastPrice": "2750",
|
|
30911
|
+
// "lastQty": "0",
|
|
30912
|
+
// "open": "2750",
|
|
30913
|
+
// "high": "2750",
|
|
30914
|
+
// "low": "2750",
|
|
30915
|
+
// "volume": "0",
|
|
30916
|
+
// "amount": "0",
|
|
30917
|
+
// "bidPrice": "4880",
|
|
30918
|
+
// "askPrice": "0",
|
|
30919
|
+
// "openTime": 0,
|
|
30920
|
+
// "closeTime": 0,
|
|
30921
|
+
// "firstTradeId": 0,
|
|
30922
|
+
// "tradeCount": 0,
|
|
30923
|
+
// "strikePrice": "80000",
|
|
30924
|
+
// "exercisePrice": "63944.09893617"
|
|
30925
|
+
// }
|
|
30926
|
+
//
|
|
30927
|
+
const marketId = this.safeString(chain, 'symbol');
|
|
30928
|
+
market = this.safeMarket(marketId, market);
|
|
30929
|
+
return {
|
|
30930
|
+
'info': chain,
|
|
30931
|
+
'currency': undefined,
|
|
30932
|
+
'symbol': market['symbol'],
|
|
30933
|
+
'timestamp': undefined,
|
|
30934
|
+
'datetime': undefined,
|
|
30935
|
+
'impliedVolatility': undefined,
|
|
30936
|
+
'openInterest': undefined,
|
|
30937
|
+
'bidPrice': this.safeNumber(chain, 'bidPrice'),
|
|
30938
|
+
'askPrice': this.safeNumber(chain, 'askPrice'),
|
|
30939
|
+
'midPrice': undefined,
|
|
30940
|
+
'markPrice': undefined,
|
|
30941
|
+
'lastPrice': this.safeNumber(chain, 'lastPrice'),
|
|
30942
|
+
'underlyingPrice': this.safeNumber(chain, 'exercisePrice'),
|
|
30943
|
+
'change': this.safeNumber(chain, 'priceChange'),
|
|
30944
|
+
'percentage': this.safeNumber(chain, 'priceChangePercent'),
|
|
30945
|
+
'baseVolume': this.safeNumber(chain, 'volume'),
|
|
30946
|
+
'quoteVolume': undefined,
|
|
30947
|
+
};
|
|
30948
|
+
}
|
|
30859
30949
|
}
|
|
30860
30950
|
|
|
30861
30951
|
|
|
@@ -83629,6 +83719,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
83629
83719
|
'fetchOpenInterestHistory': true,
|
|
83630
83720
|
'fetchOpenOrder': true,
|
|
83631
83721
|
'fetchOpenOrders': true,
|
|
83722
|
+
'fetchOption': true,
|
|
83723
|
+
'fetchOptionChain': true,
|
|
83632
83724
|
'fetchOrder': false,
|
|
83633
83725
|
'fetchOrderBook': true,
|
|
83634
83726
|
'fetchOrders': false,
|
|
@@ -91748,6 +91840,181 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
91748
91840
|
'rate': this.safeNumber(income, 'feeRate'),
|
|
91749
91841
|
};
|
|
91750
91842
|
}
|
|
91843
|
+
async fetchOption(symbol, params = {}) {
|
|
91844
|
+
/**
|
|
91845
|
+
* @method
|
|
91846
|
+
* @name bybit#fetchOption
|
|
91847
|
+
* @description fetches option data that is commonly found in an option chain
|
|
91848
|
+
* @see https://bybit-exchange.github.io/docs/v5/market/tickers
|
|
91849
|
+
* @param {string} symbol unified market symbol
|
|
91850
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
91851
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
91852
|
+
*/
|
|
91853
|
+
await this.loadMarkets();
|
|
91854
|
+
const market = this.market(symbol);
|
|
91855
|
+
const request = {
|
|
91856
|
+
'category': 'option',
|
|
91857
|
+
'symbol': market['id'],
|
|
91858
|
+
};
|
|
91859
|
+
const response = await this.publicGetV5MarketTickers(this.extend(request, params));
|
|
91860
|
+
//
|
|
91861
|
+
// {
|
|
91862
|
+
// "retCode": 0,
|
|
91863
|
+
// "retMsg": "SUCCESS",
|
|
91864
|
+
// "result": {
|
|
91865
|
+
// "category": "option",
|
|
91866
|
+
// "list": [
|
|
91867
|
+
// {
|
|
91868
|
+
// "symbol": "BTC-27DEC24-55000-P",
|
|
91869
|
+
// "bid1Price": "0",
|
|
91870
|
+
// "bid1Size": "0",
|
|
91871
|
+
// "bid1Iv": "0",
|
|
91872
|
+
// "ask1Price": "0",
|
|
91873
|
+
// "ask1Size": "0",
|
|
91874
|
+
// "ask1Iv": "0",
|
|
91875
|
+
// "lastPrice": "10980",
|
|
91876
|
+
// "highPrice24h": "0",
|
|
91877
|
+
// "lowPrice24h": "0",
|
|
91878
|
+
// "markPrice": "11814.66756236",
|
|
91879
|
+
// "indexPrice": "63838.92",
|
|
91880
|
+
// "markIv": "0.8866",
|
|
91881
|
+
// "underlyingPrice": "71690.55303594",
|
|
91882
|
+
// "openInterest": "0.01",
|
|
91883
|
+
// "turnover24h": "0",
|
|
91884
|
+
// "volume24h": "0",
|
|
91885
|
+
// "totalVolume": "2",
|
|
91886
|
+
// "totalTurnover": "78719",
|
|
91887
|
+
// "delta": "-0.23284954",
|
|
91888
|
+
// "gamma": "0.0000055",
|
|
91889
|
+
// "vega": "191.70757975",
|
|
91890
|
+
// "theta": "-30.43617927",
|
|
91891
|
+
// "predictedDeliveryPrice": "0",
|
|
91892
|
+
// "change24h": "0"
|
|
91893
|
+
// }
|
|
91894
|
+
// ]
|
|
91895
|
+
// },
|
|
91896
|
+
// "retExtInfo": {},
|
|
91897
|
+
// "time": 1711162003672
|
|
91898
|
+
// }
|
|
91899
|
+
//
|
|
91900
|
+
const result = this.safeDict(response, 'result', {});
|
|
91901
|
+
const resultList = this.safeList(result, 'list', []);
|
|
91902
|
+
const chain = this.safeDict(resultList, 0, {});
|
|
91903
|
+
return this.parseOption(chain, undefined, market);
|
|
91904
|
+
}
|
|
91905
|
+
async fetchOptionChain(code, params = {}) {
|
|
91906
|
+
/**
|
|
91907
|
+
* @method
|
|
91908
|
+
* @name bybit#fetchOptionChain
|
|
91909
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
91910
|
+
* @see https://bybit-exchange.github.io/docs/v5/market/tickers
|
|
91911
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
91912
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
91913
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
91914
|
+
*/
|
|
91915
|
+
await this.loadMarkets();
|
|
91916
|
+
const currency = this.currency(code);
|
|
91917
|
+
const request = {
|
|
91918
|
+
'category': 'option',
|
|
91919
|
+
'baseCoin': currency['id'],
|
|
91920
|
+
};
|
|
91921
|
+
const response = await this.publicGetV5MarketTickers(this.extend(request, params));
|
|
91922
|
+
//
|
|
91923
|
+
// {
|
|
91924
|
+
// "retCode": 0,
|
|
91925
|
+
// "retMsg": "SUCCESS",
|
|
91926
|
+
// "result": {
|
|
91927
|
+
// "category": "option",
|
|
91928
|
+
// "list": [
|
|
91929
|
+
// {
|
|
91930
|
+
// "symbol": "BTC-27DEC24-55000-P",
|
|
91931
|
+
// "bid1Price": "0",
|
|
91932
|
+
// "bid1Size": "0",
|
|
91933
|
+
// "bid1Iv": "0",
|
|
91934
|
+
// "ask1Price": "0",
|
|
91935
|
+
// "ask1Size": "0",
|
|
91936
|
+
// "ask1Iv": "0",
|
|
91937
|
+
// "lastPrice": "10980",
|
|
91938
|
+
// "highPrice24h": "0",
|
|
91939
|
+
// "lowPrice24h": "0",
|
|
91940
|
+
// "markPrice": "11814.66756236",
|
|
91941
|
+
// "indexPrice": "63838.92",
|
|
91942
|
+
// "markIv": "0.8866",
|
|
91943
|
+
// "underlyingPrice": "71690.55303594",
|
|
91944
|
+
// "openInterest": "0.01",
|
|
91945
|
+
// "turnover24h": "0",
|
|
91946
|
+
// "volume24h": "0",
|
|
91947
|
+
// "totalVolume": "2",
|
|
91948
|
+
// "totalTurnover": "78719",
|
|
91949
|
+
// "delta": "-0.23284954",
|
|
91950
|
+
// "gamma": "0.0000055",
|
|
91951
|
+
// "vega": "191.70757975",
|
|
91952
|
+
// "theta": "-30.43617927",
|
|
91953
|
+
// "predictedDeliveryPrice": "0",
|
|
91954
|
+
// "change24h": "0"
|
|
91955
|
+
// },
|
|
91956
|
+
// ]
|
|
91957
|
+
// },
|
|
91958
|
+
// "retExtInfo": {},
|
|
91959
|
+
// "time": 1711162003672
|
|
91960
|
+
// }
|
|
91961
|
+
//
|
|
91962
|
+
const result = this.safeDict(response, 'result', {});
|
|
91963
|
+
const resultList = this.safeList(result, 'list', []);
|
|
91964
|
+
return this.parseOptionChain(resultList, undefined, 'symbol');
|
|
91965
|
+
}
|
|
91966
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
91967
|
+
//
|
|
91968
|
+
// {
|
|
91969
|
+
// "symbol": "BTC-27DEC24-55000-P",
|
|
91970
|
+
// "bid1Price": "0",
|
|
91971
|
+
// "bid1Size": "0",
|
|
91972
|
+
// "bid1Iv": "0",
|
|
91973
|
+
// "ask1Price": "0",
|
|
91974
|
+
// "ask1Size": "0",
|
|
91975
|
+
// "ask1Iv": "0",
|
|
91976
|
+
// "lastPrice": "10980",
|
|
91977
|
+
// "highPrice24h": "0",
|
|
91978
|
+
// "lowPrice24h": "0",
|
|
91979
|
+
// "markPrice": "11814.66756236",
|
|
91980
|
+
// "indexPrice": "63838.92",
|
|
91981
|
+
// "markIv": "0.8866",
|
|
91982
|
+
// "underlyingPrice": "71690.55303594",
|
|
91983
|
+
// "openInterest": "0.01",
|
|
91984
|
+
// "turnover24h": "0",
|
|
91985
|
+
// "volume24h": "0",
|
|
91986
|
+
// "totalVolume": "2",
|
|
91987
|
+
// "totalTurnover": "78719",
|
|
91988
|
+
// "delta": "-0.23284954",
|
|
91989
|
+
// "gamma": "0.0000055",
|
|
91990
|
+
// "vega": "191.70757975",
|
|
91991
|
+
// "theta": "-30.43617927",
|
|
91992
|
+
// "predictedDeliveryPrice": "0",
|
|
91993
|
+
// "change24h": "0"
|
|
91994
|
+
// }
|
|
91995
|
+
//
|
|
91996
|
+
const marketId = this.safeString(chain, 'symbol');
|
|
91997
|
+
market = this.safeMarket(marketId, market);
|
|
91998
|
+
return {
|
|
91999
|
+
'info': chain,
|
|
92000
|
+
'currency': undefined,
|
|
92001
|
+
'symbol': market['symbol'],
|
|
92002
|
+
'timestamp': undefined,
|
|
92003
|
+
'datetime': undefined,
|
|
92004
|
+
'impliedVolatility': this.safeNumber(chain, 'markIv'),
|
|
92005
|
+
'openInterest': this.safeNumber(chain, 'openInterest'),
|
|
92006
|
+
'bidPrice': this.safeNumber(chain, 'bid1Price'),
|
|
92007
|
+
'askPrice': this.safeNumber(chain, 'ask1Price'),
|
|
92008
|
+
'midPrice': undefined,
|
|
92009
|
+
'markPrice': this.safeNumber(chain, 'markPrice'),
|
|
92010
|
+
'lastPrice': this.safeNumber(chain, 'lastPrice'),
|
|
92011
|
+
'underlyingPrice': this.safeNumber(chain, 'underlyingPrice'),
|
|
92012
|
+
'change': this.safeNumber(chain, 'change24h'),
|
|
92013
|
+
'percentage': undefined,
|
|
92014
|
+
'baseVolume': this.safeNumber(chain, 'totalVolume'),
|
|
92015
|
+
'quoteVolume': undefined,
|
|
92016
|
+
};
|
|
92017
|
+
}
|
|
91751
92018
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
91752
92019
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
91753
92020
|
if (api === 'public') {
|
|
@@ -136280,6 +136547,8 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
136280
136547
|
'fetchOpenInterest': false,
|
|
136281
136548
|
'fetchOpenInterestHistory': true,
|
|
136282
136549
|
'fetchOpenOrders': true,
|
|
136550
|
+
'fetchOption': true,
|
|
136551
|
+
'fetchOptionChain': true,
|
|
136283
136552
|
'fetchOrder': true,
|
|
136284
136553
|
'fetchOrderBook': true,
|
|
136285
136554
|
'fetchPosition': true,
|
|
@@ -143350,6 +143619,190 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
143350
143619
|
'shortLeverage': leverageValue,
|
|
143351
143620
|
};
|
|
143352
143621
|
}
|
|
143622
|
+
async fetchOption(symbol, params = {}) {
|
|
143623
|
+
/**
|
|
143624
|
+
* @method
|
|
143625
|
+
* @name gate#fetchOption
|
|
143626
|
+
* @description fetches option data that is commonly found in an option chain
|
|
143627
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#query-specified-contract-detail
|
|
143628
|
+
* @param {string} symbol unified market symbol
|
|
143629
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
143630
|
+
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
143631
|
+
*/
|
|
143632
|
+
await this.loadMarkets();
|
|
143633
|
+
const market = this.market(symbol);
|
|
143634
|
+
const request = {
|
|
143635
|
+
'contract': market['id'],
|
|
143636
|
+
};
|
|
143637
|
+
const response = await this.publicOptionsGetContractsContract(this.extend(request, params));
|
|
143638
|
+
//
|
|
143639
|
+
// {
|
|
143640
|
+
// "is_active": true,
|
|
143641
|
+
// "mark_price_round": "0.01",
|
|
143642
|
+
// "settle_fee_rate": "0.00015",
|
|
143643
|
+
// "bid1_size": 30,
|
|
143644
|
+
// "taker_fee_rate": "0.0003",
|
|
143645
|
+
// "price_limit_fee_rate": "0.1",
|
|
143646
|
+
// "order_price_round": "0.1",
|
|
143647
|
+
// "tag": "month",
|
|
143648
|
+
// "ref_rebate_rate": "0",
|
|
143649
|
+
// "name": "ETH_USDT-20240628-4500-C",
|
|
143650
|
+
// "strike_price": "4500",
|
|
143651
|
+
// "ask1_price": "280.5",
|
|
143652
|
+
// "ref_discount_rate": "0",
|
|
143653
|
+
// "order_price_deviate": "0.2",
|
|
143654
|
+
// "ask1_size": -19,
|
|
143655
|
+
// "mark_price_down": "155.45",
|
|
143656
|
+
// "orderbook_id": 11724695,
|
|
143657
|
+
// "is_call": true,
|
|
143658
|
+
// "last_price": "188.7",
|
|
143659
|
+
// "mark_price": "274.26",
|
|
143660
|
+
// "underlying": "ETH_USDT",
|
|
143661
|
+
// "create_time": 1688024882,
|
|
143662
|
+
// "settle_limit_fee_rate": "0.1",
|
|
143663
|
+
// "orders_limit": 10,
|
|
143664
|
+
// "mark_price_up": "403.83",
|
|
143665
|
+
// "position_size": 80,
|
|
143666
|
+
// "order_size_max": 10000,
|
|
143667
|
+
// "position_limit": 100000,
|
|
143668
|
+
// "multiplier": "0.01",
|
|
143669
|
+
// "order_size_min": 1,
|
|
143670
|
+
// "trade_size": 229,
|
|
143671
|
+
// "underlying_price": "3326.6",
|
|
143672
|
+
// "maker_fee_rate": "0.0003",
|
|
143673
|
+
// "expiration_time": 1719561600,
|
|
143674
|
+
// "trade_id": 15,
|
|
143675
|
+
// "bid1_price": "269.3"
|
|
143676
|
+
// }
|
|
143677
|
+
//
|
|
143678
|
+
return this.parseOption(response, undefined, market);
|
|
143679
|
+
}
|
|
143680
|
+
async fetchOptionChain(code, params = {}) {
|
|
143681
|
+
/**
|
|
143682
|
+
* @method
|
|
143683
|
+
* @name gate#fetchOptionChain
|
|
143684
|
+
* @description fetches data for an underlying asset that is commonly found in an option chain
|
|
143685
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
|
|
143686
|
+
* @param {string} currency base currency to fetch an option chain for
|
|
143687
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
143688
|
+
* @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
|
|
143689
|
+
* @param {int} [params.expiration] unix timestamp of the expiration time
|
|
143690
|
+
* @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
|
|
143691
|
+
*/
|
|
143692
|
+
await this.loadMarkets();
|
|
143693
|
+
const currency = this.currency(code);
|
|
143694
|
+
const request = {
|
|
143695
|
+
'underlying': currency['code'] + '_USDT',
|
|
143696
|
+
};
|
|
143697
|
+
const response = await this.publicOptionsGetContracts(this.extend(request, params));
|
|
143698
|
+
//
|
|
143699
|
+
// [
|
|
143700
|
+
// {
|
|
143701
|
+
// "is_active": true,
|
|
143702
|
+
// "mark_price_round": "0.1",
|
|
143703
|
+
// "settle_fee_rate": "0.00015",
|
|
143704
|
+
// "bid1_size": 434,
|
|
143705
|
+
// "taker_fee_rate": "0.0003",
|
|
143706
|
+
// "price_limit_fee_rate": "0.1",
|
|
143707
|
+
// "order_price_round": "1",
|
|
143708
|
+
// "tag": "day",
|
|
143709
|
+
// "ref_rebate_rate": "0",
|
|
143710
|
+
// "name": "BTC_USDT-20240324-63500-P",
|
|
143711
|
+
// "strike_price": "63500",
|
|
143712
|
+
// "ask1_price": "387",
|
|
143713
|
+
// "ref_discount_rate": "0",
|
|
143714
|
+
// "order_price_deviate": "0.15",
|
|
143715
|
+
// "ask1_size": -454,
|
|
143716
|
+
// "mark_price_down": "124.3",
|
|
143717
|
+
// "orderbook_id": 29600,
|
|
143718
|
+
// "is_call": false,
|
|
143719
|
+
// "last_price": "0",
|
|
143720
|
+
// "mark_price": "366.6",
|
|
143721
|
+
// "underlying": "BTC_USDT",
|
|
143722
|
+
// "create_time": 1711118829,
|
|
143723
|
+
// "settle_limit_fee_rate": "0.1",
|
|
143724
|
+
// "orders_limit": 10,
|
|
143725
|
+
// "mark_price_up": "630",
|
|
143726
|
+
// "position_size": 0,
|
|
143727
|
+
// "order_size_max": 10000,
|
|
143728
|
+
// "position_limit": 10000,
|
|
143729
|
+
// "multiplier": "0.01",
|
|
143730
|
+
// "order_size_min": 1,
|
|
143731
|
+
// "trade_size": 0,
|
|
143732
|
+
// "underlying_price": "64084.65",
|
|
143733
|
+
// "maker_fee_rate": "0.0003",
|
|
143734
|
+
// "expiration_time": 1711267200,
|
|
143735
|
+
// "trade_id": 0,
|
|
143736
|
+
// "bid1_price": "307"
|
|
143737
|
+
// },
|
|
143738
|
+
// ]
|
|
143739
|
+
//
|
|
143740
|
+
return this.parseOptionChain(response, undefined, 'name');
|
|
143741
|
+
}
|
|
143742
|
+
parseOption(chain, currency = undefined, market = undefined) {
|
|
143743
|
+
//
|
|
143744
|
+
// {
|
|
143745
|
+
// "is_active": true,
|
|
143746
|
+
// "mark_price_round": "0.1",
|
|
143747
|
+
// "settle_fee_rate": "0.00015",
|
|
143748
|
+
// "bid1_size": 434,
|
|
143749
|
+
// "taker_fee_rate": "0.0003",
|
|
143750
|
+
// "price_limit_fee_rate": "0.1",
|
|
143751
|
+
// "order_price_round": "1",
|
|
143752
|
+
// "tag": "day",
|
|
143753
|
+
// "ref_rebate_rate": "0",
|
|
143754
|
+
// "name": "BTC_USDT-20240324-63500-P",
|
|
143755
|
+
// "strike_price": "63500",
|
|
143756
|
+
// "ask1_price": "387",
|
|
143757
|
+
// "ref_discount_rate": "0",
|
|
143758
|
+
// "order_price_deviate": "0.15",
|
|
143759
|
+
// "ask1_size": -454,
|
|
143760
|
+
// "mark_price_down": "124.3",
|
|
143761
|
+
// "orderbook_id": 29600,
|
|
143762
|
+
// "is_call": false,
|
|
143763
|
+
// "last_price": "0",
|
|
143764
|
+
// "mark_price": "366.6",
|
|
143765
|
+
// "underlying": "BTC_USDT",
|
|
143766
|
+
// "create_time": 1711118829,
|
|
143767
|
+
// "settle_limit_fee_rate": "0.1",
|
|
143768
|
+
// "orders_limit": 10,
|
|
143769
|
+
// "mark_price_up": "630",
|
|
143770
|
+
// "position_size": 0,
|
|
143771
|
+
// "order_size_max": 10000,
|
|
143772
|
+
// "position_limit": 10000,
|
|
143773
|
+
// "multiplier": "0.01",
|
|
143774
|
+
// "order_size_min": 1,
|
|
143775
|
+
// "trade_size": 0,
|
|
143776
|
+
// "underlying_price": "64084.65",
|
|
143777
|
+
// "maker_fee_rate": "0.0003",
|
|
143778
|
+
// "expiration_time": 1711267200,
|
|
143779
|
+
// "trade_id": 0,
|
|
143780
|
+
// "bid1_price": "307"
|
|
143781
|
+
// }
|
|
143782
|
+
//
|
|
143783
|
+
const marketId = this.safeString(chain, 'name');
|
|
143784
|
+
market = this.safeMarket(marketId, market);
|
|
143785
|
+
const timestamp = this.safeTimestamp(chain, 'create_time');
|
|
143786
|
+
return {
|
|
143787
|
+
'info': chain,
|
|
143788
|
+
'currency': undefined,
|
|
143789
|
+
'symbol': market['symbol'],
|
|
143790
|
+
'timestamp': timestamp,
|
|
143791
|
+
'datetime': this.iso8601(timestamp),
|
|
143792
|
+
'impliedVolatility': undefined,
|
|
143793
|
+
'openInterest': undefined,
|
|
143794
|
+
'bidPrice': this.safeNumber(chain, 'bid1_price'),
|
|
143795
|
+
'askPrice': this.safeNumber(chain, 'ask1_price'),
|
|
143796
|
+
'midPrice': undefined,
|
|
143797
|
+
'markPrice': this.safeNumber(chain, 'mark_price'),
|
|
143798
|
+
'lastPrice': this.safeNumber(chain, 'last_price'),
|
|
143799
|
+
'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
|
|
143800
|
+
'change': undefined,
|
|
143801
|
+
'percentage': undefined,
|
|
143802
|
+
'baseVolume': undefined,
|
|
143803
|
+
'quoteVolume': undefined,
|
|
143804
|
+
};
|
|
143805
|
+
}
|
|
143353
143806
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
143354
143807
|
if (response === undefined) {
|
|
143355
143808
|
return undefined;
|
|
@@ -206758,16 +207211,29 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
206758
207211
|
const first = this.safeValue(data, 0, {});
|
|
206759
207212
|
return this.parseTicker(first, market);
|
|
206760
207213
|
}
|
|
206761
|
-
async
|
|
207214
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
207215
|
+
/**
|
|
207216
|
+
* @method
|
|
207217
|
+
* @name okx#fetchTickers
|
|
207218
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
207219
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
207220
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
207221
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
207222
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
207223
|
+
*/
|
|
206762
207224
|
await this.loadMarkets();
|
|
207225
|
+
symbols = this.marketSymbols(symbols);
|
|
207226
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
207227
|
+
let marketType = undefined;
|
|
207228
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
206763
207229
|
const request = {
|
|
206764
|
-
'instType': this.convertToInstrumentType(
|
|
207230
|
+
'instType': this.convertToInstrumentType(marketType),
|
|
206765
207231
|
};
|
|
206766
|
-
if (
|
|
207232
|
+
if (marketType === 'option') {
|
|
206767
207233
|
const defaultUnderlying = this.safeValue(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
206768
207234
|
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
206769
207235
|
if (currencyId === undefined) {
|
|
206770
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + '
|
|
207236
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
206771
207237
|
}
|
|
206772
207238
|
else {
|
|
206773
207239
|
request['uly'] = currencyId;
|
|
@@ -206800,29 +207266,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
206800
207266
|
// ]
|
|
206801
207267
|
// }
|
|
206802
207268
|
//
|
|
206803
|
-
const tickers = this.
|
|
207269
|
+
const tickers = this.safeList(response, 'data', []);
|
|
206804
207270
|
return this.parseTickers(tickers, symbols);
|
|
206805
207271
|
}
|
|
206806
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
206807
|
-
/**
|
|
206808
|
-
* @method
|
|
206809
|
-
* @name okx#fetchTickers
|
|
206810
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
206811
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
|
|
206812
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
206813
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
206814
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
206815
|
-
*/
|
|
206816
|
-
await this.loadMarkets();
|
|
206817
|
-
symbols = this.marketSymbols(symbols);
|
|
206818
|
-
const first = this.safeString(symbols, 0);
|
|
206819
|
-
let market = undefined;
|
|
206820
|
-
if (first !== undefined) {
|
|
206821
|
-
market = this.market(first);
|
|
206822
|
-
}
|
|
206823
|
-
const [type, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
206824
|
-
return await this.fetchTickersByType(type, symbols, query);
|
|
206825
|
-
}
|
|
206826
207272
|
parseTrade(trade, market = undefined) {
|
|
206827
207273
|
//
|
|
206828
207274
|
// public fetchTrades
|
|
@@ -209640,23 +210086,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209640
210086
|
}
|
|
209641
210087
|
}
|
|
209642
210088
|
request['fee'] = this.numberToString(fee); // withdrawals to OKCoin or OKX are fee-free, please set 0
|
|
209643
|
-
|
|
209644
|
-
request['pwd'] = params['password'];
|
|
209645
|
-
}
|
|
209646
|
-
else if ('pwd' in params) {
|
|
209647
|
-
request['pwd'] = params['pwd'];
|
|
209648
|
-
}
|
|
209649
|
-
else {
|
|
209650
|
-
const options = this.safeValue(this.options, 'withdraw', {});
|
|
209651
|
-
const password = this.safeString2(options, 'password', 'pwd');
|
|
209652
|
-
if (password !== undefined) {
|
|
209653
|
-
request['pwd'] = password;
|
|
209654
|
-
}
|
|
209655
|
-
}
|
|
209656
|
-
const query = this.omit(params, ['fee', 'password', 'pwd']);
|
|
209657
|
-
if (!('pwd' in request)) {
|
|
209658
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' withdraw() requires a password parameter or a pwd parameter, it must be the funding password, not the API passphrase');
|
|
209659
|
-
}
|
|
210089
|
+
const query = this.omit(params, ['fee']);
|
|
209660
210090
|
const response = await this.privatePostAssetWithdrawal(this.extend(request, query));
|
|
209661
210091
|
//
|
|
209662
210092
|
// {
|
|
@@ -322528,7 +322958,7 @@ SOFTWARE.
|
|
|
322528
322958
|
|
|
322529
322959
|
//-----------------------------------------------------------------------------
|
|
322530
322960
|
// this is updated by vss.js when building
|
|
322531
|
-
const version = '4.2.
|
|
322961
|
+
const version = '4.2.81';
|
|
322532
322962
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
322533
322963
|
//-----------------------------------------------------------------------------
|
|
322534
322964
|
|