bulltrackers-module 1.0.104 → 1.0.106

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.
Files changed (33) hide show
  1. package/README.MD +222 -222
  2. package/functions/appscript-api/helpers/errors.js +19 -19
  3. package/functions/appscript-api/index.js +58 -58
  4. package/functions/computation-system/helpers/orchestration_helpers.js +647 -113
  5. package/functions/computation-system/utils/data_loader.js +191 -191
  6. package/functions/computation-system/utils/utils.js +149 -254
  7. package/functions/core/utils/firestore_utils.js +433 -433
  8. package/functions/core/utils/pubsub_utils.js +53 -53
  9. package/functions/dispatcher/helpers/dispatch_helpers.js +47 -47
  10. package/functions/dispatcher/index.js +52 -52
  11. package/functions/etoro-price-fetcher/helpers/handler_helpers.js +124 -124
  12. package/functions/fetch-insights/helpers/handler_helpers.js +91 -91
  13. package/functions/generic-api/helpers/api_helpers.js +379 -379
  14. package/functions/generic-api/index.js +150 -150
  15. package/functions/invalid-speculator-handler/helpers/handler_helpers.js +75 -75
  16. package/functions/orchestrator/helpers/discovery_helpers.js +226 -226
  17. package/functions/orchestrator/helpers/update_helpers.js +92 -92
  18. package/functions/orchestrator/index.js +147 -147
  19. package/functions/price-backfill/helpers/handler_helpers.js +116 -123
  20. package/functions/social-orchestrator/helpers/orchestrator_helpers.js +61 -61
  21. package/functions/social-task-handler/helpers/handler_helpers.js +288 -288
  22. package/functions/task-engine/handler_creator.js +78 -78
  23. package/functions/task-engine/helpers/discover_helpers.js +125 -125
  24. package/functions/task-engine/helpers/update_helpers.js +118 -118
  25. package/functions/task-engine/helpers/verify_helpers.js +162 -162
  26. package/functions/task-engine/utils/firestore_batch_manager.js +258 -258
  27. package/index.js +105 -113
  28. package/package.json +45 -45
  29. package/functions/computation-system/computation_dependencies.json +0 -120
  30. package/functions/computation-system/helpers/worker_helpers.js +0 -340
  31. package/functions/computation-system/utils/computation_state_manager.js +0 -178
  32. package/functions/computation-system/utils/dependency_graph.js +0 -191
  33. package/functions/speculator-cleanup-orchestrator/helpers/cleanup_helpers.js +0 -160
