Stock Quote & Chart Dashing Dashboard consists of two widgets. While one displays a stock's current quote and other details; another displays its last 30-days closing stock prices.
Add the gem to your dashing gemfile:
gem 'json'
and run bundle install
.
First, copy stock.coffee
, stock.html
, and stock.sass
into the /widgets/stock
directory and chart.coffee
, chart.html
, and chart.sass
into the /widgets/chart
directory. Put the yahoo_stock_quote.rb
and yahoo_stock_quote.rb
files in the /jobs
folder.
To use the widget, put the following codes into one of the /dashboards
directory's .erb
file:
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="yahoo_stock_quote" data-view="Stock" data-prefix="$"></div>
</li>
<li data-row="1" data-col="1" data-sizex="3" data-sizey="1">
<div data-id="yahoo_stock_chart" data-view="Chart" data-prefix="$"></div>
</li>
There are two jobs running for this dashboard, which are yahoo_stock_quote.rb
and yahoo_stock_chart.rb
. yahoo_stock_quote.rb
selects data from yahoo.finance.quotes
table, and yahoo_stock_chart.rb
retrieves data from yahoo.finance.historicaldata
table. You can change to another stock with the following line within the jobs.
symbol = "YHOO"
@adityai - Are the tiles not displaying on the dashboard itself? Meaning, you've added the HTML above into your dashboard's
.erb
file but they are not showing up? Or are the tiles there but the data isn't presenting?@aleza84 - It seems like it was just a typo.
@howardsternisbatman - The query from Yahoo returns 6 decimal places, but what you can do is edit line 26 in
yahoo_stock_chart.rb
to include.round(2)
after.to_f
. In other words, you'll want:point << { x: i, y: q["Close"].to_f}
...to be:
point << { x: i, y: q["Close"].to_f.round(2)}
.