2014-01-27

Display Commodity Prices on the Desktop using GeekTool

I couldn't find any website showing how to display commodity prices on the desktop using GeekTool, so I just wrote it up on my own.

I asked a few of my friends working for investment banks and decided to use commodity prices listed on Bloomberg as real-time references.

7 commodities were chosen this time based on the influence on global economy:
Gold Spot [USD/t oz]
Silver Spot [USD/t oz]
Crude Oil (WTI) [USD/bbl.]
NYMEX Natural Gas [USD/MMBtu]
CBOT Corn [USD/bu.]
CBOT Wheat [USD/bu.]
CBOT Soybeans [USD/bu.]
Other than "Gold Spot" and "Silver Spot", they are all futures.


I set the font colour of "Change (Up)" as green and "Change (Down)" as red.


Gold Spot Price
curl "http://www.bloomberg.com/markets/commodities/futures/metals/" | grep -A 2 'Gold Spot' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

Gold Spot Change (Up)
curl "http://www.bloomberg.com/markets/commodities/futures/metals/" | grep -A 4 'Gold Spot' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

Gold Spot Change (Down)
curl "http://www.bloomberg.com/markets/commodities/futures/metals/" | grep -A 4 'Gold Spot' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

Silver Spot Price
curl "http://www.bloomberg.com/markets/commodities/futures/metals/" | grep -A 2 'US Dollar Spot' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

Silver Spot Change (Up)
curl "http://www.bloomberg.com/markets/commodities/futures/metals/" | grep -A 4 'US Dollar Spot' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

Silver Spot Change (Down)
curl "http://www.bloomberg.com/markets/commodities/futures/metals/" | grep -A 4 'US Dollar Spot' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

Crude Oil (WTI) Price
curl "http://www.bloomberg.com/energy/" | grep -A 2 '(WTI)' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

Crude Oil (WTI) Change (Up)
curl "http://www.bloomberg.com/energy/" | grep -A 4 '(WTI)' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

Crude Oil (WTI) Change (Down)
curl "http://www.bloomberg.com/energy/" | grep -A 4 '(WTI)' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

NYMEX Natural Gas Price
curl "http://www.bloomberg.com/energy/" | grep -A 2 'NYMEX Natural Gas' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

NYMEX Natural Gas Change (Up)
curl "http://www.bloomberg.com/energy/" | grep -A 4 'NYMEX Natural Gas' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

NYMEX Natural Gas Change (Down)
curl "http://www.bloomberg.com/energy/" | grep -A 4 'NYMEX Natural Gas' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

CBOT Corn Price
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 2 'CBOT Corn' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

CBOT Corn Change (Up)
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 4 'CBOT Corn' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

CBOT Corn Change (Down)
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 4 'CBOT Corn' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

CBOT Wheat Price
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 2 'CBOT Wheat' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

CBOT Wheat Change (Up)
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 4 'CBOT Wheat' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

CBOT Wheat Change (Down)
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 4 'CBOT Wheat' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

CBOT Soybeans Price
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 2 'CBOT Soybeans' | sed '1,2d' | sed -e 's/<td>//' | sed -e 's/<\/td>//' | sed -e 's/ //g'

CBOT Soybeans Change (Up)
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 4 'CBOT Soybeans' | sed '1,3d' | grep 'class="up"' | sed -e '1s/<td class="up">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="up">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

CBOT Soybeans Change (Down)
curl "http://www.bloomberg.com/markets/commodities/futures/agriculture/" | grep -A 4 'CBOT Soybeans' | sed '1,3d' | grep 'class="down"' | sed -e '1s/<td class="down">//' | sed -e '1s/<\/td>//' | sed -e '2s/<td class="down">/(/' | sed -e '2s/<\/td>/)/' | sed -e 's/ //g' | tr -d '\r\n'

Here is a screenshot of my desktop.

0 件のコメント:

コメントを投稿