diff --git a/examples/apidoc/V5/Market/README.md b/examples/apidoc/V5/Market/README.md new file mode 100644 index 0000000..5df9ee0 --- /dev/null +++ b/examples/apidoc/V5/Market/README.md @@ -0,0 +1,3 @@ +# V5 - REST - Market + +https://bybit-exchange.github.io/docs/v5/market/kline diff --git a/examples/apidoc/V5/Market/get-delivery-price.js b/examples/apidoc/V5/Market/get-delivery-price.js new file mode 100644 index 0000000..342a578 --- /dev/null +++ b/examples/apidoc/V5/Market/get-delivery-price.js @@ -0,0 +1,17 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getTickers({ + category: 'inverse', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-funding-rate-history.js b/examples/apidoc/V5/Market/get-funding-rate-history.js new file mode 100644 index 0000000..cbc3197 --- /dev/null +++ b/examples/apidoc/V5/Market/get-funding-rate-history.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getFundingRateHistory({ + category: 'linear', + symbol: 'ETHPERP', + limit: 1, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-historical-volatility.js b/examples/apidoc/V5/Market/get-historical-volatility.js new file mode 100644 index 0000000..34221ad --- /dev/null +++ b/examples/apidoc/V5/Market/get-historical-volatility.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getHistoricalVolatility({ + category: 'option', + baseCoin: 'ETH', + period: 30, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-instruments-info.js b/examples/apidoc/V5/Market/get-instruments-info.js new file mode 100644 index 0000000..e42efc2 --- /dev/null +++ b/examples/apidoc/V5/Market/get-instruments-info.js @@ -0,0 +1,17 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getInstrumentsInfo({ + category: 'linear', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-insurance.js b/examples/apidoc/V5/Market/get-insurance.js new file mode 100644 index 0000000..099318e --- /dev/null +++ b/examples/apidoc/V5/Market/get-insurance.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getInsurance({ + coin: 'ETH', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-kline-index-price.js b/examples/apidoc/V5/Market/get-kline-index-price.js new file mode 100644 index 0000000..cc898de --- /dev/null +++ b/examples/apidoc/V5/Market/get-kline-index-price.js @@ -0,0 +1,21 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getIndexPriceKline({ + category: 'inverse', + symbol: 'BTCUSDZ22', + interval: '1', + start: 1670601600000, + end: 1670608800000, + limit: 2, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-kline-mark-price.js b/examples/apidoc/V5/Market/get-kline-mark-price.js new file mode 100644 index 0000000..f155efa --- /dev/null +++ b/examples/apidoc/V5/Market/get-kline-mark-price.js @@ -0,0 +1,21 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getMarkPriceKline({ + category: 'linear', + symbol: 'BTCUSD', + interval: '15', + start: 1670601600000, + end: 1670608800000, + limit: 1, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-kline-premium-index-price.js b/examples/apidoc/V5/Market/get-kline-premium-index-price.js new file mode 100644 index 0000000..9915c0c --- /dev/null +++ b/examples/apidoc/V5/Market/get-kline-premium-index-price.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getPremiumIndexPriceKline({ + category: 'linear', + symbol: 'BTCUSDT', + interval: 'D', + start: 1652112000000, + end: 1652544000000, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-kline.js b/examples/apidoc/V5/Market/get-kline.js new file mode 100644 index 0000000..48d4758 --- /dev/null +++ b/examples/apidoc/V5/Market/get-kline.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getKline({ + category: 'inverse', + symbol: 'BTCUSD', + interval: '60', + start: 1670601600000, + end: 1670608800000, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-open-interest.js b/examples/apidoc/V5/Market/get-open-interest.js new file mode 100644 index 0000000..3777ba0 --- /dev/null +++ b/examples/apidoc/V5/Market/get-open-interest.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getOpenInterest({ + category: 'inverse', + symbol: 'BTCUSD', + intervalTime: '5min', + startTime: 1669571100000, + endTime: 1669571400000, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-orderbook.js b/examples/apidoc/V5/Market/get-orderbook.js new file mode 100644 index 0000000..ba91994 --- /dev/null +++ b/examples/apidoc/V5/Market/get-orderbook.js @@ -0,0 +1,17 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getOrderbook({ + category: 'linear', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-public-trading-history.js b/examples/apidoc/V5/Market/get-public-trading-history.js new file mode 100644 index 0000000..939004a --- /dev/null +++ b/examples/apidoc/V5/Market/get-public-trading-history.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getPublicTradingHistory({ + category: 'spot', + symbol: 'BTCUSDT', + limit: 1, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-risk-limit.js b/examples/apidoc/V5/Market/get-risk-limit.js new file mode 100644 index 0000000..1d2a500 --- /dev/null +++ b/examples/apidoc/V5/Market/get-risk-limit.js @@ -0,0 +1,17 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getRiskLimit({ + category: 'inverse', + symbol: 'BTCUSD', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-tickers.js b/examples/apidoc/V5/Market/get-tickers.js new file mode 100644 index 0000000..342a578 --- /dev/null +++ b/examples/apidoc/V5/Market/get-tickers.js @@ -0,0 +1,17 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getTickers({ + category: 'inverse', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Trade/README.md b/examples/apidoc/V5/Trade/README.md new file mode 100644 index 0000000..a9f1327 --- /dev/null +++ b/examples/apidoc/V5/Trade/README.md @@ -0,0 +1,3 @@ +# V5 - REST - Trade + +https://bybit-exchange.github.io/docs/v5/order/create-order diff --git a/examples/apidoc/typescripttest.ts b/examples/apidoc/typescripttest.ts new file mode 100644 index 0000000..53410e0 --- /dev/null +++ b/examples/apidoc/typescripttest.ts @@ -0,0 +1,19 @@ +import { RestClientV5 } from '../../src'; + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getDeliveryPrice({ + category: 'option', + symbol: 'ETH-26DEC22-1400-C"', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 64d66af..12f099e 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -35,6 +35,7 @@ import { CreateSubMemberParamsV5, CreateSubMemberResultV5, CursorListV5, + DeliveryPriceV5, DeliveryRecordV5, DepositAddressResultV5, DepositRecordV5, @@ -50,6 +51,7 @@ import { GetBorrowHistoryParamsV5, GetClosedPnLParamsV5, GetCoinExchangeRecordParamsV5, + GetDeliveryPriceParamsV5, GetDeliveryRecordParamsV5, GetDepositRecordParamsV5, GetExecutionListParamsV5, @@ -333,6 +335,8 @@ export class RestClientV5 extends BaseRestClient { * Get the delivery price for option * * Covers: Option + * + * @deprecated use getDeliveryPrice() instead */ getOptionDeliveryPrice( params: GetOptionDeliveryPriceParamsV5, @@ -342,6 +346,17 @@ export class RestClientV5 extends BaseRestClient { return this.get('/v5/market/delivery-price', params); } + /** + * Get the delivery price of Inverse futures, USDC futures and Options + * + * Covers: USDC futures / Inverse futures / Option + */ + getDeliveryPrice( + params: GetDeliveryPriceParamsV5, + ): Promise>> { + return this.get('/v5/market/delivery-price', params); + } + /** * ****** Trade APIs diff --git a/src/types/request/v5-market.ts b/src/types/request/v5-market.ts index 9b118bb..0fe9f0c 100644 --- a/src/types/request/v5-market.ts +++ b/src/types/request/v5-market.ts @@ -1,5 +1,5 @@ import { KlineIntervalV3 } from '../shared'; -import { CategoryV5, OptionTypeV5 } from '../v5-shared'; +import { CategoryV5, InstrumentStatusV5, OptionTypeV5 } from '../v5-shared'; export interface GetKlineParamsV5 { category: 'spot' | 'linear' | 'inverse'; @@ -40,6 +40,7 @@ export interface GetPremiumIndexPriceKlineParamsV5 { export interface GetInstrumentsInfoParamsV5 { category: CategoryV5; symbol?: string; + status?: InstrumentStatusV5; baseCoin?: string; limit?: number; cursor?: string; @@ -95,7 +96,7 @@ export interface GetOpenInterestParamsV5 { export interface GetHistoricalVolatilityParamsV5 { category: 'option'; baseCoin?: string; - period?: number; + period?: 7 | 14 | 21 | 30 | 60 | 90 | 180 | 270; startTime?: number; endTime?: number; } @@ -116,3 +117,11 @@ export interface GetOptionDeliveryPriceParamsV5 { limit?: number; cursor?: string; } + +export interface GetDeliveryPriceParamsV5 { + category: 'linear' | 'inverse' | 'option'; + symbol?: string; + baseCoin?: string; + limit?: number; + cursor?: string; +} diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index c657871..5411b56 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -24,7 +24,7 @@ export type OHLCVKlineV5 = [ string, string, string, - string + string, ]; /** @@ -257,8 +257,15 @@ export interface RiskLimitV5 { maxLeverage: string; } +/** @deprecated use DeliveryPriceV5 instead */ export interface OptionDeliveryPriceV5 { symbol: string; deliveryPrice: string; deliveryTime: string; } + +export interface DeliveryPriceV5 { + symbol: string; + deliveryPrice: string; + deliveryTime: string; +} diff --git a/src/types/v5-shared.ts b/src/types/v5-shared.ts index c297e21..53f3825 100644 --- a/src/types/v5-shared.ts +++ b/src/types/v5-shared.ts @@ -4,7 +4,12 @@ export type ContractTypeV5 = | 'LinearPerpetual' | 'InverseFutures'; -export type InstrumentStatusV5 = 'Pending' | 'Trading' | 'Settling' | 'Closed'; +export type InstrumentStatusV5 = + | 'PreLaunch' + | 'Trading' + | 'Settling' + | 'Delivering' + | 'Closed'; export type OrderFilterV5 = 'Order' | 'tpslOrder'; export type OrderSideV5 = 'Buy' | 'Sell';