bulltrackers-module 1.0.372 → 1.0.374
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.
|
@@ -54,6 +54,7 @@ class TradeSeriesBuilder {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
|
|
57
58
|
class SocialExtractor {
|
|
58
59
|
static getDiscussions(socialData) {
|
|
59
60
|
return socialData?.discussions || [];
|
|
@@ -333,6 +334,40 @@ class HistoryExtractor {
|
|
|
333
334
|
return historyDoc?.CreditByRealizedEquity || 0;
|
|
334
335
|
}
|
|
335
336
|
|
|
337
|
+
// --- [RESTORED METHOD] ---
|
|
338
|
+
static getDailyHistory(historyDoc) {
|
|
339
|
+
const trades = this.getTrades(historyDoc);
|
|
340
|
+
if (!trades.length) return [];
|
|
341
|
+
|
|
342
|
+
const dailyMap = new Map();
|
|
343
|
+
|
|
344
|
+
for (const t of trades) {
|
|
345
|
+
if (!t.CloseDateTime) continue;
|
|
346
|
+
// Extract YYYY-MM-DD
|
|
347
|
+
const date = new Date(t.CloseDateTime).toISOString().slice(0, 10);
|
|
348
|
+
const pnl = t.NetProfit || 0;
|
|
349
|
+
const invested = t.Amount || t.Invested || 0; // Handle schema variance
|
|
350
|
+
|
|
351
|
+
if (!dailyMap.has(date)) {
|
|
352
|
+
dailyMap.set(date, {
|
|
353
|
+
date: date,
|
|
354
|
+
netProfit: 0,
|
|
355
|
+
investedVolume: 0,
|
|
356
|
+
tradesCount: 0
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const entry = dailyMap.get(date);
|
|
361
|
+
entry.netProfit += pnl;
|
|
362
|
+
entry.investedVolume += invested;
|
|
363
|
+
entry.tradesCount++;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Return sorted array
|
|
367
|
+
return Array.from(dailyMap.values()).sort((a, b) => a.date.localeCompare(b.date));
|
|
368
|
+
}
|
|
369
|
+
// -------------------------
|
|
370
|
+
|
|
336
371
|
static getTradedAssets(historyDoc) {
|
|
337
372
|
const trades = this.getTrades(historyDoc);
|
|
338
373
|
if (!trades.length) return [];
|