aiden-shared-calculations-unified 1.0.42 → 1.0.44

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.
@@ -26,6 +26,7 @@
26
26
  // The `computedDependencies` argument will be unused for this calc.
27
27
 
28
28
  const { loadAllPriceData } = require('../../utils/price_data_provider');
29
+ const { FieldPath } = require('@google-cloud/firestore'); // <-- ADD THIS LINE
29
30
 
30
31
  class StrategyPerformance {
31
32
  constructor() {
@@ -47,7 +48,7 @@ class StrategyPerformance {
47
48
  async _findSignalInceptionDate(db, collection, computation, category) {
48
49
  const snapshot = await db.collection(collection)
49
50
  .where(`${category}.${computation}`, '==', true)
50
- .orderBy(db.FieldPath.documentId(), 'asc')
51
+ .orderBy(FieldPath.documentId(), 'asc')
51
52
  .limit(1)
52
53
  .get();
53
54
  if (snapshot.empty) return null;
@@ -12,7 +12,7 @@ const { Firestore } = require('@google-cloud/firestore');
12
12
  const firestore = new Firestore();
13
13
  const { loadAllPriceData, getDailyPriceChange } = require('../../../utils/price_data_provider');
14
14
  const { loadInstrumentMappings, getInstrumentSectorMap } = require('../../../utils/sector_mapping_provider');
15
- const { loadDataByRefs } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader'); // Adjust path as needed
15
+ const { loadDataByRefs, getPortfolioPartRefs, loadFullDayMap } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader');
16
16
 
17
17
  const COHORT_PERCENTILE = 0.2; // Bottom 20%
18
18
  const PROFILE_CALC_ID = 'user-investment-profile'; // The calc to read IS scores from
@@ -107,7 +107,7 @@ class DumbCohortFlow {
107
107
  const yesterdayDate = new Date(dateStr + 'T00:00:00Z');
108
108
  yesterdayDate.setUTCDate(yesterdayDate.getUTCDate() - 1);
109
109
  const yesterdayStr = yesterdayDate.toISOString().slice(0, 10);
110
- const yesterdayRefs = await calculationUtils.getPortfolioPartRefs(config, dependencies, yesterdayStr);
110
+ const yesterdayRefs = await getPortfolioPartRefs(config, dependencies, yesterdayStr);
111
111
  const yesterdayPortfolios = await loadFullDayMap(config, dependencies, yesterdayRefs);
112
112
  logger.log('INFO', `[DumbCohortFlow] Loaded ${yesterdayRefs.length} part refs for yesterday.`);
113
113
 
@@ -12,7 +12,7 @@ const { Firestore } = require('@google-cloud/firestore');
12
12
  const firestore = new Firestore();
13
13
  const { loadAllPriceData, getDailyPriceChange } = require('../../../utils/price_data_provider');
14
14
  const { loadInstrumentMappings, getInstrumentSectorMap } = require('../../../utils/sector_mapping_provider');
15
- const { loadDataByRefs } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader'); // Adjust path as needed
15
+ const { loadDataByRefs, getPortfolioPartRefs, loadFullDayMap } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader');
16
16
 
17
17
  const COHORT_PERCENTILE = 0.8; // Top 20%
18
18
  const PROFILE_CALC_ID = 'user-investment-profile'; // The calc to read IS scores from
@@ -107,7 +107,7 @@ class SmartCohortFlow {
107
107
  const yesterdayDate = new Date(dateStr + 'T00:00:00Z');
108
108
  yesterdayDate.setUTCDate(yesterdayDate.getUTCDate() - 1);
109
109
  const yesterdayStr = yesterdayDate.toISOString().slice(0, 10);
110
- const yesterdayRefs = await calculationUtils.getPortfolioPartRefs(config, dependencies, yesterdayStr);
110
+ const yesterdayRefs = await getPortfolioPartRefs(config, dependencies, yesterdayStr);
111
111
  const yesterdayPortfolios = await loadFullDayMap(config, dependencies, yesterdayRefs);
112
112
  logger.log('INFO', `[SmartCohortFlow] Loaded ${yesterdayRefs.length} part refs for yesterday.`);
113
113
 
@@ -11,8 +11,7 @@ const { Firestore } = require('@google-cloud/firestore');
11
11
  const firestore = new Firestore();
12
12
  const { loadAllPriceData, getDailyPriceChange } = require('../../../utils/price_data_provider');
13
13
  const { loadInstrumentMappings, getInstrumentSectorMap } = require('../../../utils/sector_mapping_provider');
14
- const { loadDataByRefs, getPortfolioPartRefs } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader'); // Adjust path as needed
15
- // Config
14
+ const { loadDataByRefs, getPortfolioPartRefs, loadFullDayMap } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader');// Config
16
15
  const NUM_SHARDS = 50; // Must match the number of shards to read/write
17
16
  const ROLLING_DAYS = 90;
18
17
  const SHARD_COLLECTION_NAME = 'user_profile_history'; // The collection to store sharded history
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiden-shared-calculations-unified",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "Shared calculation modules for the BullTrackers Computation System.",
5
5
  "main": "index.js",
6
6
  "files": [