Stock Streaks with CloudQuote

In this example below you will see how to do a Stock Streaks with CloudQuote with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by mdierolf, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright mdierolf ©
  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Stock Streaks with CloudQuote</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <script src="https://lib.cloudquote.net/tag.js"></script>
<cq-provider tag="fc-quote" src="http://quote.financialcontent.com/cloudquote"></cq-provider>

<cq-provider tag="fc-quotesearch" src="http://quote.financialcontent.com/cloudquoteSearch"></cq-provider>

<fc-quotesearch tag="STREAK/+2" style="display:none">
renderStreak(document.getElementById('table1'),arguments[0]);
</fc-quotesearch>
<fc-quotesearch tag="STREAK/-2" style="display:none">
renderStreak(document.getElementById('table2'),arguments[0]);
</fc-quotesearch>

<h2>Stocks with 2 day or longer winning streak</h2>
<table id="table1">
  <tr>
    <th>SymbolID</th>
    <th>Symbol</th>
    <th>Price</th>
  </tr>
</table>

<h2>Streak -2</h2>
<table id="table2">
  <tr>
    <th>SymbolID</th>
    <th>Symbol</th>
    <th>Price</th>
  </tr>
</table>
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/mdierolf/stock-streaks-with-cloudquote-JXyLdR */
th {
  background: #999;
  color: #FFF;
  line-height: 2;
  padding: 0 15px;
}
td {
  line-height: 2;
  padding: 0 15px;
  background: #EEE;
}

/*Downloaded from https://www.codeseek.co/mdierolf/stock-streaks-with-cloudquote-JXyLdR */
function renderStreak(el, rows) {
 if (rows == null) {
   return;
 }
 for (var i = 0; i < rows.length; i++) {
  var row = rows[i];
   window.cq.buildHTMLTree(el, [
    {"tr": [
     {"td": row.SymbolID},
     {"td": [
      {"fc-quote" : [
       {"@symbol" : row.SymbolID,
        "@field" : "symbol"
       }
      ]},
     ]},
     {"td": [
      {"fc-quote" : [
       {"@symbol" : row.SymbolID,
        "@field" : "price"
       }
      ]} 
     ]}
    ]}
   ]);
  }
  window.cq.scan();
}

Comments