Skip to content
Closed
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
7 changes: 6 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PortfolioMarginEndpoints } from './types/portfolio-margin';
import { SavingsEndpoints } from './types/savings';
import { MiningEndpoints } from './types/mining';
import { UtilityEndpoints } from './types/utility';
import { BinanceWebSocket } from './types/websocket';

export interface BinanceRest extends
GenericEndpoints,
Expand All @@ -26,7 +27,9 @@ export interface BinanceRest extends
PortfolioMarginEndpoints,
SavingsEndpoints,
MiningEndpoints,
UtilityEndpoints {}
UtilityEndpoints {
ws: BinanceWebSocket;
}

export * from './types/base';

Expand Down Expand Up @@ -143,6 +146,8 @@ export * from './types/utility';

// } from './types/utility';

export * from './types/websocket';


declare function Binance(options?: BinanceRestClient.BinanceRestOptions): BinanceRest;
export default Binance;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.13.6",
"description": "A node API wrapper for Binance",
"main": "dist",
"types": "index.d.ts",
"browser": {
"crypto": false,
"./dist/http-client.js": "./dist/http-client.js"
Expand Down
57 changes: 57 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,60 @@ export const PayStatus = {
SUCCESS: 'SUCCESS',
FAILED: 'FAILED',
}

export const OrderSide = {
BUY: 'BUY',
SELL: 'SELL',
}

export const OrderType = {
LIMIT: 'LIMIT',
MARKET: 'MARKET',
STOP_LOSS: 'STOP_LOSS',
STOP_LOSS_LIMIT: 'STOP_LOSS_LIMIT',
TAKE_PROFIT: 'TAKE_PROFIT',
TAKE_PROFIT_LIMIT: 'TAKE_PROFIT_LIMIT',
LIMIT_MAKER: 'LIMIT_MAKER',
STOP_MARKET: 'STOP_MARKET',
TAKE_PROFIT_MARKET: 'TAKE_PROFIT_MARKET',
TRAILING_STOP_MARKET: 'TRAILING_STOP_MARKET',
}

export const TimeInForce = {
GTC: 'GTC',
IOC: 'IOC',
FOK: 'FOK',
RPI: 'RPI',
}

export const OrderStatus = {
NEW: 'NEW',
PARTIALLY_FILLED: 'PARTIALLY_FILLED',
FILLED: 'FILLED',
CANCELED: 'CANCELED',
PENDING_CANCEL: 'PENDING_CANCEL',
REJECTED: 'REJECTED',
EXPIRED: 'EXPIRED',
ACCEPTED: 'ACCEPTED',
TRIGGERING: 'TRIGGERING',
TRIGGERED: 'TRIGGERED',
FINISHED: 'FINISHED',
}

export const RateLimitType = {
REQUEST_WEIGHT: 'REQUEST_WEIGHT',
ORDERS: 'ORDERS',
RAW_REQUESTS: 'RAW_REQUESTS',
}

export const RateLimitInterval = {
SECOND: 'SECOND',
MINUTE: 'MINUTE',
HOUR: 'HOUR',
DAY: 'DAY',
}

export const TradingType = {
SPOT: 'SPOT',
MARGIN: 'MARGIN',
}
68 changes: 45 additions & 23 deletions types/futures.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
import { BinanceRestClient, OrderSide, OrderStatus, OrderType, TimeInForce } from './base';

export interface FuturesOrderResponse {
symbol: string;
orderId: number;
orderListId: number;
clientOrderId: string;
transactTime: number;
price: string;
origQty: string;
executedQty: string;
cumQuote: string;
status: OrderStatus;
timeInForce: TimeInForce;
type: OrderType;
side: OrderSide;
marginBuyBorrowAmount: string;
marginBuyBorrowAsset: string;
fills: Array<{
price: string;
qty: string;
commission: string;
commissionAsset: string;
}>;
}

export interface FuturesAlgoOrderResponse {
symbol: string;
algoId: number;
clientAlgoId: string;
transactTime: number;
algoType: string;
side: OrderSide;
type: string;
status: OrderStatus;
}

export interface FuturesEndpoints extends BinanceRestClient {
futuresPing(): Promise<boolean>;
futuresTime(): Promise<{
Expand Down Expand Up @@ -156,34 +191,21 @@ export interface FuturesEndpoints extends BinanceRestClient {
price?: string;
newClientOrderId?: string;
stopPrice?: string;
triggerPrice?: string;
trailingDelta?: number;
trailingTime?: number;
icebergQty?: string;
newOrderRespType?: string;
timeInForce?: TimeInForce;
}): Promise<{
symbol: string;
orderId: number;
orderListId: number;
clientOrderId: string;
transactTime: number;
price: string;
origQty: string;
executedQty: string;
cumQuote: string;
status: OrderStatus;
timeInForce: TimeInForce;
type: OrderType;
side: OrderSide;
marginBuyBorrowAmount: string;
marginBuyBorrowAsset: string;
fills: Array<{
price: string;
qty: string;
commission: string;
commissionAsset: string;
}>;
}>;
positionSide?: 'BOTH' | 'LONG' | 'SHORT';
reduceOnly?: string;
closePosition?: boolean;
workingType?: 'MARK_PRICE' | 'CONTRACT_PRICE';
priceProtect?: string;
activationPrice?: string;
callbackRate?: string;
clientAlgoId?: string;
}): Promise<FuturesOrderResponse | FuturesAlgoOrderResponse>;
futuresUpdateOrder(payload: {
orderId?: number;
origClientOrderId?: string;
Expand Down
Loading
Loading