feat(): add samples for account endpoints. Breaking change: getFeeRate takes an object

This commit is contained in:
tiagosiebler
2023-06-09 10:33:00 +01:00
parent 1577764392
commit 6dbbecb9a5
15 changed files with 208 additions and 8 deletions

View File

@@ -0,0 +1,3 @@
# V5 - REST - Account
https://bybit-exchange.github.io/docs/v5/account/wallet-balance

View File

@@ -0,0 +1,16 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getAccountInfo()
.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
.getCoinGreeks('BTC')
.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
.getCollateralInfo('BTC')
.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
.getFeeRate({
category: 'linear',
symbol: 'ETHUSDT',
})
.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
.getMMPState('ETH')
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,20 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getTransactionLog({
accountType: 'UNIFIED',
category: 'linear',
currency: 'USDT',
})
.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
.getWalletBalance({
accountType: 'UNIFIED',
coin: 'BTC',
})
.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
.resetMMP('ETH')
.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
.setMarginMode('PORTFOLIO_MARGIN')
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -0,0 +1,22 @@
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setMMP({
baseCoin: 'ETH',
window: '5000',
frozenPeriod: '100000',
qtyLimit: '50',
deltaLimit: '20',
})
.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
.upgradeToUnifiedAccount()
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});

View File

@@ -57,6 +57,7 @@ import {
GetDeliveryRecordParamsV5, GetDeliveryRecordParamsV5,
GetDepositRecordParamsV5, GetDepositRecordParamsV5,
GetExecutionListParamsV5, GetExecutionListParamsV5,
GetFeeRateParamsV5,
GetFundingRateHistoryParamsV5, GetFundingRateHistoryParamsV5,
GetHistoricalVolatilityParamsV5, GetHistoricalVolatilityParamsV5,
GetIndexPriceKlineParamsV5, GetIndexPriceKlineParamsV5,
@@ -767,16 +768,13 @@ export class RestClientV5 extends BaseRestClient {
} }
/** /**
* Get the trading fee rate of derivatives. * Get the trading fee rate.
* Covers: USDT perpetual / Inverse perpetual / Inverse futures * Covers: Spot / USDT perpetual / Inverse perpetual / Inverse futures / Options
*/ */
getFeeRate( getFeeRate(
symbol?: string, params: GetFeeRateParamsV5,
): Promise<APIResponseV3WithTime<{ list: FeeRateV5[] }>> { ): Promise<APIResponseV3WithTime<CategoryCursorListV5<FeeRateV5[]>>> {
return this.getPrivate( return this.getPrivate('/v5/account/fee-rate', params);
'/v5/account/fee-rate',
symbol ? { symbol } : undefined,
);
} }
/** /**

View File

@@ -13,6 +13,12 @@ export interface GetBorrowHistoryParamsV5 {
cursor?: string; cursor?: string;
} }
export interface GetFeeRateParamsV5 {
category: CategoryV5;
symbol?: string;
baseCoin?: string;
}
export interface GetTransactionLogParamsV5 { export interface GetTransactionLogParamsV5 {
accountType?: AccountTypeV5; accountType?: AccountTypeV5;
category?: CategoryV5; category?: CategoryV5;

View File

@@ -78,6 +78,7 @@ export interface CoinGreeksV5 {
export interface FeeRateV5 { export interface FeeRateV5 {
symbol: string; symbol: string;
baseCoin: string;
takerFeeRate: string; takerFeeRate: string;
makerFeeRate: string; makerFeeRate: string;
} }