aiden-shared-calculations-unified 1.0.76 → 1.0.78
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.
- package/calculations/{pnl/asset_pnl_status.js → core/asset-pnl-status.js} +20 -0
- package/calculations/{asset_metrics/asset_position_size.js → core/asset-position-size.js} +25 -1
- package/calculations/{pnl/average_daily_pnl_all_users.js → core/average-daily-pnl-all-users.js} +22 -0
- package/calculations/{pnl/average_daily_pnl_per_sector.js → core/average-daily-pnl-per-sector.js} +22 -0
- package/calculations/{pnl/average_daily_pnl_per_stock.js → core/average-daily-pnl-per-stock.js} +22 -0
- package/calculations/{pnl/average_daily_position_pnl.js → core/average-daily-position-pnl.js} +22 -0
- package/calculations/{behavioural/historical/holding_duration_per_asset.js → core/holding-duration-per-asset.js} +46 -5
- package/calculations/{meta/gem_instrument-price-momentum.js → core/instrument-price-momentum-20d.js} +17 -4
- package/calculations/{short_and_long_stats/long_position_per_stock.js → core/long-position-per-stock.js} +24 -0
- package/calculations/{behavioural/overall_holding_duration.js → core/overall-holding-duration.js} +27 -3
- package/calculations/{pnl/overall_profitability_ratio.js → core/overall-profitability-ratio.js} +24 -0
- package/calculations/{insights/daily_buy_sell_sentiment_count.js → core/platform-buy-sell-sentiment.js} +22 -0
- package/calculations/{insights/historical/daily_bought_vs_sold_count.js → core/platform-daily-bought-vs-sold-count.js} +24 -1
- package/calculations/{insights/historical/daily_ownership_delta.js → core/platform-daily-ownership-delta.js} +24 -1
- package/calculations/{insights/daily_ownership_per_sector.js → core/platform-ownership-per-sector.js} +22 -0
- package/calculations/{insights/daily_total_positions_held.js → core/platform-total-positions-held.js} +22 -0
- package/calculations/{pnl/pnl_distribution_per_stock.js → core/pnl-distribution-per-stock.js} +24 -0
- package/calculations/{pnl/profitability_ratio_per_sector,js → core/profitability-ratio-per-sector.js} +35 -5
- package/calculations/{pnl/profitability_ratio_per_stock.js → core/profitability-ratio-per-stock.js} +24 -0
- package/calculations/{pnl/profitability_skew_per_stock.js → core/profitability-skew-per-stock.js} +24 -0
- package/calculations/{pnl/profitable_and_unprofitable_status.js → core/profitable-and-unprofitable-status.js} +24 -0
- package/calculations/{short_and_long_stats/sentiment_per_stock.js → core/sentiment-per-stock.js} +20 -0
- package/calculations/{short_and_long_stats/short_position_per_stock.js → core/short-position-per-stock.js} +24 -0
- package/calculations/{socialPosts/social_activity_aggregation.js → core/social-activity-aggregation.js} +32 -8
- package/calculations/{socialPosts → core}/social-asset-posts-trend.js +30 -8
- package/calculations/{socialPosts/social_event_correlation.js → core/social-event-correlation.js} +24 -2
- package/calculations/{socialPosts/social_sentiment_aggregation.js → core/social-sentiment-aggregation.js} +23 -0
- package/calculations/{socialPosts → core}/social-top-mentioned-words.js +31 -8
- package/calculations/{socialPosts → core}/social-topic-interest-evolution.js +35 -11
- package/calculations/{socialPosts → core}/social-topic-sentiment-matrix.js +34 -10
- package/calculations/{socialPosts → core}/social-word-mentions-trend.js +36 -11
- package/calculations/{speculators/speculator_asset_sentiment.js → core/speculator-asset-sentiment.js} +20 -0
- package/calculations/{speculators/speculator_danger_zone.js → core/speculator-danger-zone.js} +22 -0
- package/calculations/{speculators/distance_to_stop_loss_per_leverage.js → core/speculator-distance-to-stop-loss-per-leverage.js} +24 -0
- package/calculations/{speculators/distance_to_tp_per_leverage.js → core/speculator-distance-to-tp-per-leverage.js} +24 -0
- package/calculations/{speculators/entry_distance_to_sl_per_leverage.js → core/speculator-entry-distance-to-sl-per-leverage.js} +24 -0
- package/calculations/{speculators/entry_distance_to_tp_per_leverage.js → core/speculator-entry-distance-to-tp-per-leverage.js} +24 -0
- package/calculations/{speculators/leverage_per_asset.js → core/speculator-leverage-per-asset.js} +20 -0
- package/calculations/{speculators/leverage_per_sector.js → core/speculator-leverage-per-sector.js} +22 -0
- package/calculations/{speculators/risk_reward_ratio_per_asset.js → core/speculator-risk-reward-ratio-per-asset.js} +20 -0
- package/calculations/{speculators/stop_loss_distance_by_sector_short_long_breakdown.js → core/speculator-stop-loss-distance-by-sector-short-long-breakdown.js} +22 -0
- package/calculations/{speculators/stop_loss_distance_by_ticker_short_long_breakdown.js → core/speculator-stop-loss-distance-by-ticker-short-long-breakdown.js} +24 -0
- package/calculations/{speculators/stop_loss_per_asset.js → core/speculator-stop-loss-per-asset.js} +24 -0
- package/calculations/{speculators/take_profit_per_asset.js → core/speculator-take-profit-per-asset.js} +24 -0
- package/calculations/{speculators/tsl_per_asset.js → core/speculator-tsl-per-asset.js} +24 -0
- package/calculations/{short_and_long_stats/total_long_figures.js → core/total-long-figures.js} +24 -0
- package/calculations/{sectors/total_long_per_sector.js → core/total-long-per-sector.js} +22 -0
- package/calculations/{short_and_long_stats/total_short_figures.js → core/total-short-figures.js} +24 -0
- package/calculations/{sectors/total_short_per_sector.js → core/total-short-per-sector.js} +22 -0
- package/calculations/{sanity/users_processed.js → core/users-processed.js} +22 -0
- package/calculations/gauss/cohort-capital-flow.js +217 -0
- package/calculations/gauss/cohort-definer.js +211 -0
- package/calculations/gauss/daily-dna-filter.js +130 -0
- package/calculations/gauss/gauss-divergence-signal.js +160 -0
- package/calculations/{meta/gem_cohort-momentum-state.js → gem/cohort-momentum-state.js} +22 -7
- package/calculations/{behavioural/historical/gem_cohort-skill-definition.js → gem/cohort-skill-definition.js} +18 -1
- package/calculations/{sentiment/gem_platform-conviction-divergence.js → gem/platform-conviction-divergence.js} +13 -0
- package/calculations/{meta/gem_quant-skill-alpha-signal.js → gem/quant-skill-alpha-signal.js} +25 -8
- package/calculations/{behavioural/historical/gem_skilled-cohort-flow.js → gem/skilled-cohort-flow.js} +18 -3
- package/calculations/{meta/gem_skilled-unskilled-divergence.js → gem/skilled-unskilled-divergence.js} +18 -4
- package/calculations/{behavioural/historical/gem_unskilled-cohort-flow.js → gem/unskilled-cohort-flow.js} +18 -3
- package/calculations/helix/helix-contrarian-signal.js +154 -0
- package/calculations/helix/herd-consensus-score.js +152 -0
- package/calculations/helix/winner-loser-flow.js +207 -0
- package/calculations/{behavioural/historical → legacy}/asset_crowd_flow.js +1 -1
- package/calculations/{sentiment/historical → legacy}/crowd_conviction_score.js +1 -1
- package/calculations/{activity/historical → legacy}/daily_asset_activity.js +1 -1
- package/calculations/{behavioural/historical → legacy}/dumb-cohort-flow.js +1 -1
- package/calculations/{behavioural/historical → legacy}/in_loss_asset_crowd_flow.js +1 -1
- package/calculations/{behavioural/historical → legacy}/in_profit_asset_crowd_flow.js +1 -1
- package/calculations/{speculators/historical → legacy}/risk_appetite_change.js +3 -1
- package/calculations/{sectors/historical → legacy}/sector_rotation.js +1 -1
- package/calculations/{behavioural/historical → legacy}/smart-cohort-flow.js +1 -1
- package/calculations/{behavioural/historical → legacy}/smart_money_flow.js +1 -1
- package/calculations/{behavioural/historical → legacy}/user-investment-profile.js +2 -2
- package/calculations/pyro/risk-appetite-index.js +153 -0
- package/calculations/pyro/squeeze-potential.js +158 -0
- package/calculations/pyro/volatility-signal.js +133 -0
- package/package.json +1 -1
- package/calculations/socialPosts/gem_social_sentiment_aggregation.js +0 -146
- /package/calculations/{activity/historical → legacy}/activity_by_pnl_status.js +0 -0
- /package/calculations/{meta → legacy}/capital_deployment_strategy.js +0 -0
- /package/calculations/{meta → legacy}/capital_liquidation_performance.js +0 -0
- /package/calculations/{meta → legacy}/capital_vintage_performance.js +0 -0
- /package/calculations/{meta → legacy}/cash-flow-deployment.js +0 -0
- /package/calculations/{meta → legacy}/cash-flow-liquidation.js +0 -0
- /package/calculations/{capital_flow/historical → legacy}/crowd-cash-flow-proxy.js +0 -0
- /package/calculations/{meta → legacy}/crowd_sharpe_ratio_proxy.js +0 -0
- /package/calculations/{activity/historical → legacy}/daily_user_activity_tracker.js +0 -0
- /package/calculations/{capital_flow/historical → legacy}/deposit_withdrawal_percentage.js +0 -0
- /package/calculations/{sectors/historical → legacy}/diversification_pnl.js +0 -0
- /package/calculations/{behavioural/historical → legacy}/drawdown_response.js +0 -0
- /package/calculations/{behavioural/historical → legacy}/gain_response.js +0 -0
- /package/calculations/{behavioural/historical → legacy}/historical_performance_aggregator.js +0 -0
- /package/calculations/{meta → legacy}/negative_expectancy_cohort_flow.js +0 -0
- /package/calculations/{capital_flow/historical → legacy}/new_allocation_percentage.js +0 -0
- /package/calculations/{behavioural/historical → legacy}/paper_vs_diamond_hands.js +0 -0
- /package/calculations/{behavioural/historical → legacy}/position_count_pnl.js +0 -0
- /package/calculations/{meta → legacy}/positive_expectancy_cohort_flow.js +0 -0
- /package/calculations/{meta → legacy}/profit_cohort_divergence.js +0 -0
- /package/calculations/{pnl/historical → legacy}/profitability_migration.js +0 -0
- /package/calculations/{capital_flow/historical → legacy}/reallocation_increase_percentage.js +0 -0
- /package/calculations/{meta → legacy}/shark_attack_signal.js +0 -0
- /package/calculations/{meta → legacy}/smart-dumb-divergence-index.js +0 -0
- /package/calculations/{meta → legacy}/smart_dumb_divergence_index_v2.js +0 -0
- /package/calculations/{meta → legacy}/social-predictive-regime-state.js +0 -0
- /package/calculations/{meta → legacy}/social-topic-driver-index.js +0 -0
- /package/calculations/{meta → legacy}/social-topic-predictive-potential.js +0 -0
- /package/calculations/{meta → legacy}/social_flow_correlation.js +0 -0
- /package/calculations/{activity/historical → legacy}/speculator_adjustment_activity.js +0 -0
- /package/calculations/{backtests → legacy}/strategy-performance.js +0 -0
- /package/calculations/{speculators/historical → legacy}/tsl_effectiveness.js +0 -0
- /package/calculations/{meta → legacy}/user_expectancy_score.js +0 -0
- /package/calculations/{pnl/historical → legacy}/user_profitability_tracker.js +0 -0
|
@@ -14,6 +14,28 @@ class SocialWordMentionsTrend {
|
|
|
14
14
|
this.keywords = [];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'meta',
|
|
24
|
+
rootDataDependencies: ['social'],
|
|
25
|
+
isHistorical: false, // Stateful
|
|
26
|
+
userType: 'n/a',
|
|
27
|
+
category: 'core_social'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -50,14 +72,15 @@ class SocialWordMentionsTrend {
|
|
|
50
72
|
};
|
|
51
73
|
}
|
|
52
74
|
|
|
75
|
+
// --- REFACTORED ---
|
|
53
76
|
/**
|
|
54
77
|
* @param {string} dateStr - Today's date.
|
|
55
|
-
* @param {object}
|
|
78
|
+
* @param {object} rootData - The root data object.
|
|
79
|
+
* @param {object} dependencies - db, logger, calculationUtils
|
|
56
80
|
* @param {object} config - Computation config.
|
|
57
|
-
* @param {object} fetchedDependencies - (UNUSED) In-memory results.
|
|
58
81
|
*/
|
|
59
|
-
async process(dateStr, dependencies, config
|
|
60
|
-
const {
|
|
82
|
+
async process(dateStr, rootData, dependencies, config) {
|
|
83
|
+
const { calculationUtils } = dependencies;
|
|
61
84
|
|
|
62
85
|
// 1. Load keywords from config (or another source)
|
|
63
86
|
this.keywords = config.trackedKeywords || ['inflation', 'fed', 'AI', 'crypto', 'recession'];
|
|
@@ -67,21 +90,23 @@ class SocialWordMentionsTrend {
|
|
|
67
90
|
|
|
68
91
|
// 3. Initialize state for all keywords
|
|
69
92
|
for (const keyword of this.keywords) {
|
|
70
|
-
|
|
93
|
+
const normalizedKey = keyword.toLowerCase();
|
|
94
|
+
this.keywordData.set(normalizedKey, {
|
|
71
95
|
count: 0,
|
|
72
|
-
history: yHistoryData?.[
|
|
96
|
+
history: yHistoryData?.[normalizedKey]?.history_30d || []
|
|
73
97
|
});
|
|
74
98
|
}
|
|
75
99
|
|
|
76
100
|
// 4. Process today's raw social data
|
|
77
|
-
const todaySocialPosts =
|
|
101
|
+
const todaySocialPosts = rootData.todaySocialPostInsights || {};
|
|
78
102
|
|
|
79
|
-
for (const post of todaySocialPosts) {
|
|
80
|
-
const text = (post.
|
|
103
|
+
for (const post of Object.values(todaySocialPosts)) {
|
|
104
|
+
const text = (post.fullText || '').toLowerCase();
|
|
81
105
|
|
|
82
106
|
for (const keyword of this.keywords) {
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
const normalizedKey = keyword.toLowerCase();
|
|
108
|
+
if (text.includes(normalizedKey)) {
|
|
109
|
+
this.keywordData.get(normalizedKey).count++;
|
|
85
110
|
}
|
|
86
111
|
}
|
|
87
112
|
}
|
|
@@ -50,6 +50,26 @@ class SpeculatorAssetSentiment {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Statically defines all metadata for the manifest builder.
|
|
55
|
+
*/
|
|
56
|
+
static getMetadata() {
|
|
57
|
+
return {
|
|
58
|
+
type: 'standard',
|
|
59
|
+
rootDataDependencies: ['portfolio'],
|
|
60
|
+
isHistorical: false,
|
|
61
|
+
userType: 'speculator',
|
|
62
|
+
category: 'core_speculator'
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Statically declare dependencies.
|
|
68
|
+
*/
|
|
69
|
+
static getDependencies() {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
|
|
53
73
|
_initAsset(instrumentId) {
|
|
54
74
|
if (!this.assets.has(instrumentId)) {
|
|
55
75
|
const createSide = () => ({
|
package/calculations/{speculators/speculator_danger_zone.js → core/speculator-danger-zone.js}
RENAMED
|
@@ -47,6 +47,26 @@ class SpeculatorDangerZone {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Statically defines all metadata for the manifest builder.
|
|
52
|
+
*/
|
|
53
|
+
static getMetadata() {
|
|
54
|
+
return {
|
|
55
|
+
type: 'standard',
|
|
56
|
+
rootDataDependencies: ['portfolio'],
|
|
57
|
+
isHistorical: false,
|
|
58
|
+
userType: 'speculator', // This calc only runs for speculators
|
|
59
|
+
category: 'core_speculator'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Statically declare dependencies.
|
|
65
|
+
*/
|
|
66
|
+
static getDependencies() {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
|
|
50
70
|
_initAsset(instrumentId) {
|
|
51
71
|
if (!this.assets.has(instrumentId)) {
|
|
52
72
|
this.assets.set(instrumentId, {
|
|
@@ -59,6 +79,8 @@ class SpeculatorDangerZone {
|
|
|
59
79
|
}
|
|
60
80
|
|
|
61
81
|
process(portfolioData) {
|
|
82
|
+
// This check is now technically redundant due to `userType` in metadata,
|
|
83
|
+
// but it's good practice to keep it for safety.
|
|
62
84
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
63
85
|
return;
|
|
64
86
|
}
|
|
@@ -14,6 +14,28 @@ class DistanceToStopLossPerLeverage {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -50,6 +72,8 @@ class DistanceToStopLossPerLeverage {
|
|
|
50
72
|
return key;
|
|
51
73
|
}
|
|
52
74
|
|
|
75
|
+
// --- REFACTORED ---
|
|
76
|
+
// Simplified signature
|
|
53
77
|
process(portfolioData) {
|
|
54
78
|
// This calculation is only for speculators
|
|
55
79
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
@@ -14,6 +14,28 @@ class DistanceToTakeProfitPerLeverage {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -50,6 +72,8 @@ class DistanceToTakeProfitPerLeverage {
|
|
|
50
72
|
return key;
|
|
51
73
|
}
|
|
52
74
|
|
|
75
|
+
// --- REFACTORED ---
|
|
76
|
+
// Simplified signature
|
|
53
77
|
process(portfolioData) {
|
|
54
78
|
// This calculation is only for speculators
|
|
55
79
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
@@ -14,6 +14,28 @@ class EntryDistanceToSlPerLeverage {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'], // Needs portfolio.PublicPositions
|
|
25
|
+
isHistorical: false, // Only needs today's data
|
|
26
|
+
userType: 'speculator', // Only runs for speculators
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return []; // Pass 1
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -50,6 +72,8 @@ class EntryDistanceToSlPerLeverage {
|
|
|
50
72
|
return key;
|
|
51
73
|
}
|
|
52
74
|
|
|
75
|
+
// --- REFACTORED ---
|
|
76
|
+
// Simplified signature, as this calc only needs today's portfolio
|
|
53
77
|
process(portfolioData) {
|
|
54
78
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
55
79
|
return;
|
|
@@ -14,6 +14,28 @@ class EntryDistanceToTpPerLeverage {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'], // Needs portfolio.PublicPositions
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator', // Only runs for speculators
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return []; // Pass 1
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -50,6 +72,8 @@ class EntryDistanceToTpPerLeverage {
|
|
|
50
72
|
return key;
|
|
51
73
|
}
|
|
52
74
|
|
|
75
|
+
// --- REFACTORED ---
|
|
76
|
+
// Simplified signature
|
|
53
77
|
process(portfolioData) {
|
|
54
78
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
55
79
|
return;
|
package/calculations/{speculators/leverage_per_asset.js → core/speculator-leverage-per-asset.js}
RENAMED
|
@@ -41,6 +41,26 @@ class LeveragePerAsset {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Statically defines all metadata for the manifest builder.
|
|
46
|
+
*/
|
|
47
|
+
static getMetadata() {
|
|
48
|
+
return {
|
|
49
|
+
type: 'standard',
|
|
50
|
+
rootDataDependencies: ['portfolio'],
|
|
51
|
+
isHistorical: false,
|
|
52
|
+
userType: 'speculator',
|
|
53
|
+
category: 'core_speculator'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Statically declare dependencies.
|
|
59
|
+
*/
|
|
60
|
+
static getDependencies() {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
|
|
44
64
|
_initAsset(instrumentId) {
|
|
45
65
|
if (!this.assets.has(instrumentId)) {
|
|
46
66
|
this.assets.set(instrumentId, {});
|
package/calculations/{speculators/leverage_per_sector.js → core/speculator-leverage-per-sector.js}
RENAMED
|
@@ -13,6 +13,28 @@ class LeveragePerSector {
|
|
|
13
13
|
this.mappings = null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// --- NEW ---
|
|
17
|
+
/**
|
|
18
|
+
* Statically defines all metadata for the manifest builder.
|
|
19
|
+
*/
|
|
20
|
+
static getMetadata() {
|
|
21
|
+
return {
|
|
22
|
+
type: 'standard',
|
|
23
|
+
rootDataDependencies: ['portfolio'],
|
|
24
|
+
isHistorical: false,
|
|
25
|
+
userType: 'speculator',
|
|
26
|
+
category: 'core_speculator'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// --- NEW ---
|
|
31
|
+
/**
|
|
32
|
+
* Statically declare dependencies.
|
|
33
|
+
*/
|
|
34
|
+
static getDependencies() {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
/**
|
|
17
39
|
* Defines the output schema for this calculation.
|
|
18
40
|
* @returns {object} JSON Schema object
|
|
@@ -43,6 +43,26 @@ class RiskRewardRatioPerAsset {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Statically defines all metadata for the manifest builder.
|
|
48
|
+
*/
|
|
49
|
+
static getMetadata() {
|
|
50
|
+
return {
|
|
51
|
+
type: 'standard',
|
|
52
|
+
rootDataDependencies: ['portfolio'],
|
|
53
|
+
isHistorical: false,
|
|
54
|
+
userType: 'speculator',
|
|
55
|
+
category: 'core_speculator'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Statically declare dependencies.
|
|
61
|
+
*/
|
|
62
|
+
static getDependencies() {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
|
|
46
66
|
_initAsset(instrumentId) {
|
|
47
67
|
if (!this.assets.has(instrumentId)) {
|
|
48
68
|
this.assets.set(instrumentId, { sum_rr: 0, count: 0 });
|
|
@@ -14,6 +14,28 @@ class StopLossDistanceBySectorShortLongBreakdown {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -14,6 +14,28 @@ class StopLossDistanceByTickerShortLongBreakdown {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -55,6 +77,8 @@ class StopLossDistanceByTickerShortLongBreakdown {
|
|
|
55
77
|
return arr.reduce((a, b) => a + b, 0) / arr.length;
|
|
56
78
|
}
|
|
57
79
|
|
|
80
|
+
// --- REFACTORED ---
|
|
81
|
+
// Simplified signature
|
|
58
82
|
process(portfolioData) {
|
|
59
83
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
60
84
|
return;
|
package/calculations/{speculators/stop_loss_per_asset.js → core/speculator-stop-loss-per-asset.js}
RENAMED
|
@@ -14,6 +14,28 @@ class StopLossPerAsset {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -61,6 +83,8 @@ class StopLossPerAsset {
|
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
|
|
86
|
+
// --- REFACTORED ---
|
|
87
|
+
// Simplified signature
|
|
64
88
|
process(portfolioData) {
|
|
65
89
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
66
90
|
return;
|
|
@@ -14,6 +14,28 @@ class TakeProfitPerAsset {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -61,6 +83,8 @@ class TakeProfitPerAsset {
|
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
|
|
86
|
+
// --- REFACTORED ---
|
|
87
|
+
// Simplified signature
|
|
64
88
|
process(portfolioData) {
|
|
65
89
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
66
90
|
return;
|
|
@@ -14,6 +14,28 @@ class TslPerAsset {
|
|
|
14
14
|
this.mappings = null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// --- NEW ---
|
|
18
|
+
/**
|
|
19
|
+
* Statically defines all metadata for the manifest builder.
|
|
20
|
+
*/
|
|
21
|
+
static getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
type: 'standard',
|
|
24
|
+
rootDataDependencies: ['portfolio'],
|
|
25
|
+
isHistorical: false,
|
|
26
|
+
userType: 'speculator',
|
|
27
|
+
category: 'core_speculator'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- NEW ---
|
|
32
|
+
/**
|
|
33
|
+
* Statically declare dependencies.
|
|
34
|
+
*/
|
|
35
|
+
static getDependencies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* Defines the output schema for this calculation.
|
|
19
41
|
* @returns {object} JSON Schema object
|
|
@@ -51,6 +73,8 @@ class TslPerAsset {
|
|
|
51
73
|
}
|
|
52
74
|
}
|
|
53
75
|
|
|
76
|
+
// --- REFACTORED ---
|
|
77
|
+
// Simplified signature
|
|
54
78
|
process(portfolioData) {
|
|
55
79
|
if (portfolioData?.context?.userType !== 'speculator') {
|
|
56
80
|
return;
|
package/calculations/{short_and_long_stats/total_long_figures.js → core/total-long-figures.js}
RENAMED
|
@@ -9,6 +9,28 @@ class TotalLongFigures {
|
|
|
9
9
|
this.longCount = 0;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// --- NEW ---
|
|
13
|
+
/**
|
|
14
|
+
* Statically defines all metadata for the manifest builder.
|
|
15
|
+
*/
|
|
16
|
+
static getMetadata() {
|
|
17
|
+
return {
|
|
18
|
+
type: 'standard',
|
|
19
|
+
rootDataDependencies: ['portfolio'],
|
|
20
|
+
isHistorical: false,
|
|
21
|
+
userType: 'all',
|
|
22
|
+
category: 'core_sentiment'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// --- NEW ---
|
|
27
|
+
/**
|
|
28
|
+
* Statically declare dependencies.
|
|
29
|
+
*/
|
|
30
|
+
static getDependencies() {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
|
|
12
34
|
/**
|
|
13
35
|
* Defines the output schema for this calculation.
|
|
14
36
|
* @returns {object} JSON Schema object
|
|
@@ -27,6 +49,8 @@ class TotalLongFigures {
|
|
|
27
49
|
};
|
|
28
50
|
}
|
|
29
51
|
|
|
52
|
+
// --- REFACTORED ---
|
|
53
|
+
// Simplified signature
|
|
30
54
|
process(portfolioData) {
|
|
31
55
|
const positions = portfolioData.PublicPositions || portfolioData.AggregatedPositions;
|
|
32
56
|
if (!positions || !Array.isArray(positions)) {
|
|
@@ -13,6 +13,28 @@ class TotalLongPerSector {
|
|
|
13
13
|
this.mappings = null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// --- NEW ---
|
|
17
|
+
/**
|
|
18
|
+
* Statically defines all metadata for the manifest builder.
|
|
19
|
+
*/
|
|
20
|
+
static getMetadata() {
|
|
21
|
+
return {
|
|
22
|
+
type: 'standard',
|
|
23
|
+
rootDataDependencies: ['portfolio'],
|
|
24
|
+
isHistorical: false,
|
|
25
|
+
userType: 'all',
|
|
26
|
+
category: 'core_sentiment'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// --- NEW ---
|
|
31
|
+
/**
|
|
32
|
+
* Statically declare dependencies.
|
|
33
|
+
*/
|
|
34
|
+
static getDependencies() {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
/**
|
|
17
39
|
* Defines the output schema for this calculation.
|
|
18
40
|
* @returns {object} JSON Schema object
|
package/calculations/{short_and_long_stats/total_short_figures.js → core/total-short-figures.js}
RENAMED
|
@@ -9,6 +9,28 @@ class TotalShortFigures {
|
|
|
9
9
|
this.shortCount = 0;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// --- NEW ---
|
|
13
|
+
/**
|
|
14
|
+
* Statically defines all metadata for the manifest builder.
|
|
15
|
+
*/
|
|
16
|
+
static getMetadata() {
|
|
17
|
+
return {
|
|
18
|
+
type: 'standard',
|
|
19
|
+
rootDataDependencies: ['portfolio'],
|
|
20
|
+
isHistorical: false,
|
|
21
|
+
userType: 'all',
|
|
22
|
+
category: 'core_sentiment'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// --- NEW ---
|
|
27
|
+
/**
|
|
28
|
+
* Statically declare dependencies.
|
|
29
|
+
*/
|
|
30
|
+
static getDependencies() {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
|
|
12
34
|
/**
|
|
13
35
|
* Defines the output schema for this calculation.
|
|
14
36
|
* @returns {object} JSON Schema object
|
|
@@ -27,6 +49,8 @@ class TotalShortFigures {
|
|
|
27
49
|
};
|
|
28
50
|
}
|
|
29
51
|
|
|
52
|
+
// --- REFACTORED ---
|
|
53
|
+
// Simplified signature
|
|
30
54
|
process(portfolioData) {
|
|
31
55
|
const positions = portfolioData.PublicPositions || portfolioData.AggregatedPositions;
|
|
32
56
|
if (!positions || !Array.isArray(positions)) {
|