Skip to content

Commit f5e0f75

Browse files
authored
Merge pull request #40 from carlolm/master
add: input date ranges into summary stats
2 parents 96862b2 + 57958b9 commit f5e0f75

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

client/src/components/SummaryStats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SummaryStats extends Component {
3030
console.log(files[0].name);
3131
const fileName = files[0].name;
3232
CSV.parseCSV(reader.result).then((strategyData) => {
33-
const summaryStats = calcSummaryStats(strategyData);
33+
const summaryStats = calcSummaryStats(strategyData, '1/1/00', '9/1/17');
3434
this.setState({ strategyData, summaryStats, fileName });
3535
});
3636
};

client/src/utils/dataAnalysis.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ const calcSummaryStats = (priceData, startDate, endDate) => {
133133
let asset = priceData;
134134

135135
if (startDate && endDate) {
136-
console.log(startDate, endDate);
137-
asset = asset.filter(data => data.date >= new Date(startDate) && data.date <= new Date(endDate));
136+
asset = asset.filter(data => new Date(data.date) >= (new Date(startDate)) && new Date(data.date) <= (new Date(endDate)));
138137
}
139138

140139
// Calculate Overall Return
140+
console.log(asset);
141141
const first = asset[0];
142142
const last = asset[asset.length - 1];
143143
console.log('******', first, last);

0 commit comments

Comments
 (0)