Skip to content

Commit

Permalink
0.3.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
alplabin committed Apr 4, 2024
1 parent 757fe72 commit 8d32673
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 125 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
## 0.3.7 - 2024-04-04

### Changed
- Update types
- Update dependencies
- Add logger class
- Fix issue #14: Add new `WebsocketStream` type
- Fix issue #16: Update parameters of `GET /api/v3/ticker/tradingDay`
- Fix issue #18: Multiple websocket streams subscription are now handled

## 0.3.6 - 2024-01-24

Expand Down
3 changes: 2 additions & 1 deletion examples/restful/market/tradingDayTicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const baseURL = process.env.BINANCE_BASE_URL || '';
const client = new Spot('', '', { baseURL: baseURL });

const options: RestMarketTypes.tradingDayTickerOptions = {
symbol: 'BNBUSDT',
type: 'MINI',
};

client.tradingDayTicker('BNBUSDT', options).then((res: RestMarketTypes.tradingDayTickerResponse | RestMarketTypes.tradingDayTickerResponse[]) => {
client.tradingDayTicker(options).then((res: RestMarketTypes.tradingDayTickerResponse | RestMarketTypes.tradingDayTickerResponse[]) => {
console.log(res);
}).catch(err => { console.log(err); });
13 changes: 13 additions & 0 deletions examples/websocketStream/multiSubscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { WebsocketStream } from '../../src/index';

const callbacks = {
open: () => console.debug('Connected to WebSocket server'),
close: () => console.debug('Disconnected from WebSocket server'),
message: (data: string) => console.info(data)
};

const websocketStreamClient = new WebsocketStream({ callbacks });

websocketStreamClient.subscribe(['bnbusdt@depth', 'btcusdt@depth']);

setTimeout(() => websocketStreamClient.disconnect(), 6000);
36 changes: 18 additions & 18 deletions src/modules/restful/margin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface marginAccountNewOrderResponse {
fills?: marginAccountNewOrderFills[];
}

interface marginAccountNewOrderFills {
export interface marginAccountNewOrderFills {
price: string;
qty: string;
commission: string;
Expand Down Expand Up @@ -165,7 +165,7 @@ export interface getCrossMarginTransferHistoryResponse {
total: number;
}

interface getCrossMarginTransferHistoryRows {
export interface getCrossMarginTransferHistoryRows {
amount: string;
asset: string;
status: MarginStatus;
Expand Down Expand Up @@ -195,7 +195,7 @@ export interface getInterestHistoryResponse {
total: number;
}

interface getInterestHistoryRows {
export interface getInterestHistoryRows {
txId: bigint;
interestAccuredTime: number;
asset: string;
Expand All @@ -221,7 +221,7 @@ export interface getForceLiquidationRecordResponse {
total: number;
}

interface getForceLiquidationRecordRows {
export interface getForceLiquidationRecordRows {
avgPrice: string;
executedQty: string;
orderId: number;
Expand Down Expand Up @@ -250,7 +250,7 @@ export interface getCrossMarginAccountDetailsResponse {
userAssets: getCrossMarginAccountDetailsUserassets[];
}

interface getCrossMarginAccountDetailsUserassets {
export interface getCrossMarginAccountDetailsUserassets {
asset: string;
borrowed: string;
free: string;
Expand Down Expand Up @@ -375,13 +375,13 @@ export interface marginAccountNewOcoResponse {
orderReports: marginAccountNewOcoOrderreports[];
}

interface marginAccountNewOcoOrders {
export interface marginAccountNewOcoOrders {
symbol: string;
orderId: number;
clientOrderId: string;
}

interface marginAccountNewOcoOrderreports {
export interface marginAccountNewOcoOrderreports {
symbol: string;
orderId: number;
orderListId: number;
Expand Down Expand Up @@ -420,13 +420,13 @@ export interface marginAccountCancelOcoResponse {
orderReports: marginAccountCancelOcoOrderReports[];
}

interface marginAccountCancelOcoOrders {
export interface marginAccountCancelOcoOrders {
symbol: string;
orderId: number;
clientOrderId: string;
}

interface marginAccountCancelOcoOrderReports {
export interface marginAccountCancelOcoOrderReports {
symbol: string;
origClientOrderId: string;
orderId: number;
Expand Down Expand Up @@ -464,7 +464,7 @@ export interface getMarginAccountOcoResponse {
orders: getMarginAccountOcoOrders[];
}

interface getMarginAccountOcoOrders {
export interface getMarginAccountOcoOrders {
symbol: string;
orderId: number;
clientOrderId: string;
Expand Down Expand Up @@ -492,7 +492,7 @@ export interface getMarginAccountAllOcoResponse {
orders: getMarginAccountAllOcoOrders[];
}

interface getMarginAccountAllOcoOrders {
export interface getMarginAccountAllOcoOrders {
symbol: string;
orderId: number;
clientOrderId: string;
Expand All @@ -517,7 +517,7 @@ export interface getMarginAccountOpenOcoResponse {
}


interface getMarginAccountOpenOcoOrders {
export interface getMarginAccountOpenOcoOrders {
symbol: string;
orderId: number;
clientOrderId: string;
Expand Down Expand Up @@ -589,7 +589,7 @@ export interface getIsolatedMarginAccountInfoResponse {
totalNetAssetOfBtc?: string;
}

interface getIsolatedMarginAccountInfoBaseasset {
export interface getIsolatedMarginAccountInfoBaseasset {
asset: string
borrowEnabled: boolean
borrowed: string
Expand All @@ -602,7 +602,7 @@ interface getIsolatedMarginAccountInfoBaseasset {
totalAsset: string
}

interface getIsolatedMarginAccountInfoQuoteasset {
export interface getIsolatedMarginAccountInfoQuoteasset {
asset: string
borrowEnabled: boolean
borrowed: string
Expand All @@ -615,7 +615,7 @@ interface getIsolatedMarginAccountInfoQuoteasset {
totalAsset: string
}

interface getIsolatedMarginAccountInfoAssets {
export interface getIsolatedMarginAccountInfoAssets {
baseAsset: getIsolatedMarginAccountInfoBaseasset;
quoteAsset: getIsolatedMarginAccountInfoQuoteasset;
symbol: string;
Expand Down Expand Up @@ -735,7 +735,7 @@ export interface getIsolatedMarginFeeDataResponse {
data: getIsolatedMarginFeeDataData[];
}

interface getIsolatedMarginFeeDataData {
export interface getIsolatedMarginFeeDataData {
coin: string;
dailyInterest: string;
borrowLimit: string;
Expand Down Expand Up @@ -775,7 +775,7 @@ export interface crossMarginCollateralRatioResponse {
assetNames: string[];
}

interface crossMarginCollateralRatioCollaterals {
export interface crossMarginCollateralRatioCollaterals {
minUsdValue: string;
maxUsdValue?: string;
discountRate: string;
Expand Down Expand Up @@ -817,7 +817,7 @@ export interface getSmallLiabilityExchangeHistoryResponse {
rows: getSmallLiabilityExchangeHistoryRows[];
}

interface getSmallLiabilityExchangeHistoryRows {
export interface getSmallLiabilityExchangeHistoryRows {
asset: string;
amount: string;
targetAsset: string;
Expand Down
17 changes: 10 additions & 7 deletions src/modules/restful/market/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,23 @@ export function mixinMarket<T extends Constructor>(base: T): Constructor<MarketM
/**
* Trading Day Ticker {@link https://binance-docs.github.io/apidocs/spot/en/#trading-day-ticker}
*
* @param {string} symbol - Trading symbol, e.g. BNBUSDT
* @param {object} [options]
* @param {string} [options.symbols] - The maximum number of symbols allowed in a request is 100.
* @param {string} [options.symbol] - Trading symbol, e.g. BNBUSDT
* @param {string[]} [options.symbols] - The maximum number of symbols allowed in a request is 100.
* @param {string} [options.timeZone] - Default: 0 (UTC)
* @param {string} [options.type] - Supported values: FULL or MINI., If none provided, the default is FULL
*/
async tradingDayTicker(symbol: string, options?: tradingDayTickerOptions): Promise<tradingDayTickerResponse | tradingDayTickerResponse[]> {
validateRequiredParameters({ symbol });
async tradingDayTicker(options: tradingDayTickerOptions): Promise<tradingDayTickerResponse | tradingDayTickerResponse[]> {
if (options.symbol && options.symbols) throw new Error('Symbol and Symbols cannot be sent together.');
if (options && options.symbol && Object.prototype.hasOwnProperty.call(options, 'symbol')) {
options.symbol = options.symbol.toUpperCase();
}
if (options && options.symbols && Object.prototype.hasOwnProperty.call(options, 'symbols')) {
options.symbols = options.symbols.map(symbol => symbol.toUpperCase());
}
const url = this.preparePath('/api/v3/ticker/tradingDay',
Object.assign(
options ? options : {},
{
symbol: symbol.toUpperCase()
}
)
);
return await this.makeRequest('GET', url);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/restful/market/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ export interface MarketMethods {
symbolPriceTicker(options?: symbolPriceTickerOptions): Promise<symbolPriceTickerResponse | symbolPriceTickerResponse[]>;
symbolOrderBookTicker(options?: symbolOrderBookTickerOptions): Promise<symbolOrderBookTickerResponse | symbolOrderBookTickerResponse[]>;
rollingWindowPriceChangeStatistics(options?: rollingWindowPriceChangeStatisticsOptions): Promise<rollingWindowPriceChangeStatisticsResponse | rollingWindowPriceChangeStatisticsResponse[]>;
tradingDayTicker(symbol: string, options?: tradingDayTickerOptions): Promise<tradingDayTickerResponse | tradingDayTickerResponse[]>;
tradingDayTicker(options?: tradingDayTickerOptions): Promise<tradingDayTickerResponse | tradingDayTickerResponse[]>;
}
41 changes: 21 additions & 20 deletions src/modules/restful/market/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ export interface exchangeInformationResponse {
symbols: exchangeInformationSymbols[];
}

interface exchangeInformationRatelimits {
export interface exchangeInformationRatelimits {
rateLimitType: 'REQUEST_WEIGHT' | 'ORDERS' | 'RAW_REQUESTS';
interval: 'SECOND' | 'MINUTE' | 'DAY';
intervalNum: number;
limit: number;
}

interface exchangefilters {
export interface exchangefilters {
filterType: string;
maxNumOrders: number;
}

interface exchangeInformationSymbols {
export interface exchangeInformationSymbols {
symbol: string;
status: string;
baseAsset: string;
Expand Down Expand Up @@ -209,63 +209,63 @@ export interface rollingWindowPriceChangeStatisticsResponse {

type filters = priceFilter | percentPrice | percentPriceBySide | lotSize | minNotional | notional | iceBergParts | marketLotSize | maxNumOrders | maxNumAlgoOrders | maxNumIcebergOrders | maxPosition | trailingDelta | exchangeMaxNumOrders | exchangeMaxNumAlgoOrders | exchangeMaxNumIcebergOrders;

interface exchangeMaxNumOrders {
export interface exchangeMaxNumOrders {
filterType: 'EXCHANGE_MAX_NUM_ORDERS';
maxNumOrders: number;
}

interface exchangeMaxNumAlgoOrders {
export interface exchangeMaxNumAlgoOrders {
filterType: 'EXCHANGE_MAX_NUM_ALGO_ORDERS';
maxNumAlgoOrders: number;
}

interface exchangeMaxNumIcebergOrders {
export interface exchangeMaxNumIcebergOrders {
filterType: 'EXCHANGE_MAX_NUM_ICEBERG_ORDERS';
maxNumIcebergOrders: number;
}

interface lotSize {
export interface lotSize {
filterType: 'LOT_SIZE';
minQty: string;
maxQty: string;
stepSize: string;
}

interface marketLotSize {
export interface marketLotSize {
filterType: 'MARKET_LOT_SIZE';
minQty: string;
maxQty: string;
stepSize: string;
}

interface maxNumAlgoOrders {
export interface maxNumAlgoOrders {
filterType: 'MAX_NUM_ALGO_ORDERS';
maxNumAlgoOrders: number;
}

interface maxNumOrders {
export interface maxNumOrders {
filterType: 'MAX_NUM_ORDERS';
maxNumOrders: number;
}

interface maxNumIcebergOrders {
export interface maxNumIcebergOrders {
filterType: 'MAX_NUM_ICEBERG_ORDERS';
maxNumIcebergOrders: number;
}

interface maxPosition {
export interface maxPosition {
filterType: 'MAX_POSITION';
maxPosition: string;
}

interface minNotional {
export interface minNotional {
filterType: 'MIN_NOTIONAL';
minNotional: string;
applyToMarket: boolean;
avgPriceMins: number;
}

interface notional {
export interface notional {
filterType: 'NOTIONAL';
minNotional: string;
applyMinToMarket: boolean;
Expand All @@ -274,14 +274,14 @@ interface notional {
avgPriceMins: number;
}

interface percentPrice {
export interface percentPrice {
filterType: 'PERCENT_PRICE';
multiplierUp: string;
multiplierDown: string;
avgPriceMins: number;
}

interface percentPriceBySide {
export interface percentPriceBySide {
filterType: 'PERCENT_PRICE_BY_SIDE';
bidMultiplierUp: string;
bidMultiplierDown: string;
Expand All @@ -290,19 +290,19 @@ interface percentPriceBySide {
avgPriceMins: number;
}

interface priceFilter {
export interface priceFilter {
filterType: 'PRICE_FILTER';
minPrice: string;
maxPrice: string;
tickSize: string;
}

interface iceBergParts {
export interface iceBergParts {
filterType: 'ICEBERG_PARTS';
limit: number;
}

interface trailingDelta {
export interface trailingDelta {
filterType: 'TRAILING_DELTA';
minTrailingAboveDelta: number;
maxTrailingAboveDelta: number;
Expand All @@ -311,7 +311,8 @@ interface trailingDelta {
}

export interface tradingDayTickerOptions {
symbols?: string;
symbol?: string;
symbols?: string[];
timeZone?: string;
type?: 'FULL' | 'MINI';
}
Expand Down
Loading

0 comments on commit 8d32673

Please sign in to comment.