Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper types for futuresExchangeInfo #649

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
node_modules/
.nyc_output/
dist/

.vscode/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(all changes of gitignore)

.yarn/
.yarnrc
.env
.idea
205 changes: 196 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ declare module 'binance-api-node' {
): Promise<UniversalTransferHistoryResponse>
futuresPing(): Promise<boolean>
futuresTime(): Promise<number>
futuresExchangeInfo(): Promise<ExchangeInfo<FuturesOrderType_LT>>
futuresExchangeInfo(): Promise<FuturesExchangeInfo>
futuresBook(options: { symbol: string; limit?: number }): Promise<OrderBook>
futuresCandles(options: CandlesOptions): Promise<CandleChartResult[]>
futuresMarkPriceCandles(options: CandlesOptions): Promise<CandleChartResult[]>
Expand Down Expand Up @@ -995,11 +995,12 @@ declare module 'binance-api-node' {
limit: number
}

export type ExchangeFilterType_LT = 'EXCHANGE_MAX_NUM_ORDERS' | 'EXCHANGE_MAX_ALGO_ORDERS'
export type ExchangeFilterType_LT = 'EXCHANGE_MAX_NUM_ORDERS' | 'EXCHANGE_MAX_NUM_ALGO_ORDERS' | 'EXCHANGE_MAX_NUM_ICEBERG_ORDERS'

export const enum ExchangeFilterType {
EXCHANGE_MAX_NUM_ORDERS = 'EXCHANGE_MAX_NUM_ORDERS',
EXCHANGE_MAX_ALGO_ORDERS = 'EXCHANGE_MAX_ALGO_ORDERS',
EXCHANGE_MAX_NUM_ALGO_ORDERS = 'EXCHANGE_MAX_NUM_ALGO_ORDERS',
EXCHANGE_MAX_NUM_ICEBERG_ORDERS = 'EXCHANGE_MAX_NUM_ICEBERG_ORDERS',
}

