Jump to content

Downloadin stock prices


This topic is 6766 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi,

I am writing a db with the intent of comparing the prices of a list of stocks over a period of time. To do this I import prices daily with an applescript which takes me to yahoo from where I can download my list in spreadsheet form. Then I import to FM.

It would be ever so convenient to be able to do this from within FM7 with a script.

Any suggestions?

Thanks

yknot

Link to comment
Share on other sites

You can run the AppleScript code in a Perform AppleScript step. I'd like to see the AppleScript myself, if it's not proprietary. There is also the Unix "curl" command: do shell script "curl http://www.fentonjones.com", which will get the raw source from a link, and optionally write it to a file.

But if you download it as a spreadsheet it should be easy enough to import into FileMaker. I'm kind of wondering where you're stuck, as it sounds as if you have most of the pieces and skills for automation already.

Link to comment
Share on other sites

Hi Fenton,

Thanks for the reply. Following is the applescript routine:

tell application "Finder"

if the file ("Macintosh HD:users:yknot:desktop:quotes.csv") exists then

display dialog "Quotes.csv exists on the desktop and will be deleted"

tell application "Finder"

delete the file ("Macintosh HD:users:yknot:desktop:quotes.csv")

end tell

else

display dialog "It ain't there"

end if

end tell

tell application "Finder"

if the file ("Macintosh HD:users:yknot:desktop:downloads:quotes.csv") exists then

display dialog "Quotes.csv exists in the download folder and will be deleted"

tell application "Finder"

delete the file ("Macintosh HD:users:yknot:desktop:downloads:quotes.csv")

end tell

else

display dialog "It ain't there"

end if

end tell

property target_URL :) "http://finance.yahoo.com/q?s=,ibm,dell,dia,qqq,&d=v1"

open location target_URL

This all works fine if I run it from the desktop and then do an import routine into FM. Yahoo displays the stocks and then prompts me to download it to a csv file.

When I run this routine as part of a FM script it does not work. The hangup must be that the script is unable to respond to the prompt by yahoo

Any further thoughts are appreciated,

yknot

Link to comment
Share on other sites

I moved the topic to the AppleScript forum, as it's mostly about that. There are other more automated ways to download the file. I'm using the URL Access Scripting application. The advantages is it doesn't require Safari, and does not open a web page. I'm using the download link to the .csv file directly (which I copied off the web site). I'm assuming that it will continue to work.

I slimmed down the script, and made it just go to the Desktop, which is referenced generically (so it will work on everyone's machine, not just yours :)-). The URL Access Scripting application's (System, Library, Scripting Additions) download command requires a file specification for the destination. The "Downloads" folder may be different for some people, so I just used the Desktop.

I also didn't see the point in telling someone that the file isn't there. I don't see much point in telling them it is either; why not just delete it?

[Caveat: I had to go zip the silly URL Access Scripting file in the OS 9 System Folder, Scripting Additions folder. It's named the same as its OS X counterpart, and AppleScript kept trying to launch Classic. Annoying, especially since I don't think I've ever used Classic on this computer.]

As to importing the file, you can just set up an Import step once, and it should work file. If you run the script from FileMaker, you'd like want to pause a little, to give the file time to download. The attached file has that. It uses a Script Variable, so requires FileMaker 8 to run as is; but you could easily retarget the Import for yourself (the desktop cannot be set as an Import location in FileMaker 7).

------------------------------------

set DT to ((path to desktop) as string)

set DT_quotes to (DT & "quotes.csv")

tell application "Finder"

if the file (DT & "quotes.csv") exists then

display dialog "Quotes.csv exists on the desktop and will be deleted" with icon caution

if result is "" then

return -- this stops the script if they hit "Cancel"

end if

delete the file (DT & "quotes.csv")

end if

end tell

property target_csv : "http://finance.yahoo.com/d/quotes.csv?s=IBM,DELL,DIA,QQQQ,AAPL&f=sl1d1t1c1ohgv&e=.csv"

tell application "URL Access Scripting"

download target_csv to file DT_quotes

end tell

Download_Quotes2.zip

Edited by Guest
Changed the file
Link to comment
Share on other sites

  • 4 weeks later...

Hi Fenton,

How would I include the % chg column from the Yahoo Finance webside in the script step you provided? I tried a few changes to your step but just managed to screw it up.

Your step is: property target_csv : "http://finance.yahoo.com/d/quotes.csv?s=IBM,DELL,DIA,QQQQ,AAPL&f=sl1d1t1c1ohgv&e=.csv"

And where can I find instructions on how to download from the web?

Thanks,

yknot

Link to comment
Share on other sites

I don't know. Maybe it's from the day before? If so you could calculate it. As you can see, I know next to nothing about the stock market. I got the URL by copying the "Download as a spreadsheet" link on your original page. They don't give you instructions on that page about how to customize the URL (nor do I think you'll find them, as they're trying to get you to sign up to a pay-for-data service).

Link to comment
Share on other sites

This topic is 6766 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.