title: Google Sheets sparklines trend query using Yahoo finance data
body: <p>Can someone help me write a one cell query similar to the one below but using yahoo finance data instead of google finance. This sparkline shows a trend on daily price for the last 365 days and colors the sparkline green or red depending if the current price is higher or lower than the first day from the range provided. In this case 1st day from 365 days.</p>
  
  <p>I really hope this can be done as I don't want to create additional tables or tabs to store data and then produce a sparkline.</p>
  
  <pre><code>=sparkline(query(googlefinance(AAPL, "price", today()-365, today()-2), "select Col2 label Col2 ''", 1),{"color",if( INDEX(googlefinance(AAPL,"price",today()-365),2,2) &lt; INDEX(googlefinance(AAPL, "price", today()-2),2,2),"green","red");"linewidth",2})
  </code></pre>
  
  <p>Here is an example of how to grab the latest price using yahoo finance.</p>
  
  <pre><code>=index(IMPORTXML("https://finance.yahoo.com/quote/AAPL","//*[@id='quote-header-info']//span"),2)
  </code></pre>