Stock price Applescript- for display on Control Pges

Posted on
Thu Apr 02, 2009 10:58 am
Briand9 offline
Posts: 28
Joined: May 23, 2008
Location: Florida

Stock price Applescript- for display on Control Pges

Has anyone figured out a way to write an applescript that gets stock prices? I looked extensively online, and found several scripts, and even tried the apple provided one in the script menu, but none worked. I couldn't even get them to work outside Indigo. Does anyone have any idea? I assume I would have to use SOAP? But I have never used it. Thanks.

Posted on
Fri Apr 03, 2009 5:03 am
Matt offline
Posts: 406
Joined: Aug 13, 2006
Location: Northern Idaho

(No subject)

Go here ( http://www.ovolab.com/phlink/resources.php ) and download the Web scripts file. I don't know what it includes, but it sounds like it might be what you need.

Posted on
Sat Apr 04, 2009 10:19 am
bobeast offline
User avatar
Posts: 400
Joined: Apr 16, 2003

Re: Stock price Applescript- for display on Control Pges

Briand9 wrote:
Has anyone figured out a way to write an applescript that gets stock prices? I looked extensively online, and found several scripts, and even tried the apple provided one in the script menu, but none worked. I couldn't even get them to work outside Indigo. Does anyone have any idea? I assume I would have to use SOAP? But I have never used it. Thanks.


On Leopard, at least, Apple already provides an example script to retrieve a stock quote via SOAP. The file is located @

/Library/Scripts/Internet Services/Stock Quote.scpt

Unfortunately, It returned an error for me, but you might want to give it a try. Let me know if it works for you.

Choose to chance the rapids.
Dare to dance the tide.

Posted on
Sat Apr 04, 2009 1:03 pm
lalisingh offline
Posts: 166
Joined: Mar 27, 2007

(No subject)

I have not tired to do this on a control page but the following technique should work.

1)Create a spreadsheet in Google Docs(Sign up is free)

2)Use hyperlinks to the appropriate charts and stock prices in the spreadsheet

3)Embed the spreadsheet in your control page

Not sure how you edit the css/html for the control page.

Posted on
Sun May 31, 2009 9:53 pm
Briand9 offline
Posts: 28
Joined: May 23, 2008
Location: Florida

(No subject)

Thanks to Matt, I finally had a moment to download the web scripts folder he mentioned. I found the script file I need, but am having trouble modifying it. I am not using ovolab phlink at all, but hoped to use the first part of the script to call the stock quote or a set stock or a indicator (DJIA, NASDAQ etc). My initial thought was just to leave in the Phlink code, since that seems to get the number, and just use something like a

tell application "IndigoServer"
set value of variable "AppleStock" to call_result as string
end tell

Obviously this didn't work. I don't know anything about Phlink, and am very new to applescripting. Is there anyone out there that can help me to edit this code? Thanks a lot. I am sure there are a lot of people out there that would love to see stock quotes on their control pages. Thanks!


Code: Select all
-- This script looks up the delayed stock quote for "AAPL" on the web.
-- Requires an active connection to the Internet.

-- To customize this script for looking up a different stock quote, replace the symbol ("AAPL") below with the appropriate value.

-- Portions of this script courtesy of Apple Computer, Inc.. See sample scripts in /Library/Scripts/Internet Services/ for more details.

property SOAP_Endpoint_URL : "http://services.xmethods.net:80/soap"
property SOAP_app : "soap"
property method_name : "getQuote"
property method_namespace_URI : "urn:xmethods-delayed-quotes"
property SOAP_action : ""

on do_action given call:c, callername:n, callerid:cid, tonesequence:seq
   set this_text to "AAPL"
   
   set the method_parameters to {symbol:this_text}
   
   copy my SOAP_call(SOAP_Endpoint_URL, method_name, method_namespace_URI, method_parameters, SOAP_action) to {call_indicator, call_result}
   tell application "Ovolab Phlink.app"
      tell c
         if the call_indicator is false then
            «event miscSpk » "An error occurred." & return & return & call_result
         else
            «event miscSpk » "The stock quote for " & this_text & " is: " & call_result & " dollars."
         end if
      end tell
   end tell
