bulltrackers-module 1.0.90 → 1.0.92
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.
|
@@ -1,56 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Computation system sub-pipes and utils.
|
|
3
3
|
* REFACTORED: Now stateless and receive dependencies where needed.
|
|
4
|
+
* DYNAMIC: Automatically categorizes meta and historical calcs based on file path.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
const { FieldValue, FieldPath } = require('@google-cloud/firestore');
|
|
7
8
|
const { calculations, utils } = require('aiden-shared-calculations-unified');
|
|
8
9
|
const { withRetry } = utils;
|
|
9
10
|
|
|
10
|
-
// --- Calculation Categorization
|
|
11
|
-
const HISTORICAL_CALC_NAMES = new Set([
|
|
12
|
-
'paper-vs-diamond-hands', 'smart-money-flow', 'profitability-migration',
|
|
13
|
-
'user-profitability-tracker', 'sector-rotation', 'crowd-conviction-score',
|
|
14
|
-
'risk-appetite-change', 'drawdown-response', 'gain-response',
|
|
15
|
-
'tsl-effectiveness', 'position-count-pnl', 'diversification-pnl',
|
|
16
|
-
|
|
17
|
-
'deposit-withdrawal-percentage',
|
|
18
|
-
'new-allocation-percentage',
|
|
19
|
-
'reallocation-increase-percentage',
|
|
20
|
-
'asset-crowd-flow'
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
// --- Set for meta calculation names (Generated Dynamically) ---
|
|
24
|
-
const META_CALC_NAMES = new Set(); // This will be populated dynamically
|
|
11
|
+
// --- Dynamic Calculation Categorization ---
|
|
25
12
|
|
|
13
|
+
// These sets will be populated dynamically by inspecting the file structure
|
|
14
|
+
const HISTORICAL_CALC_NAMES = new Set();
|
|
15
|
+
const META_CALC_NAMES = new Set();
|
|
26
16
|
|
|
27
17
|
const historicalCalculations = {};
|
|
28
18
|
const dailyCalculations = {};
|
|
29
|
-
const metaCalculations = {};
|
|
19
|
+
const metaCalculations = {};
|
|
30
20
|
|
|
31
21
|
for (const category in calculations) {
|
|
32
|
-
for (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
// 1. Check for 'meta' category first (by top-level directory name)
|
|
23
|
+
if (category === 'meta') {
|
|
24
|
+
if (!metaCalculations[category]) metaCalculations[category] = {};
|
|
25
|
+
for (const calcName in calculations[category]) {
|
|
26
|
+
const CalculationClass = calculations[category][calcName];
|
|
27
|
+
metaCalculations[category][calcName] = CalculationClass;
|
|
28
|
+
META_CALC_NAMES.add(calcName);
|
|
29
|
+
}
|
|
30
|
+
continue; // Done with this category
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 2. Process other categories (e.g., 'pnl', 'capital_flow')
|
|
34
|
+
for (const subKey in calculations[category]) {
|
|
35
|
+
const item = calculations[category][subKey];
|
|
36
|
+
|
|
37
|
+
// Check if the key is 'historical' and it contains an object of calculations
|
|
38
|
+
if (subKey === 'historical' && typeof item === 'object' && item !== null && !Array.isArray(item)) {
|
|
39
|
+
// This is the historical subdirectory, e.g., calculations.capital_flow.historical
|
|
40
|
+
|
|
43
41
|
if (!historicalCalculations[category]) historicalCalculations[category] = {};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
|
|
43
|
+
for (const calcName in item) {
|
|
44
|
+
const CalculationClass = item[calcName];
|
|
45
|
+
// Add it to the historical list, using the parent 'category'
|
|
46
|
+
historicalCalculations[category][calcName] = CalculationClass;
|
|
47
|
+
HISTORICAL_CALC_NAMES.add(calcName);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Check if the item is a function (a standard daily calc at the root of the category)
|
|
51
|
+
else if (typeof item === 'function') {
|
|
52
|
+
// This is a standard daily calc, e.g., calculations.pnl.average-daily-pnl
|
|
53
|
+
const calcName = subKey;
|
|
54
|
+
const CalculationClass = item;
|
|
55
|
+
|
|
48
56
|
if (!dailyCalculations[category]) dailyCalculations[category] = {};
|
|
49
|
-
dailyCalculations[category][calcName] =
|
|
57
|
+
dailyCalculations[category][calcName] = CalculationClass;
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
|
-
// --- End Categorization ---
|
|
61
|
+
// --- End Dynamic Categorization ---
|
|
54
62
|
|
|
55
63
|
|
|
56
64
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bulltrackers-module",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.92",
|
|
4
4
|
"description": "Helper Functions for Bulltrackers.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@google-cloud/firestore": "^7.11.3",
|
|
33
33
|
"sharedsetup": "latest",
|
|
34
34
|
"require-all": "^3.0.0",
|
|
35
|
-
"aiden-shared-calculations-unified": "1.0.
|
|
35
|
+
"aiden-shared-calculations-unified": "1.0.16",
|
|
36
36
|
"@google-cloud/pubsub": "latest",
|
|
37
37
|
"express": "^4.19.2",
|
|
38
38
|
"cors": "^2.8.5",
|