Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/handling of values rounding to zero in twitter bot (#7210)

Thomas Kaulc0b6a2f95a38
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 468ca68ccf..2d1558a97c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the language localization for Ukrainian (`uk`)
- Upgraded `yahoo-finance2` from version `3.14.3` to `3.15.4`
+### Fixed
+
+- Fixed the market condition of the benchmarks in the twitter bot service when values round to zero
+
## 3.19.1 - 2026-07-03
### Added
diff --git a/apps/api/src/services/twitter-bot/twitter-bot.service.ts b/apps/api/src/services/twitter-bot/twitter-bot.service.ts
index 4e6fd5bb2c..366b016b67 100644
--- a/apps/api/src/services/twitter-bot/twitter-bot.service.ts
+++ b/apps/api/src/services/twitter-bot/twitter-bot.service.ts
@@ -12,6 +12,7 @@ import {
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { isWeekend } from 'date-fns';
+import { round } from 'lodash';
import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2';
@Injectable()
@@ -89,16 +90,16 @@ export class TwitterBotService implements OnModuleInit {
});
return benchmarks
- .map(({ marketCondition, name, performances }) => {
- let changeFormAllTimeHigh = (
- performances.allTimeHigh.performancePercent * 100
- ).toFixed(1);
+ .map(({ name, performances }) => {
+ const performancePercent = round(
+ performances.allTimeHigh.performancePercent,
+ 3
+ );
- if (Math.abs(parseFloat(changeFormAllTimeHigh)) === 0) {
- changeFormAllTimeHigh = '0.0';
- }
+ const marketCondition =
+ this.benchmarkService.getMarketCondition(performancePercent);
- return `${name} ${changeFormAllTimeHigh}%${
+ return `${name} ${(performancePercent * 100).toFixed(1)}%${
marketCondition !== 'NEUTRAL_MARKET'
? ' ' + resolveMarketCondition(marketCondition).emoji
: ''