end do_action

on SOAP_call(SOAP_Endpoint_URL, method_name, method_namespace_URI, method_parameters, SOAP_action)
   try
      with timeout of 10 seconds
         using terms from application "http://www.apple.com/placebo"
            tell application SOAP_Endpoint_URL
               set this_result to call soap ¬
                  {method name:method_name ¬
                     , method namespace uri:method_namespace_URI ¬
                     , parameters:method_parameters ¬
                     , SOAPAction:SOAP_action}
            end tell
         end using terms from
         return {true, this_result}
      end timeout
   on error error_message number error_number
      if the error_number is -916 then ¬
         set the error_message to "The script was unable to establish a connection to the Internet."
      return {false, error_message}
   end try
end SOAP_call

tell application "IndigoServer"
   set value of variable "AppleStock" to call_result as string
end tell

Posted on
Mon Jun 01, 2009 9:57 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

Briand9 wrote:
Thanks to Matt, I finally had a moment to download the web scripts folder he mentioned. I found the script file I need, but am having trouble modifying it. I am not using ovolab phlink at all, but hoped to use the first part of the script to call the stock quote or a set stock or a indicator (DJIA, NASDAQ etc).


It appears that the services.xmethods.net soap server is no longer available (at least it won't resolve on my Mac). However, there is a much easier way that I just ran across:

Code: Select all
tell application "IndigoServer"
   set value of variable "AppleStock" to do shell script "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=l1'"
end tell


Works nicely, at least in my limited (ran it twice) testing... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jun 01, 2009 7:38 pm
Briand9 offline
Posts: 28
Joined: May 23, 2008
Location: Florida

(No subject)

Thanks Jay! It works perfectly! I have been trying to figure this one out for a while. Now I have more data at my fingertips on my control page. I love having one page where I can see a LOT of relevant info. Thanks again. I am sure there are other people out there that will be happy to see this post.

Posted on
Sun Aug 11, 2013 1:08 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Stock price Applescript- for display on Control Pges

Great little script Jay, thanks for posting, works great. Thinking it would be nice to have the percent of change
of the stock in addition to it. Anyone come across a script that might be able to do that?
I have a Hue light that I thought would be cool to reflect the change by it's color.

Thanks,

Carl

Posted on
Mon Aug 12, 2013 4:04 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Stock price Applescript- for display on Control Pges

replace "l1" with a "c0" and you get the change in absolute $ and %

this link explains the available codes.
http://code.google.com/p/yahoo-finance- ... teProperty

and this one explains the whole syntax
http://code.google.com/p/yahoo-finance- ... esDownload

Karl

Posted on
Wed Aug 14, 2013 5:35 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Stock price Applescript- for display on Control Pges

Perfect. Thanks a bunch. Now I can have Indigo track my meager stocks and
display the not so good news :-)

Carl

Posted on
Wed Aug 14, 2013 7:47 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Stock price Applescript- for display on Control Pges

cool name, wrong spelling

Karl

Posted on
Wed Aug 14, 2013 9:12 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Stock price Applescript- for display on Control Pges

:-)

Posted on
Wed Aug 21, 2013 4:54 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Stock price Applescript- for display on Control Pges

In Jay's script might it be possible to use the value of a variable for the stock name?

Code: Select all
tell application "IndigoServer"
   set value of variable "AppleStock" to do shell script "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=l1'"
end tell


Tried a number of things but seeing it's actually a shell script the usual suspects aren't working.

Thanks,

Carl

Posted on
Wed Aug 21, 2013 9:29 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Stock price Applescript- for display on Control Pges

Carl
this works

set stock to "ibm"
set stockvalue to do shell script "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=" & stock & "&f=l1'"

tell application indigoserver
set value of variable "IBMStock" to stockvalue
end

Karl

going from C to K

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 25 guests