|
|
|
@ -30,10 +30,17 @@ import { get, isNil, isString } from 'lodash'; |
|
|
|
import { |
|
|
|
DEFAULT_CURRENCY, |
|
|
|
DERIVED_CURRENCIES, |
|
|
|
ghostfolioFearAndGreedIndexSymbol, |
|
|
|
ghostfolioFearAndGreedIndexSymbolCryptocurrencies, |
|
|
|
ghostfolioFearAndGreedIndexSymbolStocks, |
|
|
|
ghostfolioScraperApiSymbolPrefix, |
|
|
|
locale |
|
|
|
} from './config'; |
|
|
|
import { AssetProfileIdentifier, Benchmark } from './interfaces'; |
|
|
|
import { |
|
|
|
AdminMarketDataItem, |
|
|
|
AssetProfileIdentifier, |
|
|
|
Benchmark |
|
|
|
} from './interfaces'; |
|
|
|
import { BenchmarkTrend, ColorScheme } from './types'; |
|
|
|
|
|
|
|
export const DATE_FORMAT = 'yyyy-MM-dd'; |
|
|
|
@ -93,6 +100,27 @@ export function calculateMovingAverage({ |
|
|
|
.toNumber(); |
|
|
|
} |
|
|
|
|
|
|
|
export function canDeleteAssetProfile({ |
|
|
|
activitiesCount, |
|
|
|
isBenchmark, |
|
|
|
symbol, |
|
|
|
watchedByCount |
|
|
|
}: Pick< |
|
|
|
AdminMarketDataItem, |
|
|
|
'activitiesCount' | 'isBenchmark' | 'symbol' | 'watchedByCount' |
|
|
|
>): boolean { |
|
|
|
return ( |
|
|
|
activitiesCount === 0 && |
|
|
|
!isBenchmark && |
|
|
|
!isDerivedCurrency(getCurrencyFromSymbol(symbol)) && |
|
|
|
!isRootCurrency(getCurrencyFromSymbol(symbol)) && |
|
|
|
symbol !== ghostfolioFearAndGreedIndexSymbol && |
|
|
|
symbol !== ghostfolioFearAndGreedIndexSymbolCryptocurrencies && |
|
|
|
symbol !== ghostfolioFearAndGreedIndexSymbolStocks && |
|
|
|
watchedByCount === 0 |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
export function capitalize(aString: string) { |
|
|
|
return aString.charAt(0).toUpperCase() + aString.slice(1).toLowerCase(); |
|
|
|
} |
|
|
|
|