Skip to content

Commit

Permalink
Merge pull request #68 from TrustyFund/hotfix/bad-history-data-fix
Browse files Browse the repository at this point in the history
hotfix/bad-data-from-history
  • Loading branch information
roma219 authored Apr 5, 2018
2 parents 74643c8 + 4ca94ac commit b049d19
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ export const getPrices = (history) => {
if (!history.length) return { first: 0, last: 0 };
const startElem = history[0];
const endElem = history[history.length - 1];
const startPrice = startElem.open_base / startElem.open_quote;
const endPrice = endElem.close_base / endElem.close_quote;
// || 1 when node sends bad data ( 0 )
const startPrice = (startElem.open_base || 1) / (startElem.open_quote || 1);
const endPrice = (endElem.close_base || 1) / (endElem.close_quote || 1);
if (!startElem.open_base || !startElem.close_base ||
!startElem.open_quote || !endElem.close_quote) {
console.warn('[MARKET] : bad price history');
}
return { first: startPrice, last: endPrice };
};

Expand Down

0 comments on commit b049d19

Please sign in to comment.