Merge pull request #359 from JJ-Cro/ReleaseNotes170724

v3.10.12: feat() Add convert endpoints, convert examples, small updates to request/response types
This commit is contained in:
Tiago
2024-07-25 16:58:41 +02:00
committed by GitHub
16 changed files with 305 additions and 10 deletions

1
.gitignore vendored
View File

@@ -24,4 +24,5 @@ bundleReport.html
.history/
rawReq.ts
localtest.sh
localtest.ts

View File

@@ -0,0 +1,18 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.confirmConvertQuote({
quoteTxId: '10100108106409343501030232064',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,16 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getConvertCoins({ accountType: 'eb_convert_spot' })
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,16 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getConvertHistory()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,19 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getConvertStatus({
quoteTxId: 'quoteTransactionId',
accountType: 'eb_convert_funding',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,23 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.requestConvertQuote({
requestId: 'test-00002',
fromCoin: 'ETH',
toCoin: 'BTC',
accountType: 'eb_convert_funding',
requestCoin: 'ETH',
requestAmount: '0.1',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "bybit-api",
"version": "3.10.10",
"version": "3.10.12",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "bybit-api",
"version": "3.10.10",
"version": "3.10.12",
"license": "MIT",
"dependencies": {
"axios": "^1.6.6",

View File

@@ -1,6 +1,6 @@
{
"name": "bybit-api",
"version": "3.10.11",
"version": "3.10.12",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -38,8 +38,8 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.7.0",
"ts-node": "^10.9.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"optionalDependencies": {

View File

@@ -35,6 +35,11 @@ import {
CoinInfoV5,
CollateralInfoV5,
ConfirmNewRiskLimitParamsV5,
ConvertCoinSpecV5,
ConvertCoinsParamsV5,
ConvertHistoryRecordV5,
ConvertQuoteV5,
ConvertStatusV5,
CreateSubApiKeyParamsV5,
CreateSubApiKeyResultV5,
CreateSubMemberParamsV5,
@@ -64,6 +69,7 @@ import {
GetClassicTransactionLogsParamsV5,
GetClosedPnLParamsV5,
GetCoinExchangeRecordParamsV5,
GetConvertHistoryParamsV5,
GetDeliveryPriceParamsV5,
GetDeliveryRecordParamsV5,
GetDepositRecordParamsV5,
@@ -130,6 +136,7 @@ import {
RedeemSpotLeveragedTokenResultV5,
RepayLiabilityParamsV5,
RepayLiabilityResultV5,
RequestConvertQuoteParamsV5,
RiskLimitV5,
SetAutoAddMarginParamsV5,
SetCollateralCoinParamsV5,
@@ -552,6 +559,10 @@ export class RestClientV5 extends BaseRestClient {
*
* If you need to turn it on/off, you can contact your client manager for consultation and application.
* The default time window is 10 seconds.
*
* Only for institutional clients!
*
* If it doesn't work, use v2!
*/
setDisconnectCancelAllWindow(
category: 'option',
@@ -563,6 +574,21 @@ export class RestClientV5 extends BaseRestClient {
});
}
/**
* This endpoint allows you to set the disconnection protect time window. Covers: option (unified account).
*
* If you need to turn it on/off, you can contact your client manager for consultation and application.
* The default time window is 10 seconds.
*
* Only for institutional clients!
*/
setDisconnectCancelAllWindowV2(params: {
product: 'OPTION' | 'SPOT' | 'DERIVATIVES',
timeWindow: number,
}): Promise<APIResponseV3<undefined>> {
return this.postPrivate('/v5/order/disconnected-cancel-all', params);
}
/**
*
****** Position APIs
@@ -1385,6 +1411,68 @@ export class RestClientV5 extends BaseRestClient {
return this.postPrivate('/v5/asset/withdraw/cancel', { id });
}
/**
* Query the coin list of convert from (to).
*/
getConvertCoins(params: ConvertCoinsParamsV5): Promise<
APIResponseV3WithTime<{
coins: ConvertCoinSpecV5[];
}>
> {
return this.getPrivate('/v5/asset/exchange/query-coin-list', params);
}
/**
* Request a quote for converting coins.
*/
requestConvertQuote(
params: RequestConvertQuoteParamsV5,
): Promise<APIResponseV3WithTime<ConvertQuoteV5>> {
return this.postPrivate('/v5/asset/exchange/quote-apply', params);
}
/**
* Confirm a quote for converting coins.
*/
confirmConvertQuote(params: { quoteTxId: string }): Promise<
APIResponseV3WithTime<{
quoteTxId: string;
exchangeStatus: 'init' | 'processing' | 'success' | 'failure';
}>
> {
return this.postPrivate('/v5/asset/exchange/convert-execute', params);
}
/**
* Query the exchange result by sending quoteTxId.
*/
getConvertStatus(params: {
quoteTxId?: string;
accountType:
| 'eb_convert_funding'
| 'eb_convert_uta'
| 'eb_convert_spot'
| 'eb_convert_contract'
| 'eb_convert_inverse';
}): Promise<
APIResponseV3WithTime<{
result: ConvertStatusV5;
}>
> {
return this.getPrivate('/v5/asset/exchange/convert-result-query', params);
}
/**
* Query the conversion history.
*/
getConvertHistory(params?: GetConvertHistoryParamsV5): Promise<
APIResponseV3WithTime<{
list: ConvertHistoryRecordV5[];
}>
> {
return this.getPrivate('/v5/asset/exchange/query-convert-history', params);
}
/**
*
****** User APIs

View File

@@ -124,3 +124,31 @@ export interface WithdrawParamsV5 {
forceChain?: number;
accountType?: 'SPOT' | 'FUND';
}
export interface ConvertCoinsParamsV5 {
coin?: string;
side?: number;
accountType:
| 'eb_convert_funding'
| 'eb_convert_uta'
| 'eb_convert_spot'
| 'eb_convert_contract'
| 'eb_convert_inverse';
}
export interface RequestConvertQuoteParamsV5 {
fromCoin: string;
toCoin: string;
fromCoinType?: string;
toCoinType?: string;
requestCoin: string;
requestAmount: string;
accountType: 'eb_convert_funding' | 'eb_convert_uta' | 'eb_convert_spot' | 'eb_convert_contract' | 'eb_convert_inverse';
requestId?: string;
}
export interface GetConvertHistoryParamsV5 {
accountType?: string;
index?: number;
limit?: number;
}

View File

@@ -1,5 +1,5 @@
export interface GetExchangeBrokerEarningsParamsV5 {
bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS';
bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT';
begin?: string;
end?: string;
uid?: string;

View File

@@ -89,6 +89,8 @@ export interface FeeRateV5 {
export interface AccountInfoV5 {
unifiedMarginStatus: number;
marginMode: AccountMarginModeV5;
isMasterTrader: boolean;
spotHedgingStatus: string;
updatedTime: string;
}
@@ -134,5 +136,3 @@ export interface DCPInfoV5 {
dcpStatus: 'ON';
timeWindow: string;
}

View File

@@ -169,8 +169,74 @@ export interface WithdrawalRecordV5 {
updateTime: string;
}
export interface VaspEntityV5 {
vaspEntityId: string;
vaspName: string;
}
}
export interface ConvertCoinSpecV5 {
coin: string;
fullName: string;
icon: string;
iconNight: string;
accuracyLength: number;
coinType: string;
balance: string;
uBalance: string;
singleFromMinLimit: string;
singleFromMaxLimit: string;
disableFrom: boolean;
disableTo: boolean;
timePeriod: number;
singleToMinLimit: string;
singleToMaxLimit: string;
dailyFromMinLimit: string;
dailyFromMaxLimit: string;
dailyToMinLimit: string;
dailyToMaxLimit: string;
}
export interface ConvertQuoteV5 {
quoteTxId: string;
exchangeRate: string;
fromCoin: string;
fromCoinType: string;
toCoin: string;
toCoinType: string;
fromAmount: string;
toAmount: string;
expiredTime: string;
requestId: string;
}
export interface ConvertStatusV5 {
accountType: string;
exchangeTxId: string;
userId: string;
fromCoin: string;
fromCoinType: string;
toCoin: string;
toCoinType: string;
fromAmount: string;
toAmount: string;
exchangeStatus: 'init' | 'processing' | 'success' | 'failure';
extInfo: object;
convertRate: string;
createdAt: string;
}
export interface ConvertHistoryRecordV5 {
accountType: string;
exchangeTxId: string;
userId: string;
fromCoin: string;
fromCoinType: string;
toCoin: string;
toCoinType: string;
fromAmount: string;
toAmount: string;
exchangeStatus: 'init' | 'processing' | 'success' | 'failure';
extInfo: object;
convertRate: string;
createdAt: string;
}

View File

@@ -1,6 +1,6 @@
interface EarningDetailV5 {
userId: string;
bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS';
bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS' | 'CONVERT';
symbol: string;
coin: string;
earning: string;
@@ -20,6 +20,7 @@ export interface ExchangeBrokerEarningResultV5 {
spot: TotalEarningCategoryV5[];
derivatives: TotalEarningCategoryV5[];
options: TotalEarningCategoryV5[];
convert: TotalEarningCategoryV5[];
total: TotalEarningCategoryV5[];
};
details: EarningDetailV5[];
@@ -36,6 +37,7 @@ export interface ExchangeBrokerAccountInfoV5 {
markupFeeRebateRate: {
spot: string;
derivatives: string;
convert: string;
};
ts: string;
}

View File

@@ -75,6 +75,20 @@ export interface LinearInverseInstrumentInfoV5 {
copyTrading: CopyTradingV5;
upperFundingRate: string;
lowerFundingRate: string;
isPreListing: boolean;
preListingInfo: {
curAuctionPhase: string;
phases: {
phase: string;
startTime: string;
endTime: string;
}[];
auctionFeeInfo: {
auctionFeeRate: string;
takerFeeRate: string;
makerFeeRate: string;
};
} | null;
}
export interface OptionInstrumentInfoV5 {
@@ -170,6 +184,9 @@ export interface TickerLinearInverseV5 {
bid1Price: string;
ask1Price: string;
bid1Size: string;
preOpenPrice: string;
preQty: string;
curPreListingPhase: string;
}
export interface TickerOptionV5 {

View File

@@ -11,6 +11,7 @@ export type InstrumentStatusV5 =
| 'Settling'
| 'Delivering'
| 'Closed';
export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly';