aiden-shared-calculations-unified 1.0.34 → 1.0.35

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 null; // <--- MODIFICATION
85
+ return null; // <--- Returns null if no users
86
86
  }
87
87
 
88
88
  // Load priceMap and mappings if not loaded
@@ -95,18 +95,14 @@ class AssetCrowdFlow {
95
95
  this.priceMap = priceData;
96
96
  this.mappings = mappingData;
97
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
98
  if (!this.priceMap || Object.keys(this.priceMap).length === 0) {
102
99
  console.error('[AssetCrowdFlow] CRITICAL: Price map is empty or failed to load. Aborting calculation to allow backfill.');
103
100
  return null; // Return null to trigger backfill
104
101
  }
105
- // --- END NEW CHECK ---
106
102
 
107
103
  } catch (err) {
108
104
  console.error('[AssetCrowdFlow] Failed to load dependencies:', err);
109
- return null; // <--- MODIFICATION: Return null on error
105
+ return null; // <--- Return null on error
110
106
  }
111
107
  }
112
108
 
@@ -121,15 +117,17 @@ class AssetCrowdFlow {
121
117
  const avg_day1_value = this.asset_values[rawInstrumentId].day1_value_sum / this.user_count;
122
118
  const avg_day2_value = this.asset_values[rawInstrumentId].day2_value_sum / this.user_count;
123
119
 
124
- // FIX to detect weekends and skip them
120
+ // --- THIS IS THE FIX YOU APPLIED ---
125
121
  const priceChangePct = getDailyPriceChange(instrumentId, yesterdayStr, todayStr, this.priceMap);
122
+ // --- END FIX ---
126
123
 
127
124
  if (priceChangePct === null) {
128
- // <--- MODIFICATION: We no longer add a warning object. We just skip it.
129
- // If it's missing price data, it won't be in finalResults.
125
+ // If price is missing, we simply skip this ticker.
126
+ // It will not be in the final output.
130
127
  continue;
131
128
  }
132
129
 
130
+ // --- THIS IS THE LOGIC THAT IS BROKEN IN YOUR FILE ---
133
131
  // Calculate expected day2 value from price movement
134
132
  const expected_day2_value = avg_day1_value * (1 + priceChangePct);
135
133
 
@@ -138,22 +136,19 @@ class AssetCrowdFlow {
138
136
 
139
137
  finalResults[ticker] = {
140
138
  net_crowd_flow_pct,
141
- avg_value_day1,
142
- avg_value_day2,
139
+ avg_value_day1_pct: avg_day1_value, // <-- Note: I've also fixed the key name here
140
+ avg_value_day2_pct: avg_day2_value, // <-- Note: I've also fixed the key name here
143
141
  expected_day2_value,
144
142
  price_change_pct: priceChangePct,
145
143
  user_sample_size: this.user_count
146
144
  };
145
+ // --- END BROKEN LOGIC ---
147
146
  }
148
147
 
149
- // --- START NEW CHECK ---
150
- // If all tickers were skipped due to missing price data,
151
- // finalResults will be empty. Return null to trigger backfill.
152
148
  if (Object.keys(finalResults).length === 0) {
153
149
  console.warn(`[AssetCrowdFlow] No results generated for ${this.dates.today}. This likely means all price data was missing. Returning null for backfill.`);
154
- return null;
150
+ return null; // <--- Returns null if all tickers failed
155
151
  }
156
- // --- END NEW CHECK ---
157
152
 
158
153
  return finalResults;
159
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiden-shared-calculations-unified",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "Shared calculation modules for the BullTrackers Computation System.",
5
5
  "main": "index.js",
6
6
  "files": [