Fedora Linux Support Community & Resources Center
  #1  
Old 26th November 2012, 11:54 PM
nkogkneeto Offline
Registered User
 
Join Date: Nov 2012
Location: san antonio
Posts: 10
linuxfirefox
stock and futures price checker

i would like to know if anyone has ever heard of a command line tool for checking stock or futures prices and if not how hard do you think it would be to make.

i've never wrote a useful program before but i think this is a good idea. i want it to be able to fetch data from forexpros.com since that would be able to check prices for almost anything thats traded around the world.
Reply With Quote
  #2  
Old 27th November 2012, 12:45 AM
ocratato Offline
Registered User
 
Join Date: Oct 2010
Location: Canberra
Posts: 550
linuxfirefox
Re: stock and futures price checker

It appears that Forexpros has a SOAP based interface available with this WSDL so putting together an app should be quite straightforward for those that have done this sort of thing (not me).

I guess that it will be necessary to enter into some sort of agreement with them as I doubt that they will give away all this data freely.
__________________
Don't tell me "The sky is the limit" when there are footprints on the moon.
Reply With Quote
  #3  
Old 3rd December 2012, 02:11 AM
nkogkneeto Offline
Registered User
 
Join Date: Nov 2012
Location: san antonio
Posts: 10
linuxubuntufirefox
Re: stock and futures price checker

alright i figured it out heres what works for me....just make sure you install curl first

Code:
#!/bin/bash

echo "Looking up your quote..."

curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$1}&f=l1"
Just save this as whatever.sh then chmod +x whatever.sh then ./whatever.sh INSERTQUOTESYMBOLHERE to check a quote, try ./whatever.sh GOOG to see googles price.

I'm new to programming anyone know how to help make it to where i can have more arguments work for it? Like say ./whatever.sh GOOG APPL

Last edited by nkogkneeto; 3rd December 2012 at 02:21 AM.
Reply With Quote
  #4  
Old 3rd December 2012, 03:42 AM
PabloTwo's Avatar
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,126
linuxchrome
Re: stock and futures price checker

Nice. I have a laptop that I can mostly only use in console mode due to a hardware graphics issue. This might be nice to check prices when I'm only on that laptop.

Here's a one way of parsing multiple arguments:
Code:
#!/bin/bash

echo "Looking up your quotes..."
for getquote in "$@"
 do
   curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$getquote}&f=l1"
 done
And the results:
Code:
BASH:~/-> ./stock-quote.sh JNJ DUK CVX
Looking up your quotes...
69.73
63.82
105.69
I'd add in a printf line so each price quote was adjacent to, either before or after, the stock symbol associated with it for more clarity.

---------- Post added at 10:42 PM ---------- Previous post was at 10:20 PM ----------

Here's the improved version with printf:
Code:
#!/bin/bash

echo "Looking up your quotes..."
for getquote in "$@"
 do
   printf "%b" "$getquote\t"
   curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$getquote}&f=l1"
 done
And the results:
Code:
BASH:~/-> ./stock-quote.sh HQH FOF GGN
Looking up your quotes...
HQH	17.95
FOF	12.70
GGN	13.32

Last edited by PabloTwo; 3rd December 2012 at 03:45 AM.
Reply With Quote
  #5  
Old 3rd December 2012, 04:05 AM
nkogkneeto Offline
Registered User
 
Join Date: Nov 2012
Location: san antonio
Posts: 10
linuxubuntufirefox
Re: stock and futures price checker

cool i like the way that works better i was trying this to make it look better and so i dont have to put any arguments in

Code:
#!/bin/bash

echo 'Looking up your quotes...'
echo \

BONDS='ZBZ12.CBT'
TENYR='ZNZ12.CBT'
FIVEYR='ZFZ12.CBT'
TWOYR='ZTZ12.CBT'
SP500='ESZ12.CME'
EURUSD='EURUSD=X'

echo '30-year bond'
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$BONDS}&f=l1"

echo '-----------------'

echo '10-year note'
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$TENYR}&f=l1"

echo '-----------------'

echo '5-year note'
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$FIVEYR}&f=l1"

echo '-----------------'

echo '2-year note'
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$TWOYR}&f=l1"

echo '-----------------'

echo 'E-mini S&P 500'
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$SP500}&f=l1"

echo '-----------------'

echo 'EUR/USD'
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s={$EURUSD}&f=l1"

echo \
with output of

Code:
incognito@desktop ~ $ ./quoterv2 
Looking up your quotes...

30-year bond
151.4062
-----------------
10-year note
134.125
-----------------
5-year note
124.8438
-----------------
2-year note
110.2422
-----------------
E-mini S&P 500
1414.50
-----------------
EUR/USD
1.3043

Now i just need to figure out how to convert the bond decimal quotes to 32nds, like instead of the 30 year bond printing out 151.35 it should be like 151 13/32

Last edited by nkogkneeto; 3rd December 2012 at 04:07 AM.
Reply With Quote
  #6  
Old 3rd December 2012, 07:28 PM
PabloTwo's Avatar
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 5,126
linuxchrome
Re: stock and futures price checker

I don't know how to convert decimal to fractions (haven't had a need to yet), but I did explore a bit more with pulling down financial info via command line from finance.yahoo<dot>com and came across this interesting page. It lists all the format options (something I was wondering about where to find) and has an example using wget instead of curl. The nice thing about the wget example is that it doesn't require any for loops to handle multiple command line args.

Output was comma separated and I didn't care for that, but couldn't figure out how to change that output other than to pipe things into sed. Much simpler. New code:
Code:
#!/bin/bash

wget -q -O - "http://download.finance.yahoo.com/d/quotes.csv?f=nsl1&s='`echo ${@}`'" | \
sed 's/\,/\t/g'
And the result:
Code:
BASH:~/-> ./stock-quote2 cvx duk jnj
"Chevron Corporati"	"CVX"	104.47
"Duke Energy Corpo"	"DUK"	63.98
"Johnson & Johnson"	"JNJ"	69.41
My only gripe is that on some securities, the quote is delayed a bit too much. While watching prices and trades in "real time" on several stocks this morning, I kept fetching the "last trade" quote from yahoo finance via the command line curl script. Some stock quotes were more than a half hour stale, maybe OK for casual "ball park" monitoring, but not so much on checking for any sudden and fast movements. Oddly, getting a quote directly from Yahoo's webpage was very close to real time (even said so.. "2:26PM EST - Nasdaq Real Time Price".

Last edited by PabloTwo; 3rd December 2012 at 07:31 PM.
Reply With Quote
  #7  
Old 3rd December 2012, 08:55 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,105
linuxfirefox
Re: stock and futures price checker

Now what you want is to retrieve the quotes from two different markets - generate a buy from the low priced one and generate a sell on the high...
Reply With Quote
Reply

Tags
checker, futures, price, stock

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphics card price samara Gamers' Lounge 1 8th November 2012 02:08 PM
vista price cuts Wayne Wibble 66 3rd March 2008 04:09 AM
The Price Is Right kona0197 Wibble 18 18th October 2007 05:36 AM
AMD Price Cut (official prices) Invader02 Wibble 5 27th July 2006 07:38 PM


Current GMT-time: 00:20 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat