Skip to content

Commit 3ad64e0

Browse files
Added support for Historical Count Endpoint
1 parent 95d74ef commit 3ad64e0

7 files changed

Lines changed: 56 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,22 @@ const assetPopularity = await client.getAssetPopularity();
443443

444444
### Historical Methods
445445

446+
* [`getHistoricalCount`](https://developers.shrimpy.io/docs/#get-historical-count)
447+
```js
448+
const count = await client.getHistoricalCount(
449+
'trade', // type
450+
'binance', // exchange
451+
'LTC', // baseTradingSymbol
452+
'BTC', // quoteTradingSymbol
453+
new Date("2018-05-19T01:00:00.000Z"), // startTime
454+
new Date("2018-11-02T02:00:00.000Z") // endTime
455+
);
456+
```
457+
446458
* [`getHistoricalInstruments`](https://developers.shrimpy.io/docs/#get-historical-instruments)
447459
```js
448460
const instruments = await client.getHistoricalInstruments();
461+
const bittrexInstruments = await client.getHistoricalInstruments('bittrex');
449462
```
450463

451464
* [`getHistoricalTrades`](https://developers.shrimpy.io/docs/#get-historical-trades)

lib/client/shrimpy-api-client.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
IExchangeAsset,
1616
IExchangeInfo,
1717
IHistoricalCandlestick,
18+
IHistoricalCount,
1819
IHistoricalOrderBook,
1920
IHistoricalInstrument,
2021
IHistoricalTrade,
@@ -45,6 +46,7 @@ import {
4546
IExchangeInfoDto,
4647
IGuidIdResultDto,
4748
IHistoricalCandlestickDto,
49+
IHistoricalCountDto,
4850
IHistoricalOrderBookDto,
4951
IHistoricalInstrumentDto,
5052
IHistoricalTradeDto,
@@ -756,6 +758,38 @@ export class ShrimpyApiClient {
756758
return this._historicalInstrumentsDtoConverter.convertFromDto(resultDto);
757759
}
758760

761+
public async getHistoricalCount(
762+
type: 'trade' | 'orderbook',
763+
exchange: string,
764+
baseTradingSymbol: string,
765+
quoteTradingSymbol: string,
766+
startTime: Date,
767+
endTime: Date
768+
): Promise<IHistoricalCount> {
769+
const endpoint = `historical/count`;
770+
const parameters: {
771+
type: string,
772+
exchange: string,
773+
baseTradingSymbol: string,
774+
quoteTradingSymbol: string,
775+
startTime: string,
776+
endTime: string
777+
} = {
778+
type: type,
779+
exchange: exchange,
780+
baseTradingSymbol: baseTradingSymbol,
781+
quoteTradingSymbol: quoteTradingSymbol,
782+
startTime: this._dateDtoConverter.convertToDto(startTime),
783+
endTime: this._dateDtoConverter.convertToDto(endTime)
784+
};
785+
const countDto = await this._callEndpoint<IHistoricalCountDto>(endpoint, 'GET', parameters, true);
786+
const result: IHistoricalCount = {
787+
count: countDto.count
788+
};
789+
790+
return result;
791+
}
792+
759793
/* Management */
760794

761795
public async getStatus(): Promise<IManagementStatus> {

lib/dtos/ihistorical-count-dto.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface IHistoricalCountDto {
2+
count: number;
3+
}

lib/dtos/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export * from './iexchange-info-dto';
1717
export * from './iexchange-order-book-dto';
1818
export * from './iguid-id-result-dto';
1919
export * from './ihistorical-candlestick-dto';
20+
export * from './ihistorical-count-dto';
2021
export * from './ihistorical-order-book-dto';
2122
export * from './ihistorical-instrument-dto';
2223
export * from './ihistorical-trade-dto';

lib/models/ihistorical-count.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface IHistoricalCount {
2+
count: number;
3+
}

lib/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export * from './iexchange-asset';
1616
export * from './iexchange-info';
1717
export * from './iexchange-order-book';
1818
export * from './ihistorical-candlestick';
19+
export * from './ihistorical-count';
1920
export * from './ihistorical-order-book';
2021
export * from './ihistorical-instrument';
2122
export * from './ihistorical-trade';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shrimpy-node",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"author": "Shrimpy",
55
"bugs": "https://github.com/shrimpy-dev/shrimpy-node/issues",
66
"contributors": [

0 commit comments

Comments
 (0)