Skip to content

Commit

Permalink
include 0 growth into report
Browse files Browse the repository at this point in the history
  • Loading branch information
rustboyar committed Jun 11, 2024
1 parent 0e4b61f commit 5f76087
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/reports/__snapshots__/capo-report.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exports[`capo report > should generate a well formatted capo report 1`] = `
| Max Yearly % | Max Day-to-day yearly % | Max 7-day yearly % |
| --- | --- | --- | --- |
| --- | --- | --- |
| 8.75% | 4.91% | 3.65% |
Expand Down
24 changes: 12 additions & 12 deletions src/reports/capo-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Price = {
export async function generateCapoReport(snapshot: CapoSnapshot) {
// map to dates and formatted values

const prices: Price[] = [];
let prices: Price[] = [];

let maxDayToDayGrowth = 0;
let maxSmoothedGrowth = 0;
Expand All @@ -32,21 +32,21 @@ export async function generateCapoReport(snapshot: CapoSnapshot) {

const formattedDate = formatTimestamp(price.timestamp);

if (price.smoothedGrowth > 0) {
prices.push({
sourcePrice,
referencePrice,
diff,
dayToDayGrowth,
smoothedGrowth,
date: formattedDate,
});
}
prices.push({
sourcePrice,
referencePrice,
diff,
dayToDayGrowth,
smoothedGrowth,
date: formattedDate,
});

maxDayToDayGrowth = Math.max(maxDayToDayGrowth, price.dayToDayGrowth);
maxSmoothedGrowth = Math.max(maxSmoothedGrowth, price.smoothedGrowth);
}

prices = prices.slice(snapshot.minSnapshotDelay);

// generate md report
let content = '';
content += `# Capo Report\n\n`;
Expand All @@ -63,7 +63,7 @@ export async function generateCapoReport(snapshot: CapoSnapshot) {

content += `\n\n`;
content += `| Max Yearly % | Max Day-to-day yearly % | Max ${snapshot.minSnapshotDelay}-day yearly % | \n`;
content += `| --- | --- | --- | --- |\n`;
content += `| --- | --- | --- |\n`;
content += `| ${maxYearlyGrowthPercent}% | ${maxDayToDayGrowthPercent}% | ${maxSmoothedGrowthPercent}% | \n`;
content += `\n\n`;

Expand Down

0 comments on commit 5f76087

Please sign in to comment.