package/index.js CHANGED
@@ -1,114 +1,106 @@
1
- /**
2
- * @fileoverview Main entry point for the Bulltrackers shared module.
3
- * This module consolidates all core logic into a single 'pipe' object
4
- * to enforce a clear naming convention and dependency injection pattern.
5
- */
6
-
7
- // --- Core Utilities (Classes and Stateless Helpers) ---
8
-
9
- const core = {
10
- IntelligentHeaderManager: require('./functions/core/utils/intelligent_header_manager').IntelligentHeaderManager,
11
- IntelligentProxyManager: require('./functions/core/utils/intelligent_proxy_manager').IntelligentProxyManager,
12
- FirestoreBatchManager: require('./functions/task-engine/utils/firestore_batch_manager').FirestoreBatchManager,
13
- firestoreUtils: require('./functions/core/utils/firestore_utils'),
14
- pubsubUtils: require('./functions/core/utils/pubsub_utils'),
15
- };
16
-
17
- // --- Pipe 1: Orchestrator ---
18
-
19
- const orchestrator = {
20
- // Main Pipes (Entry points for Cloud Functions)
21
- runDiscoveryOrchestrator: require('./functions/orchestrator/index').runDiscoveryOrchestrator,
22
- runUpdateOrchestrator: require('./functions/orchestrator/index').runUpdateOrchestrator,
23
-
24
- // Sub-Pipes (Discovery)
25
- checkDiscoveryNeed: require('./functions/orchestrator/helpers/discovery_helpers').checkDiscoveryNeed,
26
- getDiscoveryCandidates: require('./functions/orchestrator/helpers/discovery_helpers').getDiscoveryCandidates,
27
- dispatchDiscovery: require('./functions/orchestrator/helpers/discovery_helpers').dispatchDiscovery,
28
-
29
- // Sub-Pipes (Updates)
30
- getUpdateTargets: require('./functions/orchestrator/helpers/update_helpers').getUpdateTargets,
31
- dispatchUpdates: require('./functions/orchestrator/helpers/update_helpers').dispatchUpdates,
32
- };
33
-
34
- // --- Pipe 2: Dispatcher ---
35
-
36
- const dispatcher = {
37
- // Main Pipe
38
- handleRequest: require('./functions/dispatcher/index').handleRequest,
39
-
40
- // Sub-Pipe
41
- dispatchTasksInBatches: require('./functions/dispatcher/helpers/dispatch_helpers').dispatchTasksInBatches,
42
- };
43
-
44
- // --- Pipe 3: Task Engine ---
45
-
46
- const taskEngine = {
47
- // Main Pipe
48
- handleRequest: require('./functions/task-engine/handler_creator').handleRequest,
49
-
50
- // Sub-Pipes
51
- handleDiscover: require('./functions/task-engine/helpers/discover_helpers').handleDiscover,
52
- handleVerify: require('./functions/task-engine/helpers/verify_helpers').handleVerify,
53
- handleUpdate: require('./functions/task-engine/helpers/update_helpers').handleUpdate,
54
- };
55
-
56
- // --- Pipe 4: Computation System ---
57
- const computationSystem = {
58
- // Main Pipe (Scheduler)
59
- runOrchestration: require('./functions/computation-system/helpers/orchestration_helpers').runComputationOrchestrator,
60
-
61
- // Main Pipe (Worker)
62
- handleNodeTask: require('./functions/computation-system/helpers/worker_helpers').handleNodeTask, // <-- Corrected
63
-
64
- // Sub-Pipes (Helpers and Utilities)
65
- dataLoader: require('./functions/computation-system/utils/data_loader'),
66
- computationUtils: require('./functions/computation-system/utils/utils'),
67
- computationStateManager: require('./functions/computation-system/utils/computation_state_manager'), // <-- Added
68
-
69
- // Graph Tools
70
- ComputationGraph: require('./functions/computation-system/utils/dependency_graph').ComputationGraph, // <-- Corrected
71
- dependencyConfig: require('./functions/computation-system/computation_dependencies.json') // <-- Added
72
- }
73
-
74
- // --- Pipe 5: API ---
75
-
76
- const api = {
77
- // Main Pipe
78
- createApiApp: require('./functions/generic-api/index').createApiApp,
79
-
80
- // Sub-Pipes (Helpers exposed for documentation/testing)
81
- helpers: require('./functions/generic-api/helpers/api_helpers'),
82
- };
83
-
84
- // --- Pipe 6: Maintenance ---
85
- // Standalone cleanup and utility functions TODO -- Some of these are not really maintenance pipes, socials could do with its own pipe..?
86
- const maintenance = {
87
- runSpeculatorCleanup: require('./functions/speculator-cleanup-orchestrator/helpers/cleanup_helpers').runCleanup,
88
- handleInvalidSpeculator: require('./functions/invalid-speculator-handler/helpers/handler_helpers').handleInvalidSpeculator,
89
- runFetchInsights: require('./functions/fetch-insights/helpers/handler_helpers').fetchAndStoreInsights,
90
- runFetchPrices: require('./functions/etoro-price-fetcher/helpers/handler_helpers').fetchAndStorePrices,
91
- runSocialOrchestrator: require('./functions/social-orchestrator/helpers/orchestrator_helpers').runSocialOrchestrator,
92
- handleSocialTask: require('./functions/social-task-handler/helpers/handler_helpers').handleSocialTask,
93
- runBackfillAssetPrices: require('./functions/price-backfill/helpers/handler_helpers').runBackfillAssetPrices,
94
- };
95
-
96
- // --- Pipe 7: Proxy ---
97
-
98
- const proxy = {
99
- handlePost: require('./functions/appscript-api/index').handlePost,
100
- };
101
-
102
- // --- EXPORT THE FINAL PIPE OBJECT ---
103
- module.exports = {
104
- pipe: {
105
- core,
106
- orchestrator,
107
- dispatcher,
108
- taskEngine,
109
- computationSystem,
110
- api,
111
- maintenance,
112
- proxy,
113
- }
1
+ /**
2
+ * @fileoverview Main entry point for the Bulltrackers shared module.
3
+ * This module consolidates all core logic into a single 'pipe' object
4
+ * to enforce a clear naming convention and dependency injection pattern.
5
+ */
6
+
7
+ // --- Core Utilities (Classes and Stateless Helpers) ---
8
+
9
+ const core = {
10
+ IntelligentHeaderManager: require('./functions/core/utils/intelligent_header_manager').IntelligentHeaderManager,
11
+ IntelligentProxyManager: require('./functions/core/utils/intelligent_proxy_manager').IntelligentProxyManager,
12
+ FirestoreBatchManager: require('./functions/task-engine/utils/firestore_batch_manager').FirestoreBatchManager,
13
+ firestoreUtils: require('./functions/core/utils/firestore_utils'),
14
+ pubsubUtils: require('./functions/core/utils/pubsub_utils'),
15
+ };
16
+
17
+ // --- Pipe 1: Orchestrator ---
18
+
19
+ const orchestrator = {
20
+ // Main Pipes (Entry points for Cloud Functions)
21
+ runDiscoveryOrchestrator: require('./functions/orchestrator/index').runDiscoveryOrchestrator,
22
+ runUpdateOrchestrator: require('./functions/orchestrator/index').runUpdateOrchestrator,
23
+
24
+ // Sub-Pipes (Discovery)
25
+ checkDiscoveryNeed: require('./functions/orchestrator/helpers/discovery_helpers').checkDiscoveryNeed,
26
+ getDiscoveryCandidates: require('./functions/orchestrator/helpers/discovery_helpers').getDiscoveryCandidates,
27
+ dispatchDiscovery: require('./functions/orchestrator/helpers/discovery_helpers').dispatchDiscovery,
28
+
29
+ // Sub-Pipes (Updates)
30
+ getUpdateTargets: require('./functions/orchestrator/helpers/update_helpers').getUpdateTargets,
31
+ dispatchUpdates: require('./functions/orchestrator/helpers/update_helpers').dispatchUpdates,
32
+ };
33
+
34
+ // --- Pipe 2: Dispatcher ---
35
+
36
+ const dispatcher = {
37
+ // Main Pipe
38
+ handleRequest: require('./functions/dispatcher/index').handleRequest,
39
+
40
+ // Sub-Pipe
41
+ dispatchTasksInBatches: require('./functions/dispatcher/helpers/dispatch_helpers').dispatchTasksInBatches,
42
+ };
43
+
44
+ // --- Pipe 3: Task Engine ---
45
+
46
+ const taskEngine = {
47
+ // Main Pipe
48
+ handleRequest: require('./functions/task-engine/handler_creator').handleRequest,
49
+
50
+ // Sub-Pipes
51
+ handleDiscover: require('./functions/task-engine/helpers/discover_helpers').handleDiscover,
52
+ handleVerify: require('./functions/task-engine/helpers/verify_helpers').handleVerify,
53
+ handleUpdate: require('./functions/task-engine/helpers/update_helpers').handleUpdate,
54
+ };
55
+
56
+ // --- Pipe 4: Computation System ---
57
+ const computationSystem = {
58
+ // Main Pipe
59
+ runOrchestration: require('./functions/computation-system/helpers/orchestration_helpers').runComputationOrchestrator,
60
+
61
+ // Sub-Pipes (Exposing utils for potential external use)
62
+ dataLoader: require('./functions/computation-system/utils/data_loader'),
63
+ computationUtils: require('./functions/computation-system/utils/utils'),
64
+ };
65
+
66
+ // --- Pipe 5: API ---
67
+
68
+ const api = {
69
+ // Main Pipe
70
+ createApiApp: require('./functions/generic-api/index').createApiApp,
71
+
72
+ // Sub-Pipes (Helpers exposed for documentation/testing)
73
+ helpers: require('./functions/generic-api/helpers/api_helpers'),
74
+ };
75
+
76
+ // --- Pipe 6: Maintenance ---
77
+ // Standalone cleanup and utility functions TODO -- Some of these are not really maintenance pipes, socials could do with its own pipe..?
78
+ const maintenance = {
79
+ runSpeculatorCleanup: require('./functions/speculator-cleanup-orchestrator/helpers/cleanup_helpers').runCleanup,
80
+ handleInvalidSpeculator: require('./functions/invalid-speculator-handler/helpers/handler_helpers').handleInvalidSpeculator,
81
+ runFetchInsights: require('./functions/fetch-insights/helpers/handler_helpers').fetchAndStoreInsights,
82
+ runFetchPrices: require('./functions/etoro-price-fetcher/helpers/handler_helpers').fetchAndStorePrices,
83
+ runSocialOrchestrator: require('./functions/social-orchestrator/helpers/orchestrator_helpers').runSocialOrchestrator,
84
+ handleSocialTask: require('./functions/social-task-handler/helpers/handler_helpers').handleSocialTask,
85
+ runBackfillAssetPrices: require('./functions/price-backfill/helpers/handler_helpers').runBackfillAssetPrices,
86
+ };
87
+
88
+ // --- Pipe 7: Proxy ---
89
+
90
+ const proxy = {
91
+ handlePost: require('./functions/appscript-api/index').handlePost,
92
+ };
93
+
94
+ // --- EXPORT THE FINAL PIPE OBJECT ---
95
+ module.exports = {
96
+ pipe: {
97
+ core,
98
+ orchestrator,
99
+ dispatcher,
100
+ taskEngine,
101
+ computationSystem,
102
+ api,
103
+ maintenance,
104
+ proxy,
105
+ }
114
106
  };
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "bulltrackers-module",
3
- "version": "1.0.104",
4
- "description": "Helper Functions for Bulltrackers.",
5
- "main": "index.js",
6
- "files": [
7
- "index.js",
8
- "functions/orchestrator/",
9
- "functions/task-engine/",
10
- "functions/core/",
11
- "functions/computation-system/",
12
- "functions/generic-api/",
13
- "functions/dispatcher/",
14
- "functions/invalid-speculator-handler/",
15
- "functions/speculator-cleanup-orchestrator/",
16
- "functions/fetch-insights/",
17
- "functions/etoro-price-fetcher/",
18
- "functions/appscript-api/",
19
- "functions/social-orchestrator/",
20
- "functions/social-task-handler/",
21
- "functions/price-backfill/"
22
- ],
23
- "keywords": [
24
- "bulltrackers",
25
- "etoro",
26
- "precompute",
27
- "calculations",
28
- "finance"
29
- ],
30
- "dependencies": {
31
- "@google-cloud/firestore": "^7.11.3",
32
- "sharedsetup": "latest",
33
- "require-all": "^3.0.0",
34
- "@google-cloud/pubsub": "latest",
35
- "express": "^4.19.2",
36
- "cors": "^2.8.5",
37
- "p-limit": "^3.1.0"
38
- },
39
- "engines": {
40
- "node": ">=20"
41
- },
42
- "publishConfig": {
43
- "access": "public"
44
- }
45
- }
1
+ {
2
+ "name": "bulltrackers-module",
3
+ "version": "1.0.106",
4
+ "description": "Helper Functions for Bulltrackers.",
5
+ "main": "index.js",
6
+ "files": [
7
+ "index.js",
8
+ "functions/orchestrator/",
9
+ "functions/task-engine/",
10
+ "functions/core/",
11
+ "functions/computation-system/",
12
+ "functions/generic-api/",
13
+ "functions/dispatcher/",
14
+ "functions/invalid-speculator-handler/",
15
+ "functions/speculator-cleanup-orchestrator/",
16
+ "functions/fetch-insights/",
17
+ "functions/etoro-price-fetcher/",
18
+ "functions/appscript-api/",
19
+ "functions/social-orchestrator/",
20
+ "functions/social-task-handler/",
21
+ "functions/price-backfill/"
22
+ ],
23
+ "keywords": [
24
+ "bulltrackers",
25
+ "etoro",
26
+ "precompute",
27
+ "calculations",
28
+ "finance"
29
+ ],
30
+ "dependencies": {
31
+ "@google-cloud/firestore": "^7.11.3",
32
+ "sharedsetup": "latest",
33
+ "require-all": "^3.0.0",
34
+ "@google-cloud/pubsub": "latest",
35
+ "express": "^4.19.2",
36
+ "cors": "^2.8.5",
37
+ "p-limit": "^3.1.0"
38
+ },
39
+ "engines": {
40
+ "node": ">=20"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ }
45
+ }
@@ -1,120 +0,0 @@
1
- {
2
- "dependencies": {
3
- "smart-cohort-flow": ["user-investment-profile"],
4
- "dumb-cohort-flow": ["user-investment-profile"],
5
- "crowd_sharpe_ratio_proxy": ["pnl-distribution-per-stock"],
6
- "social_flow_correlation": [
7
- "social_sentiment_aggregation",
8
- "asset_crowd_flow"
9
- ],
10
- "cash-flow-deployment": [
11
- "crowd-cash-flow-proxy",
12
- "asset_crowd_flow"
13
- ],
14
- "cash-flow-liquidation": [
15
- "crowd-cash-flow-proxy",
16
- "asset_crowd_flow"
17
- ],
18
- "capital_deployment_strategy": [
19
- "crowd-cash-flow-proxy",
20
- "new-allocation-percentage",
21
- "reallocation-increase-percentage"
22
- ],
23
- "profit_cohort_divergence": [
24
- "in-profit-asset-crowd-flow",
25
- "in-loss-asset-crowd-flow"
26
- ],
27
- "smart-dumb-divergence-index": [
28
- "smart-cohort-flow",
29
- "dumb-cohort-flow"
30
- ],
31
- "capital_vintage_performance": ["cash-flow-deployment"],
32
- "capital_liquidation_performance": ["cash-flow-liquidation"],
33
- "strategy-performance": [
34
- "smart-dumb-divergence-index",
35
- "profit_cohort_divergence"
36
- ]
37
- },
38
- "requirements": {
39
- "activity_by_pnl_status": ["today_portfolio", "yesterday_portfolio"],
40
- "daily_asset_activity": ["today_portfolio", "yesterday_portfolio"],
41
- "daily_user_activity_tracker": ["today_portfolio", "yesterday_portfolio"],
42
- "speculator_adjustment_activity": ["today_portfolio", "yesterday_portfolio"],
43
- "asset_position_size": ["today_portfolio"],
44
- "strategy-performance": ["meta"],
45
- "asset_crowd_flow": ["today_portfolio", "yesterday_portfolio"],
46
- "drawdown_response": ["today_portfolio", "yesterday_portfolio"],
47
- "dumb-cohort-flow": ["today_portfolio", "yesterday_portfolio"],
48
- "gain_response": ["today_portfolio", "yesterday_portfolio"],
49
- "in_loss_asset_crowd_flow": ["today_portfolio", "yesterday_portfolio"],
50
- "in_profit_asset_crowd_flow": ["today_portfolio", "yesterday_portfolio"],
51
- "paper_vs_diamond_hands": ["today_portfolio", "yesterday_portfolio"],
52
- "position_count_pnl": ["today_portfolio"],
53
- "smart-cohort-flow": ["today_portfolio", "yesterday_portfolio"],
54
- "smart_money_flow": ["today_portfolio", "yesterday_portfolio"],
55
- "user-investment-profile": ["today_portfolio", "yesterday_portfolio"],
56
- "crowd-cash-flow-proxy": ["today_portfolio", "yesterday_portfolio"],
57
- "deposit_withdrawal_percentage": ["today_portfolio", "yesterday_portfolio"],
58
- "new_allocation_percentage": ["today_portfolio", "yesterday_portfolio"],
59
- "reallocation_increase_percentage": ["today_portfolio", "yesterday_portfolio"],
60
- "daily_bought_vs_sold_count": ["today_insights", "yesterday_insights"],
61
- "daily_buy_sell_sentiment_count": ["today_insights"],
62
- "daily_ownership_delta": ["today_insights", "yesterday_insights"],
63
- "daily_total_positions_held": ["today_insights"],
64
- "capital_deployment_strategy": ["meta"],
65
- "cash-flow-deployment": ["meta"],
66
- "cash-flow-liquidation": ["meta"],
67
- "crowd_sharpe_ratio_proxy": ["meta"],
68
- "profit_cohort_divergence": ["meta"],
69
- "smart-dumb-divergence-index": ["meta"],
70
- "social_flow_correlation": ["meta"],
71
- "capital_liquidation_performance": ["meta"],
72
- "capital_vintage_performance": ["meta"],
73
- "profitability_migration": ["today_portfolio", "yesterday_portfolio"],
74
- "user_profitability_tracker": ["today_portfolio"],
75
- "asset_pnl_status": ["today_portfolio"],
76
- "average_daily_pnl_all_users": ["today_portfolio"],
77
- "average_daily_pnl_per_sector": ["today_portfolio"],
78
- "average_daily_pnl_per_stock": ["today_portfolio"],
79
- "average_daily_position_pnl": ["today_portfolio"],
80
- "pnl_distribution_per_stock": ["today_portfolio"],
81
- "profitability_ratio_per_stock": ["today_portfolio"],
82
- "profitability_skew_per_stock": ["today_portfolio"],
83
- "profitable_and_unprofitable_status": ["today_portfolio"],
84
- "users_processed": ["today_portfolio"],
85
- "diversification_pnl": ["today_portfolio", "yesterday_portfolio"],
86
- "sector_rotation": ["today_portfolio", "yesterday_portfolio"],
87
- "total_long_per_sector": ["today_portfolio"],
88
- "total_short_per_sector": ["today_portfolio"],
89
- "crowd_conviction_score": ["today_portfolio", "yesterday_portfolio"],
90
- "long_position_per_stock": ["today_portfolio"],
91
- "sentiment_per_stock": ["today_portfolio"],
92
- "short_position_per_stock": ["today_portfolio"],
93
- "total_long_figures": ["today_portfolio"],
94
- "total_short_figures": ["today_portfolio"],
95
- "social-asset-posts-trend": ["today_social"],
96
- "social-top-mentioned-words": ["today_social", "yesterday_social"],
97
- "social-topic-interest-evolution": ["today_social"],
98
- "social-word-mentions-trend": ["today_social"],
99
- "social_activity_aggregation": ["today_social"],
100
- "social_event_correlation": ["today_social", "yesterday_social"],
101
- "social_sentiment_aggregation": ["today_social"],
102
- "risk_appetite_change": ["today_portfolio", "yesterday_portfolio"],
103
- "tsl_effectiveness": ["today_portfolio"],
104
- "distance_to_stop_loss_per_leverage": ["today_portfolio"],
105
- "distance_to_tp_per_leverage": ["today_portfolio"],
106
- "entry_distance_to_sl_per_leverage": ["today_portfolio"],
107
- "entry_distance_to_tp_per_leverage": ["today_portfolio"],
108
- "holding_duration_per_asset": ["today_portfolio"],
109
- "leverage_per_asset": ["today_portfolio"],
110
- "leverage_per_sector": ["today_portfolio"],
111
- "risk_reward_ratio_per_asset": ["today_portfolio"],
112
- "speculator_asset_sentiment": ["today_portfolio"],
113
- "speculator_danger_zone": ["today_portfolio"],
114
- "stop_loss_distance_by_sector_short_long_breakdown": ["today_portfolio"],
115
- "stop_loss_distance_by_ticker_short_long_breakdown": ["today_portfolio"],
116
- "stop_loss_per_asset": ["today_portfolio"],
117
- "take_profit_per_asset": ["today_portfolio"],
118
- "tsl_per_asset": ["today_portfolio"]
119
- }
120
- }