Skip to content

Commit

Permalink
Add margin capital flow and interest history endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewzolotukhin committed Apr 21, 2024
1 parent 6d27134 commit 947a6b0
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
129 changes: 129 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,36 @@ declare module 'binance-api-node' {
| -2014
| -2015

export type CapitalFlowType =
| 'TRANSFER'
| 'BORROW'
| 'REPAY'
| 'BUY_INCOME'
| 'BUY_EXPENSE'
| 'SELL_INCOME'
| 'SELL_EXPENSE'
| 'TRADING_COMMISSION'
| 'BUY_LIQUIDATION'
| 'SELL_LIQUIDATION'
| 'REPAY_LIQUIDATION'
| 'OTHER_LIQUIDATION'
| 'LIQUIDATION_FEE'
| 'SMALL_BALANCE_CONVERT'
| 'COMMISSION_RETURN'
| 'SMALL_CONVERT'

export type MarginInterestHistory = {
txId: string
interestAccuredTime: number
asset: string
rawAsset?: string
principal: string
interest: string
interestRate: string
type: string
isolatedSymbol: string
}

export const enum ErrorCodes {
UNKNOWN = -1000,
DISCONNECTED = -1001,
Expand Down Expand Up @@ -766,10 +796,48 @@ declare module 'binance-api-node' {
marginRepay(options: MarginBorrowOptions): Promise<{ tranId: number }>
marginLoan(options: MarginBorrowOptions): Promise<{ tranId: number }>
marginAccountInfo(options?: { recvWindow?: number }): Promise<IsolatedCrossAccount>
marginCapitalFlow(options?: {
asset?: string
/**
* Required when querying isolated data
*/
symbol?: string
type?: CapitalFlowType
/**
* Only supports querying the data of the last 90 days
*/
startTime?: number
endTime?: number
fromId?: number
/**
* The number of data items returned each time is limited. Default 500; Max 1000.
*/
limit?: number
recvWindow?: number
}): Promise<
{
id: number
tranId: number
timestamp: number
asset: string
symbol: string
type: CapitalFlowType
amount: number
}[]
>
marginIsolatedAccount(options?: {
symbols?: string
recvWindow?: number
}): Promise<IsolatedMarginAccount>
marginInterestHistory(options: {
asset?: string
isolatedSymbol?: string
startTime?: number
endTime?: number
current?: number
size?: number
timestamp?: number
}): Promise<{ total: number; rows: MarginInterestHistory[] }>
marginMaxBorrow(options: {
asset: string
isolatedSymbol?: string
Expand All @@ -796,6 +864,67 @@ declare module 'binance-api-node' {
privateRequest(method: HttpMethod, url: string, payload: object): Promise<unknown>
disableMarginAccount(options: { symbol: string }): Promise<{ success: boolean; symbol: string }>
enableMarginAccount(options: { symbol: string }): Promise<{ success: boolean; symbol: string }>
isolatedMarginAllPairs(options: {
symbol?: string
}): Promise<
{
base: string
isBuyAllowed: boolean
isMarginTrade: boolean
isSellAllowed: boolean
quote: string
symbol: string
}[]
>
isolatedMarginAccount(options: {
/**
* Max 5 symbols can be sent; separated by ",". e.g. "BTCUSDT,BNBUSDT,ADAUSDT"
*/
symbols?: string
recvWindow?: number
}): Promise<{
assets: {
baseAsset: {
asset: string
borrowEnabled: boolean
borrowed: number
free: number
interest: number
locked: number
netAsset: number
netAssetOfBtc: number
repayEnabled: boolean
totalAsset: number
}
quoteAsset: {
asset: string
borrowEnabled: boolean
borrowed: number
free: number
interest: number
locked: number
netAsset: number
netAssetOfBtc: number
repayEnabled: boolean
totalAsset: number
}
symbol: string
isolatedCreated: boolean
enabled: boolean
marginLevel: number
marginLevelStatus:
| 'EXCESSIVE'
| 'NORMAL'
| 'MARGIN_CALL'
| 'PRE_LIQUIDATION'
| 'FORCE_LIQUIDATION'
marginRatio: number
indexPrice: number
liquidatePrice: number
liquidateRate: number
tradeEnabled: boolean
}[]
}>
getPortfolioMarginAccountInfo(): Promise<{
uniMMR: string
accountEquity: string
Expand Down
4 changes: 4 additions & 0 deletions src/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ export default opts => {
marginMyTrades: payload => privCall('/sapi/v1/margin/myTrades', payload),
marginRepay: payload => privCall('/sapi/v1/margin/repay', payload, 'POST'),
marginLoan: payload => privCall('/sapi/v1/margin/loan', payload, 'POST'),
marginCapitalFlow: payload => privCall('/sapi/v1/margin/capital-flow', payload),
marginInterestHistory: payload => privCall('/sapi/v1/margin/interestHistory', payload),
marginIsolatedAccount: payload => privCall('/sapi/v1/margin/isolated/account', payload),
marginMaxBorrow: payload => privCall('/sapi/v1/margin/maxBorrowable', payload),
marginCreateIsolated: payload => privCall('/sapi/v1/margin/isolated/create', payload, 'POST'),
Expand All @@ -453,6 +455,8 @@ export default opts => {
disableMarginAccount: payload =>
privCall('/sapi/v1/margin/isolated/account', payload, 'DELETE'),
enableMarginAccount: payload => privCall('/sapi/v1/margin/isolated/account', payload, 'POST'),
isolatedMarginAllPairs: payload => privCall('/sapi/v1/margin/isolated/allPairs', payload),
isolatedMarginAccount: payload => privCall('/sapi/v1/margin/isolated/account', payload),
getPortfolioMarginAccountInfo: () => privCall('/sapi/v1/portfolio/account'),

futuresPing: () => pubCall('/fapi/v1/ping').then(() => true),
Expand Down

0 comments on commit 947a6b0

Please sign in to comment.