@cranberry-money/shared-utils 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portfolio-related helper functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Calculate total portfolio value
|
|
6
|
+
*/
|
|
7
|
+
export declare const calculateTotalValue: (marketValue: number, cashBalance: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate market allocation percentage
|
|
10
|
+
*/
|
|
11
|
+
export declare const getMarketAllocation: (marketValue: number, totalValue: number) => number;
|
|
12
|
+
/**
|
|
13
|
+
* Calculate cash allocation percentage
|
|
14
|
+
*/
|
|
15
|
+
export declare const getCashAllocation: (cashBalance: number, totalValue: number) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Format portfolio value with default currency
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatPortfolioValue: (value: number) => string;
|
|
20
|
+
//# sourceMappingURL=portfolio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/helpers/portfolio.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,EAAE,aAAa,MAAM,KAAG,MAE9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,EAAE,YAAY,MAAM,KAAG,MAE7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,EAAE,YAAY,MAAM,KAAG,MAE3E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,MAEpD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portfolio-related helper functions
|
|
3
|
+
*/
|
|
4
|
+
import { formatCurrency } from '../formatters/currency';
|
|
5
|
+
/**
|
|
6
|
+
* Calculate total portfolio value
|
|
7
|
+
*/
|
|
8
|
+
export const calculateTotalValue = (marketValue, cashBalance) => {
|
|
9
|
+
return marketValue + cashBalance;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Calculate market allocation percentage
|
|
13
|
+
*/
|
|
14
|
+
export const getMarketAllocation = (marketValue, totalValue) => {
|
|
15
|
+
return totalValue > 0 ? (marketValue / totalValue) * 100 : 0;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Calculate cash allocation percentage
|
|
19
|
+
*/
|
|
20
|
+
export const getCashAllocation = (cashBalance, totalValue) => {
|
|
21
|
+
return totalValue > 0 ? (cashBalance / totalValue) * 100 : 0;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Format portfolio value with default currency
|
|
25
|
+
*/
|
|
26
|
+
export const formatPortfolioValue = (value) => {
|
|
27
|
+
return formatCurrency(value);
|
|
28
|
+
};
|