aiden-shared-calculations-unified 1.0.31 → 1.0.32
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.
|
@@ -82,7 +82,7 @@ class AssetCrowdFlow {
|
|
|
82
82
|
async getResult() {
|
|
83
83
|
if (this.user_count === 0 || !this.dates.today) {
|
|
84
84
|
console.warn('[AssetCrowdFlow] No users processed or dates missing.');
|
|
85
|
-
return
|
|
85
|
+
return null; // <--- MODIFICATION
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// Load priceMap and mappings if not loaded
|
|
@@ -94,9 +94,19 @@ class AssetCrowdFlow {
|
|
|
94
94
|
]);
|
|
95
95
|
this.priceMap = priceData;
|
|
96
96
|
this.mappings = mappingData;
|
|
97
|
+
|
|
98
|
+
// --- START NEW CHECK ---
|
|
99
|
+
// If priceData failed to load (e.g., returned {} from provider)
|
|
100
|
+
// this.priceMap will be empty. We must abort.
|
|
101
|
+
if (!this.priceMap || Object.keys(this.priceMap).length === 0) {
|
|
102
|
+
console.error('[AssetCrowdFlow] CRITICAL: Price map is empty or failed to load. Aborting calculation to allow backfill.');
|
|
103
|
+
return null; // Return null to trigger backfill
|
|
104
|
+
}
|
|
105
|
+
// --- END NEW CHECK ---
|
|
106
|
+
|
|
97
107
|
} catch (err) {
|
|
98
108
|
console.error('[AssetCrowdFlow] Failed to load dependencies:', err);
|
|
99
|
-
return
|
|
109
|
+
return null; // <--- MODIFICATION: Return null on error
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
112
|
|
|
@@ -129,14 +139,8 @@ class AssetCrowdFlow {
|
|
|
129
139
|
}
|
|
130
140
|
|
|
131
141
|
if (priceChangePct === null) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
avg_value_day1: avg_day1_value,
|
|
135
|
-
avg_value_day2: avg_day2_value,
|
|
136
|
-
price_change_pct: null,
|
|
137
|
-
user_sample_size: this.user_count,
|
|
138
|
-
warning: 'Missing price data for calculation'
|
|
139
|
-
};
|
|
142
|
+
// <--- MODIFICATION: We no longer add a warning object. We just skip it.
|
|
143
|
+
// If it's missing price data, it won't be in finalResults.
|
|
140
144
|
continue;
|
|
141
145
|
}
|
|
142
146
|
|
|
@@ -156,6 +160,15 @@ class AssetCrowdFlow {
|
|
|
156
160
|
};
|
|
157
161
|
}
|
|
158
162
|
|
|
163
|
+
// --- START NEW CHECK ---
|
|
164
|
+
// If all tickers were skipped due to missing price data,
|
|
165
|
+
// finalResults will be empty. Return null to trigger backfill.
|
|
166
|
+
if (Object.keys(finalResults).length === 0) {
|
|
167
|
+
console.warn(`[AssetCrowdFlow] No results generated for ${this.dates.today}. This likely means all price data was missing. Returning null for backfill.`);
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
// --- END NEW CHECK ---
|
|
171
|
+
|
|
159
172
|
return finalResults;
|
|
160
173
|
}
|
|
161
174
|
|
|
@@ -169,4 +182,4 @@ class AssetCrowdFlow {
|
|
|
169
182
|
}
|
|
170
183
|
}
|
|
171
184
|
|
|
172
|
-
module.exports = AssetCrowdFlow;
|
|
185
|
+
module.exports = AssetCrowdFlow;
|
|
@@ -45,6 +45,18 @@ class CashFlowDeployment {
|
|
|
45
45
|
if (snap.exists) dataMap.set(idx, snap.data());
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
// --- START MODIFICATION ---
|
|
49
|
+
// Check for THIS DATE's dependencies (cash-flow and asset-flow) FIRST.
|
|
50
|
+
// These are at the end of the 'dates' array.
|
|
51
|
+
const cashFlowData = dataMap.get(this.lookbackDays);
|
|
52
|
+
const assetFlowData = dataMap.get(this.lookbackDays + 1);
|
|
53
|
+
|
|
54
|
+
if (!cashFlowData || !assetFlowData) {
|
|
55
|
+
logger.log('WARN', `[CashFlowDeployment] Missing critical dependency data (cash-flow or asset-flow) for ${dateStr}. Skipping to allow backfill.`);
|
|
56
|
+
return null; // This allows backfill
|
|
57
|
+
}
|
|
58
|
+
// --- END MODIFICATION ---
|
|
59
|
+
|
|
48
60
|
// find deposit signal
|
|
49
61
|
let depositSignal = null;
|
|
50
62
|
let depositSignalDay = null;
|
|
@@ -77,14 +89,10 @@ class CashFlowDeployment {
|
|
|
77
89
|
};
|
|
78
90
|
}
|
|
79
91
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!cashFlowData || !assetFlowData) {
|
|
85
|
-
logger.log('WARN', `[CashFlowDeployment] Missing dependency data for ${dateStr}. Skipping.`);
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
92
|
+
// --- REMOVED ---
|
|
93
|
+
// The check for cashFlowData and assetFlowData was here
|
|
94
|
+
// but has been moved up.
|
|
95
|
+
// --- END REMOVED ---
|
|
88
96
|
|
|
89
97
|
const netSpendPct = cashFlowData.components?.trading_effect || 0;
|
|
90
98
|
const netDepositPct = Math.abs(depositSignal.cash_flow_effect_proxy);
|
|
@@ -114,4 +122,4 @@ class CashFlowDeployment {
|
|
|
114
122
|
reset() {}
|
|
115
123
|
}
|
|
116
124
|
|
|
117
|
-
module.exports = CashFlowDeployment;
|
|
125
|
+
module.exports = CashFlowDeployment;
|
|
@@ -59,6 +59,18 @@ class CashFlowLiquidation {
|
|
|
59
59
|
if (snap.exists) dataMap.set(idx, snap.data());
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
// --- START MODIFICATION ---
|
|
63
|
+
// Check for THIS DATE's dependencies (cash-flow and asset-flow) FIRST.
|
|
64
|
+
const cashFlowData = dataMap.get(this.lookbackDays);
|
|
65
|
+
const assetFlowData = dataMap.get(this.lookbackDays + 1);
|
|
66
|
+
|
|
67
|
+
if (!cashFlowData || !assetFlowData) {
|
|
68
|
+
logger.log('WARN', `[CashFlowLiquidation] Missing critical dependency data (cash-flow or asset-flow) for ${dateStr}. Skipping to allow backfill.`);
|
|
69
|
+
return null; // This allows backfill
|
|
70
|
+
}
|
|
71
|
+
// --- END MODIFICATION ---
|
|
72
|
+
|
|
73
|
+
|
|
62
74
|
// 2. Find the withdrawal signal
|
|
63
75
|
let withdrawalSignal = null;
|
|
64
76
|
let withdrawalSignalDay = null;
|
|
@@ -92,14 +104,10 @@ class CashFlowLiquidation {
|
|
|
92
104
|
};
|
|
93
105
|
}
|
|
94
106
|
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (!cashFlowData || !assetFlowData) {
|
|
100
|
-
logger.log('WARN', `[CashFlowLiquidation] Missing dependency data for ${dateStr}. Skipping.`);
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
107
|
+
// --- REMOVED ---
|
|
108
|
+
// The check for cashFlowData and assetFlowData was here
|
|
109
|
+
// but has been moved up.
|
|
110
|
+
// --- END REMOVED ---
|
|
103
111
|
|
|
104
112
|
// 'trading_effect' will be negative if the crowd is net-selling
|
|
105
113
|
const netSellPct = cashFlowData.components?.trading_effect || 0;
|