Skip to content

Commit

Permalink
✨ feat: 차트 데이터는 문자열로 반환하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
xjfcnfw3 committed Dec 4, 2024
1 parent 53dec2b commit 29cddd4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/backend/src/stock/dto/stockData.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class PriceDto {

constructor(stockData: StockData) {
this.startTime = stockData.startTime;
this.open = Number(stockData.open);
this.high = Number(stockData.high);
this.low = Number(stockData.low);
this.close = Number(stockData.close);
this.open = stockData.open;
this.high = stockData.high;
this.low = stockData.low;
this.close = stockData.close;
}
}

Expand All @@ -63,11 +63,11 @@ export class VolumeDto {
description: '거래량',
example: 1000,
})
volume: number;
volume: string;

constructor(stockData: StockData) {
this.startTime = stockData.startTime;
this.volume = Number(stockData.volume);
this.volume = String(stockData.volume);
}
}

Expand Down Expand Up @@ -104,13 +104,13 @@ export class StockDataResponse {

renewLastData(stockLiveData: StockLiveData, entity: new () => StockData) {
const lastIndex = this.priceDtoList.length - 1;
this.priceDtoList[lastIndex].close = Number(stockLiveData.currentPrice);
this.priceDtoList[lastIndex].close = stockLiveData.currentPrice;
this.priceDtoList[lastIndex].high =
stockLiveData.high > this.priceDtoList[lastIndex].high
Number(stockLiveData.high) > Number(this.priceDtoList[lastIndex].high)
? stockLiveData.high
: this.priceDtoList[lastIndex].high;
this.priceDtoList[lastIndex].low =
stockLiveData.low < this.priceDtoList[lastIndex].low
Number(stockLiveData.low) < Number(this.priceDtoList[lastIndex].low)
? stockLiveData.low
: this.priceDtoList[lastIndex].low;

Expand All @@ -120,7 +120,10 @@ export class StockDataResponse {
: this.priceDtoList[lastIndex].startTime;
this.volumeDtoList[lastIndex].volume =
entity === StockDaily
? stockLiveData.volume
: this.volumeDtoList[lastIndex].volume + stockLiveData.volume;
? String(stockLiveData.volume)
: String(
Number(this.volumeDtoList[lastIndex].volume) +
Number(stockLiveData.volume),
);
}
}

0 comments on commit 29cddd4

Please sign in to comment.