Skip to content

Commit

Permalink
Add coloring for signals and sentiment
Browse files Browse the repository at this point in the history
  • Loading branch information
alichtman committed Nov 30, 2018
1 parent 62938c4 commit e970ed6
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions bitvision/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ function calculateGaugePercentages(technicalIndicators) {

technicalIndicators.forEach(indicator => {
let signal = indicator[2].toLowerCase().trim();
if (signal === "buy") {
if (signal.includes("buy")) {
totalBuy++;
} else if (signal === "sell") {
} else if (signal.includes("sell")) {
totalSell++;
} else {
ignoreCount++;
Expand Down Expand Up @@ -439,12 +439,33 @@ function refreshInterface() {
let headlineData = headlinesJSON.data.map(article => {
// Truncates each headline by 35 characters
let headline = article[1];
article[1] =
headline.length > 35 ? headline.slice(0, 35) + "..." : headline + "...";

article[1] = headline.length > 35 ? headline.slice(0, 35) + "..." : headline + "...";

// Color sentiment labels
let sentiment = article[2].toLowerCase().trim();
if (sentiment == "pos") {
article[2] = article[2].green;
} else if (sentiment == "neg") {
article[2] = article[2].red;
} else {
article[2] = article[2].yellow;
}
return article;
});
let technicalData = technicalIndicatorJSON.data;

let technicalData = technicalIndicatorJSON.data.map(indicator => {
// Color signal labels
let signal = indicator[2].toLowerCase().trim();
if (signal == "buy") {
indicator[2] = indicator[2].green;
} else if (signal == "sell") {
indicator[2] = indicator[2].red;
} else {
indicator[2] = indicator[2].yellow;
}
return indicator;
});

let gaugeData = calculateGaugePercentages(technicalData);
let blockchainData = blockchainJSON.data;
let tickerData = reformatPriceData(tickerJSON.data);
Expand Down

0 comments on commit e970ed6

Please sign in to comment.