aiden-shared-calculations-unified 1.0.8 → 1.0.9

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 (31) hide show
  1. package/calculations/pnl/average_daily_pnl_all_users.js +1 -1
  2. package/calculations/pnl/average_daily_pnl_per_sector.js +1 -1
  3. package/calculations/pnl/average_daily_pnl_per_stock.js +1 -1
  4. package/calculations/pnl/average_daily_position_pnl.js +1 -1
  5. package/calculations/pnl/pnl_distribution_per_stock.js +52 -52
  6. package/calculations/pnl/profitability_ratio_per_stock.js +50 -50
  7. package/calculations/pnl/profitability_skew_per_stock.js +58 -58
  8. package/calculations/sanity/users_processed.js +26 -26
  9. package/calculations/sectors/total_long_per_sector.js +1 -1
  10. package/calculations/sectors/total_short_per_sector.js +1 -1
  11. package/calculations/short_and_long_stats/long_position_per_stock.js +1 -1
  12. package/calculations/short_and_long_stats/sentiment_per_stock.js +49 -49
  13. package/calculations/short_and_long_stats/short_position_per_stock.js +1 -1
  14. package/calculations/short_and_long_stats/total_long_figures.js +1 -1
  15. package/calculations/short_and_long_stats/total_short_figures.js +1 -1
  16. package/calculations/speculators/distance_to_stop_loss_per_leverage.js +78 -78
  17. package/calculations/speculators/distance_to_tp_per_leverage.js +76 -76
  18. package/calculations/speculators/entry_distance_to_sl_per_leverage.js +78 -78
  19. package/calculations/speculators/entry_distance_to_tp_per_leverage.js +77 -77
  20. package/calculations/speculators/holding_duration_per_asset.js +55 -55
  21. package/calculations/speculators/leverage_per_asset.js +46 -46
  22. package/calculations/speculators/leverage_per_sector.js +44 -44
  23. package/calculations/speculators/risk_reward_ratio_per_asset.js +60 -60
  24. package/calculations/speculators/speculator_asset_sentiment.js +81 -81
  25. package/calculations/speculators/speculator_danger_zone.js +57 -57
  26. package/calculations/speculators/stop_loss_distance_by_sector_short_long_breakdown.js +91 -91
  27. package/calculations/speculators/stop_loss_distance_by_ticker_short_long_breakdown.js +73 -73
  28. package/calculations/speculators/stop_loss_per_asset.js +55 -55
  29. package/calculations/speculators/take_profit_per_asset.js +55 -55
  30. package/calculations/speculators/tsl_per_asset.js +51 -51
  31. package/package.json +1 -1
@@ -1,52 +1,52 @@
1
- /**
2
- * @fileoverview Counts how many users have TSL enabled vs. disabled per asset.
3
- */
4
- const { loadInstrumentMappings } = require('../../utils/sector_mapping_provider');
5
-
6
- class TslPerAsset {
7
- constructor() {
8
- this.tslData = {};
9
- this.mappings = null;
10
- }
11
-
12
- process(portfolioData, userId) {
13
- if (portfolioData && portfolioData.PublicPositions) {
14
- for (const position of portfolioData.PublicPositions) {
15
- const instrumentId = position.InstrumentID;
16
- const isTslEnabled = position.IsTslEnabled;
17
-
18
- if (!this.tslData[instrumentId]) {
19
- this.tslData[instrumentId] = { enabled: 0, disabled: 0 };
20
- }
21
-
22
- if (isTslEnabled) {
23
- this.tslData[instrumentId].enabled++;
24
- } else {
25
- this.tslData[instrumentId].disabled++;
26
- }
27
- }
28
- }
29
- }
30
-
31
- async getResult() {
32
- if (!this.mappings) {
33
- this.mappings = await loadInstrumentMappings();
34
- }
35
- const result = {};
36
- for (const instrumentId in this.tslData) {
37
- const ticker = this.mappings.instrumentToTicker[instrumentId] || instrumentId.toString();
38
- result[ticker] = this.tslData[instrumentId];
39
- }
40
- if (Object.keys(result).length === 0) return {};
41
- return {
42
- tsl_per_asset: result
43
- };
44
- }
45
-
46
- reset() {
47
- this.tslData = {};
48
- this.mappings = null;
49
- }
50
- }
51
-
1
+ /**
2
+ * @fileoverview Counts how many users have TSL enabled vs. disabled per asset.
3
+ */
4
+ const { loadInstrumentMappings } = require('../../utils/sector_mapping_provider');
5
+
6
+ class TslPerAsset {
7
+ constructor() {
8
+ this.tslData = {};
9
+ this.mappings = null;
10
+ }
11
+
12
+ process(portfolioData, yesterdayPortfolio, userId, context) {
13
+ if (portfolioData && portfolioData.PublicPositions) {
14
+ for (const position of portfolioData.PublicPositions) {
15
+ const instrumentId = position.InstrumentID;
16
+ const isTslEnabled = position.IsTslEnabled;
17
+
18
+ if (!this.tslData[instrumentId]) {
19
+ this.tslData[instrumentId] = { enabled: 0, disabled: 0 };
20
+ }
21
+
22
+ if (isTslEnabled) {
23
+ this.tslData[instrumentId].enabled++;
24
+ } else {
25
+ this.tslData[instrumentId].disabled++;
26
+ }
27
+ }
28
+ }
29
+ }
30
+
31
+ async getResult() {
32
+ if (!this.mappings) {
33
+ this.mappings = await loadInstrumentMappings();
34
+ }
35
+ const result = {};
36
+ for (const instrumentId in this.tslData) {
37
+ const ticker = this.mappings.instrumentToTicker[instrumentId] || instrumentId.toString();
38
+ result[ticker] = this.tslData[instrumentId];
39
+ }
40
+ if (Object.keys(result).length === 0) return {};
41
+ return {
42
+ tsl_per_asset: result
43
+ };
44
+ }
45
+
46
+ reset() {
47
+ this.tslData = {};
48
+ this.mappings = null;
49
+ }
50
+ }
51
+
52
52
  module.exports = TslPerAsset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiden-shared-calculations-unified",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Shared calculation modules for the BullTrackers Computation System.",
5
5
  "main": "index.js",
6
6
  "files": [