export interface ExchangeFilter {
Expand All @@ -1010,19 +1011,32 @@ declare module 'binance-api-node' {
export type SymbolFilterType_LT =
| 'PRICE_FILTER'
| 'PERCENT_PRICE'
| 'PERCENT_PRICE_BY_SIDE'
| 'LOT_SIZE'
| 'MARKET_LOT_SIZE'
| 'MIN_NOTIONAL'
| 'NOTIONAL'
| 'MAX_NUM_ORDERS'
| 'MAX_ALGO_ORDERS'
| 'MAX_NUM_ALGO_ORDERS'
| 'MAX_NUM_ICEBERG_ORDERS'
| 'ICEBERG_PARTS'
| 'MAX_POSITION'
| 'TRAILING_DELTA'

export const enum SymbolFilterType {
PRICE_FILTER = 'PRICE_FILTER',
PERCENT_PRICE = 'PERCENT_PRICE',
PERCENT_PRICE_BY_SIDE = 'PERCENT_PRICE_BY_SIDE',
LOT_SIZE = 'LOT_SIZE',
MARKET_LOT_SIZE = 'MARKET_LOT_SIZE',
MIN_NOTIONAL = 'MIN_NOTIONAL',
NOTIONAL = 'NOTIONAL',
MAX_NUM_ORDERS = 'MAX_NUM_ORDERS',
MAX_ALGO_ORDERS = 'MAX_ALGO_ORDERS',
MAX_NUM_ALGO_ORDERS = 'MAX_NUM_ALGO_ORDERS',
MAX_NUM_ICEBERG_ORDERS = 'MAX_NUM_ICEBERG_ORDERS',
ICEBERG_PARTS = 'ICEBERG_PARTS',
MAX_POSITION = 'MAX_POSITION',
TRAILING_DELTA = 'TRAILING_DELTA',
}

export interface SymbolPriceFilter {
Expand Down Expand Up @@ -1055,27 +1069,74 @@ declare module 'binance-api-node' {

export interface SymbolMinNotionalFilter {
filterType: SymbolFilterType.MIN_NOTIONAL
notional: string
minNotional: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennycode what's the consensus on this one? Pretty sure there's a lot of back and forth on this which might be due to the fact the field changes depending on which endpoint is hit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp, that's why there is now a FuturesSymbolMinNotionalFilter and a SymbolMinNotionalFilter. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually you were part of the original convo, my bad

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha thank you for the confirmation

}

export interface SymbolMaxNumOrdersFilter {
filterType: SymbolFilterType.MAX_NUM_ORDERS
maxNumOrders: number
}

export interface SymbolMaxAlgoOrdersFilter {
filterType: SymbolFilterType.MAX_ALGO_ORDERS
export interface SymbolMaxNumAlgoOrdersFilter {
filterType: SymbolFilterType.MAX_NUM_ALGO_ORDERS
maxNumAlgoOrders: number
}

export interface SymbolPercentPricePerSideFilter {
filterType: SymbolFilterType.PERCENT_PRICE_BY_SIDE
bidMultiplierUp: string
bidMultiplierDown: string
askMultiplierUp: string
askMultiplierDown: string
avgPriceMins: number
}

export interface SymbolNotionalFilter {
filterType: SymbolFilterType.NOTIONAL
minNotional: string
applyMinToMarket: boolean
maxNotional: string
applyMaxToMarket: boolean
avgPriceMins: number
}

export interface SymbolMaxNumIcebergOrdersFilter {
filterType: SymbolFilterType.MAX_NUM_ICEBERG_ORDERS
maxNumIcebergOrders: number
}

export interface SymbolIcebergPartsFilter {
filterType: SymbolFilterType.ICEBERG_PARTS
limit: number
}

export interface SymbolMaxPositionFilter {
filterType: SymbolFilterType.MAX_POSITION
maxPosition: string
}

export interface SymbolTrailingDeltaFilter {
filterType: SymbolFilterType.TRAILING_DELTA
minTrailingAboveDelta: number
maxTrailingAboveDelta: number
minTrailingBelowDelta: number
maxTrailingBelowDelta: number
}

export type SymbolFilter =
| SymbolPriceFilter
| SymbolPercentPriceFilter
| SymbolPercentPricePerSideFilter
| SymbolLotSizeFilter
| SymbolMarketLotSizeFilter
| SymbolMinNotionalFilter
| SymbolNotionalFilter
| SymbolMaxNumOrdersFilter
| SymbolMaxAlgoOrdersFilter
| SymbolMaxNumAlgoOrdersFilter
| SymbolMaxNumIcebergOrdersFilter
| SymbolIcebergPartsFilter
| SymbolMaxPositionFilter
| SymbolTrailingDeltaFilter

export interface Symbol<T = OrderType_LT> {
baseAsset: string
Expand Down Expand Up @@ -1113,6 +1174,111 @@ declare module 'binance-api-node' {
bids: Bid[]
}

export const enum FuturesSymbolFilterType {
PRICE_FILTER = 'PRICE_FILTER',
LOT_SIZE = 'LOT_SIZE',
MARKET_LOT_SIZE = 'MARKET_LOT_SIZE',
MAX_NUM_ORDERS = 'MAX_NUM_ORDERS',
MAX_NUM_ALGO_ORDERS = 'MAX_NUM_ALGO_ORDERS',
PERCENT_PRICE = 'PERCENT_PRICE',
MIN_NOTIONAL = 'MIN_NOTIONAL',
}

export interface FuturesSymbolPriceFilter {
filterType: FuturesSymbolFilterType.PRICE_FILTER
minPrice: string
maxPrice: string
tickSize: string
}

export interface FuturesSymbolLotSizeFilter {
filterType: FuturesSymbolFilterType.LOT_SIZE
minQty: string
maxQty: string
stepSize: string
}

export interface FuturesSymbolMarketLotSizeFilter {
filterType: FuturesSymbolFilterType.MARKET_LOT_SIZE
minQty: string
maxQty: string
stepSize: string
}

export interface FuturesSymbolPercentPriceFilter {
filterType: FuturesSymbolFilterType.PERCENT_PRICE
multiplierDown: string
multiplierUp: string
multiplierDecimal: number
}

export interface FuturesSymbolMinNotionalFilter {
filterType: FuturesSymbolFilterType.MIN_NOTIONAL
notional: string
}

export interface FuturesSymbolMaxNumOrdersFilter {
filterType: FuturesSymbolFilterType.MAX_NUM_ORDERS
limit: number
}

export interface FuturesSymbolMaxAlgoOrdersFilter {
filterType: FuturesSymbolFilterType.MAX_NUM_ALGO_ORDERS
limit: number
}

export type FuturesSymbolFilter =
| FuturesSymbolPriceFilter
| FuturesSymbolLotSizeFilter
| FuturesSymbolMarketLotSizeFilter
| FuturesSymbolMaxNumOrdersFilter
| FuturesSymbolMaxAlgoOrdersFilter
| FuturesSymbolPercentPriceFilter
| FuturesSymbolMinNotionalFilter

export interface FuturesSymbol {
baseAsset: string
baseAssetPrecision: number
contractType: FuturesContractType,
deliveryDate: number
filters: FuturesSymbolFilter[],
liquidationFee: string
maintMarginPercent: string
marginAsset: string
marketTakeBound: string
maxMoveOrderLimit: number
onboardDate: number
orderTypes: FuturesOrderType_LT
pair: string
pricePrecision: number
quantityPrecision: number
quoteAsset: string
quotePrecision: number
requiredMarginPercent: string
settlePlan: number
status: FuturesContractStatus
symbol: string
timeInForce: FuturesTimeInForce
triggerProtect: string
underlyingType: string
underlyingSubType: string[]
}

export interface FuturesAsset_EI {
asset: string
marginAvailable: boolean
autoAssetExchange: string
}

export interface FuturesExchangeInfo {
timezone: string
serverTime: number
rateLimits: ExchangeInfoRateLimit[]
exchangeFilters: ExchangeFilter[]
assets: FuturesAsset_EI[]
symbols: FuturesSymbol[]
}

interface NewFuturesOrderBase {
symbol: string
side: OrderSide_LT
Expand Down Expand Up @@ -1420,6 +1586,25 @@ declare module 'binance-api-node' {
TRAILING_STOP_MARKET = 'TRAILING_STOP_MARKET',
}

export type FuturesContractType =
| 'PERPETUAL'
| 'CURRENT_MONTH'
| 'NEXT_MONTH'
| 'CURRENT_QUARTER'
| 'NEXT_QUARTER'
| 'PERPETUAL_DELIVERING'

export type FuturesContractStatus =
| 'PENDING_TRADING'
| 'TRADING'
| 'PRE_DELIVERING'
| 'DELIVERING'
| 'DELIVERED'
| 'PRE_SETTLE'
| 'SETTLING'
| 'CLOSE'


export type NewOrderRespType_LT = 'ACK' | 'RESULT' | 'FULL'

export const enum NewOrderRespType {
Expand All @@ -1430,6 +1615,8 @@ declare module 'binance-api-node' {

export type TimeInForce_LT = 'GTC' | 'IOC' | 'FOK' | 'GTE_GTC'

export type FuturesTimeInForce = 'GTC' | 'IOC' | 'FOK' | 'GTX' | 'GTD'

export const enum TimeInForce {
GTC = 'GTC',
IOC = 'IOC',
Expand Down
Loading