|
|
@ -12,6 +12,7 @@ import { |
|
|
|
|
|
|
|
|
import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; |
|
|
import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; |
|
|
import { isWeekend } from 'date-fns'; |
|
|
import { isWeekend } from 'date-fns'; |
|
|
|
|
|
import { round } from 'lodash'; |
|
|
import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2'; |
|
|
import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2'; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
@ -89,16 +90,16 @@ export class TwitterBotService implements OnModuleInit { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return benchmarks |
|
|
return benchmarks |
|
|
.map(({ marketCondition, name, performances }) => { |
|
|
.map(({ name, performances }) => { |
|
|
let changeFormAllTimeHigh = ( |
|
|
const performancePercent = round( |
|
|
performances.allTimeHigh.performancePercent * 100 |
|
|
performances.allTimeHigh.performancePercent, |
|
|
).toFixed(1); |
|
|
3 |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
if (Math.abs(parseFloat(changeFormAllTimeHigh)) === 0) { |
|
|
const marketCondition = |
|
|
changeFormAllTimeHigh = '0.0'; |
|
|
this.benchmarkService.getMarketCondition(performancePercent); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return `${name} ${changeFormAllTimeHigh}%${ |
|
|
return `${name} ${(performancePercent * 100).toFixed(1)}%${ |
|
|
marketCondition !== 'NEUTRAL_MARKET' |
|
|
marketCondition !== 'NEUTRAL_MARKET' |
|
|
? ' ' + resolveMarketCondition(marketCondition).emoji |
|
|
? ' ' + resolveMarketCondition(marketCondition).emoji |
|
|
: '' |
|
|
: '' |
|
|
|