diff --git a/app/src/components/Graph.js b/app/src/components/Graph.js index 710b152f..6b6e0736 100644 --- a/app/src/components/Graph.js +++ b/app/src/components/Graph.js @@ -156,25 +156,35 @@ const Graph = ({ ...entries ]; + // Logic to add last entry if necessary const lastEntry = entries[entries.length - 1]; + const noTrades = entries.length === 0; + const isBeforeResolutionDate = getMoment(resolutionDate).isAfter( getMoment() ); - const isLastEntryBeforeResolutionDate = getMoment( - lastEntry.date - ).isBefore(getMoment(resolutionDate)); - if (isBeforeResolutionDate || isLastEntryBeforeResolutionDate) { + const isLastEntryBeforeResolutionDate = + !noTrades && + getMoment(lastEntry.date).isBefore(getMoment(resolutionDate)); + + if ( + isBeforeResolutionDate || + noTrades || + isLastEntryBeforeResolutionDate + ) { // Only add last entry (with current probabilities) if the market is not already resolved. // When market is resolved, if latest trade is before selected resolution date, duplicate latest trade // but adjust to show on resolution date (in some special cases there can be trades a bit after resolution date) const newEntry = isBeforeResolutionDate ? { outcomesProbability: currentProbability, - date: +new Date() + date: getMoment().valueOf() } : { - outcomesProbability: lastEntry.outcomesProbability, + outcomesProbability: noTrades + ? initialOutcomesProbability + : lastEntry.outcomesProbability, date: getMoment(resolutionDate).valueOf() }; newData.push({