feat(): add samples for account endpoints. Breaking change: getFeeRate takes an object
This commit is contained in:
3
examples/apidoc/V5/Account/README.md
Normal file
3
examples/apidoc/V5/Account/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# V5 - REST - Account
|
||||
|
||||
https://bybit-exchange.github.io/docs/v5/account/wallet-balance
|
||||
16
examples/apidoc/V5/Account/get-account-info.js
Normal file
16
examples/apidoc/V5/Account/get-account-info.js
Normal 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);
|
||||
});
|
||||
16
examples/apidoc/V5/Account/get-coin-greeks.js
Normal file
16
examples/apidoc/V5/Account/get-coin-greeks.js
Normal 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);
|
||||
});
|
||||
16
examples/apidoc/V5/Account/get-collateral-info.js
Normal file
16
examples/apidoc/V5/Account/get-collateral-info.js
Normal 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);
|
||||
});
|
||||
19
examples/apidoc/V5/Account/get-fee-rate.js
Normal file
19
examples/apidoc/V5/Account/get-fee-rate.js
Normal 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);
|
||||
});
|
||||
16
examples/apidoc/V5/Account/get-mmp-state.js
Normal file
16
examples/apidoc/V5/Account/get-mmp-state.js
Normal 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);
|
||||
});
|
||||
20
examples/apidoc/V5/Account/get-transaction-log.js
Normal file
20
examples/apidoc/V5/Account/get-transaction-log.js
Normal 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);
|
||||
});
|
||||
19
examples/apidoc/V5/Account/get-wallet-balance.js
Normal file
19
examples/apidoc/V5/Account/get-wallet-balance.js
Normal 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);
|
||||
});
|
||||
16
examples/apidoc/V5/Account/reset-mmp.js
Normal file
16
examples/apidoc/V5/Account/reset-mmp.js
Normal 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);
|
||||
});
|
||||
16
examples/apidoc/V5/Account/set-margin-mode.js
Normal file
16
examples/apidoc/V5/Account/set-margin-mode.js
Normal 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);
|
||||
});
|
||||
22
examples/apidoc/V5/Account/set-mmp.js
Normal file
22
examples/apidoc/V5/Account/set-mmp.js
Normal 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);
|
||||
});
|
||||
16
examples/apidoc/V5/Account/upgrade-to-unified-account.js
Normal file
16
examples/apidoc/V5/Account/upgrade-to-unified-account.js
Normal 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);
|
||||
});
|
||||
@@ -57,6 +57,7 @@ import {
|
||||
GetDeliveryRecordParamsV5,
|
||||
GetDepositRecordParamsV5,
|
||||
GetExecutionListParamsV5,
|
||||
GetFeeRateParamsV5,
|
||||
GetFundingRateHistoryParamsV5,
|
||||
GetHistoricalVolatilityParamsV5,
|
||||
GetIndexPriceKlineParamsV5,
|
||||
@@ -767,16 +768,13 @@ export class RestClientV5 extends BaseRestClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the trading fee rate of derivatives.
|
||||
* Covers: USDT perpetual / Inverse perpetual / Inverse futures
|
||||
* Get the trading fee rate.
|
||||
* Covers: Spot / USDT perpetual / Inverse perpetual / Inverse futures / Options
|
||||
*/
|
||||
getFeeRate(
|
||||
symbol?: string,
|
||||
): Promise<APIResponseV3WithTime<{ list: FeeRateV5[] }>> {
|
||||
return this.getPrivate(
|
||||
'/v5/account/fee-rate',
|
||||
symbol ? { symbol } : undefined,
|
||||
);
|
||||
params: GetFeeRateParamsV5,
|
||||
): Promise<APIResponseV3WithTime<CategoryCursorListV5<FeeRateV5[]>>> {
|
||||
return this.getPrivate('/v5/account/fee-rate', params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,12 @@ export interface GetBorrowHistoryParamsV5 {
|
||||
cursor?: string;
|
||||
}
|
||||
|
||||
export interface GetFeeRateParamsV5 {
|
||||
category: CategoryV5;
|
||||
symbol?: string;
|
||||
baseCoin?: string;
|
||||
}
|
||||
|
||||
export interface GetTransactionLogParamsV5 {
|
||||
accountType?: AccountTypeV5;
|
||||
category?: CategoryV5;
|
||||
|
||||
@@ -78,6 +78,7 @@ export interface CoinGreeksV5 {
|
||||
|
||||
export interface FeeRateV5 {
|
||||
symbol: string;
|
||||
baseCoin: string;
|
||||
takerFeeRate: string;
|
||||
makerFeeRate: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user