@@ -14,6 +14,7 @@ import {
1414 ICandlestick ,
1515 IExchangeAsset ,
1616 IExchangeInfo ,
17+ IHistoricalCandlestick ,
1718 IHistoricalOrderBook ,
1819 IHistoricalInstrument ,
1920 IHistoricalTrade ,
@@ -43,6 +44,7 @@ import {
4344 IExchangeAssetDto ,
4445 IExchangeInfoDto ,
4546 IGuidIdResultDto ,
47+ IHistoricalCandlestickDto ,
4648 IHistoricalOrderBookDto ,
4749 IHistoricalInstrumentDto ,
4850 IHistoricalTradeDto ,
@@ -58,6 +60,7 @@ import {
5860 ITradeDto ,
5961 ITradingPairDto ,
6062 IUserDto ,
63+ IWebsocketTokenDto ,
6164} from "../dtos" ;
6265import {
6366 AccountBalanceDtoConverter ,
@@ -68,6 +71,7 @@ import {
6871 CandlestickDtoConverter ,
6972 DateDtoConverter ,
7073 DecimalDtoConverter ,
74+ HistoricalCandlestickDtoConverter ,
7175 HistoricalOrderBooksDtoConverter ,
7276 HistoricalInstrumentsDtoConverter ,
7377 HistoricalTradesDtoConverter ,
@@ -91,6 +95,7 @@ export class ShrimpyApiClient {
9195 private _candlestickDtoConverter = new CandlestickDtoConverter ( ) ;
9296 private _dateDtoConverter = new DateDtoConverter ( ) ;
9397 private _decimalDtoConverter = new DecimalDtoConverter ( ) ;
98+ private _historicalCandlestickDtoConverter = new HistoricalCandlestickDtoConverter ( ) ;
9499 private _historicalOrderBooksDtoConverter = new HistoricalOrderBooksDtoConverter ( ) ;
95100 private _historicalInstrumentsDtoConverter = new HistoricalInstrumentsDtoConverter ( ) ;
96101 private _historicalTradesDtoConverter = new HistoricalTradesDtoConverter ( ) ;
@@ -695,6 +700,41 @@ export class ShrimpyApiClient {
695700 return this . _historicalOrderBooksDtoConverter . convertFromDto ( resultDto ) ;
696701 }
697702
703+ public async getHistoricalCandles (
704+ exchange : string ,
705+ baseTradingSymbol : string ,
706+ quoteTradingSymbol : string ,
707+ startTime : Date ,
708+ endTime : Date ,
709+ limit : number ,
710+ interval : '1m' | '5m' | '15m' | '1h' | '6h' | '1d'
711+ ) : Promise < IHistoricalCandlestick [ ] > {
712+ const endpoint = `historical/candles` ;
713+ const parameters : {
714+ exchange : string ,
715+ baseTradingSymbol : string ,
716+ quoteTradingSymbol : string ,
717+ startTime : string ,
718+ endTime : string ,
719+ limit : number ,
720+ interval : '1m' | '5m' | '15m' | '1h' | '6h' | '1d'
721+ } = {
722+ exchange : exchange ,
723+ baseTradingSymbol : baseTradingSymbol ,
724+ quoteTradingSymbol : quoteTradingSymbol ,
725+ startTime : this . _dateDtoConverter . convertToDto ( startTime ) ,
726+ endTime : this . _dateDtoConverter . convertToDto ( endTime ) ,
727+ limit : limit ,
728+ interval : interval
729+ } ;
730+ const resultDto = await this . _callEndpoint < IHistoricalCandlestickDto [ ] > ( endpoint , 'GET' , parameters , true ) ;
731+ const result = resultDto . map ( ( candlestick ) => {
732+ return this . _historicalCandlestickDtoConverter . convertFromDto ( candlestick ) ;
733+ } ) ;
734+
735+ return result ;
736+ }
737+
698738 public async getHistoricalInstruments (
699739 exchange ?: string ,
700740 baseTradingSymbol ?: string ,
@@ -728,6 +768,14 @@ export class ShrimpyApiClient {
728768 return await this . _callEndpoint < IManagementUsage > ( endpoint , 'GET' , null , true ) ;
729769 }
730770
771+ /* WebSocket */
772+
773+ public async getToken ( ) : Promise < string > {
774+ const endpoint = `ws/token` ;
775+ const websocketTokenResult = await this . _callEndpoint < IWebsocketTokenDto > ( endpoint , 'GET' , null , true ) ;
776+
777+ return websocketTokenResult . token ;
778+ }
731779
732780/* private methods */
733781
0 commit comments