Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 18 Jun 2013, 01:52
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
getting stock data from yahoo finance
Post new topic   Reply to topic View previous topic :: View next topic
Page 4 of 4 [50 Posts]   Goto page: Previous 1, 2, 3, 4
Author Message
jpeps

Joined: 31 May 2008
Posts: 2448

PostPosted: Mon 06 Feb 2012, 17:42    Post subject:  

Cute! Glad it eliminates all those pesky 4 letter stocks, like MSFT.
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 2448

PostPosted: Mon 06 Feb 2012, 20:37    Post subject:  

seaside's script; reads 4 char symbols


Code:

#!/bin/sh


#!/bin/bash
# stock ticker- seaside February 6, 2012
# yad version 16.2 required
# stock retrieval ideas from technosaurus

symlist="/root/quotepage"

PIPE=/tmp/stockpipe
mkfifo $PIPE
exec 3<> $PIPE
trap on_exit EXIT


function on_exit () {
    echo "quit" >&3
    rm -f $PIPE
}

export -f on_exit

yad --notification --kill-parent --listen \
    --image=gtk-stop --text="Stock Ticker" \
    --command="geany $symlist" <&3 &
   
# set sample stock info
   
[[ ! -f $symlist ]] && echo 'ibm
dis
goog ' >$symlist

LINE=1

while true; do


STK=`sed -n "${LINE}p" $symlist`

[ "$STK" = "" ] && LINE=1 && STK=`sed -n "${LINE}p" $symlist` #ran out of lines


QUOTE=`wget -q -O - "http://download.finance.yahoo.com/d/quotes.csv?f=sb3c1&s=$STK"`
#returns "IBM",180.27,-1.77

 oldIFS=$IFS
 IFS=","
  read STOCK BID CHANGE<<<"$QUOTE"
 IFS=$oldIFS
 
 STOCK="${STOCK//\"/}"
 STOCK="${STOCK:0:4}"
 BID="${BID:0:5}"

  case $CHANGE in
 -*)  BG=#FF6F55 ;; #light red
 +*)  BG=#90EE90 ;; #light green
 *)  BG=#C7E7F1 ;;  #light blue
 esac

 
  # technosaurus' use of svg for icons
   echo '<svg>
   <rect width="64" height="64" x="0" y="0"
     style="fill:'"$BG"'"/>
   <text x="0.79569316" y="22"
     style="font-size:22px"
     >'"$STOCK"'</text>
   <text x="1" y="48"
     style="font-size:22px;font-weight:bold"
     >'"$BID"'</text>
 </svg> ' >/tmp/stockicon.svg
   
   echo icon:/tmp/stockicon.svg >$PIPE # send notice to change icon
     
 
  LINE=$[LINE+1]
 
  sleep 3
  # Wait before checking again.

done

Last edited by jpeps on Tue 07 Feb 2012, 12:49; edited 1 time in total
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 841

PostPosted: Mon 06 Feb 2012, 21:28    Post subject:  

jpeps wrote:
seaside's script; reads 4 char symbols


jpeps,

Great! I don't know how you squeezed that extra char out by increasing the bottom price pixel to 22. It is counter-intuitive and absolutely beyond me. Smile Smile

Anyway, no one should have any excuses for losing money on the stock market, given these tools. Smile

Regards,
s
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 2448

PostPosted: Mon 06 Feb 2012, 22:15    Post subject:  

seaside wrote:
jpeps wrote:
seaside's script; reads 4 char symbols


jpeps,

Great! I don't know how you squeezed that extra char out by increasing the bottom price pixel to 22. It is counter-intuitive and absolutely beyond me. Smile Smile

Anyway, no one should have any excuses for losing money on the stock market, given these tools. Smile

Regards,
s


The icon size appears to be fixed, so increasing the rect ht, width numbers scales the font size smaller. When I don't understand something, trial & error often works wonders!
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 841

PostPosted: Tue 07 Feb 2012, 00:38    Post subject:  

jpeps,

Good find. It just never even occurred to me to change the width height bigger than the tray icon.

Regards,
s
(Of course, the hard part then is to see exactly what the effect is with each change..... maybe a GUI for that Smile )
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 4 of 4 [50 Posts]   Goto page: Previous 1, 2, 3, 4
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0475s ][ Queries: 13 (0.0057s) ][ GZIP on ]