Loading ...
Sorry, an error occurred while loading the content.
 

Re: Grab stock quotes

Expand Messages
  • flo.gehrke
    ... Given data like this: Dow 9,705.62 -34.94 (-0.36%) S&P 500 999.68 +4.93 (0.55%) Nasdaq 1,973.89 -6.82 (-0.34%) The clip... ^!Jump 1 ^!Find
    Message 1 of 15 , Sep 3, 2009
      --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@...> wrote:
      >
      > Ideally, I want to round off the percentages to the nearest 1/10 of a percent, so -0.36%=-0.4% and -0.33%=-0.3%.
      >
      > Can I do this with a clip?

      Given data like this:

      Dow 9,705.62 -34.94 (-0.36%)
      S&P 500 999.68 +4.93 (0.55%)
      Nasdaq 1,973.89 -6.82 (-0.34%)

      The clip...


      ^!Jump 1
      ^!Find "\(-?\K\d+\.\d\d(?=%)" RS
      ^!IfError End
      ; Next long line
      ^!Replace "^$GetSelection$" >> "^$Calc(ROUND(^$GetSelection$*100)/100;1)$" S
      ^!Goto Skip_-3


      would provide the following result:

      Dow 9,705.62 -34.94 (-0.4%)
      S&P 500 999.68 +4.93 (0.6%)
      Nasdaq 1,973.89 -6.82 (-0.3%)

      Regards,
      Flo
    • silvermoonwoman2001
      ... Gave it a shot, here s a clip that will insert the current index quotes exactly as you asked (except the download comes from Yahoo), into the current
      Message 2 of 15 , Sep 3, 2009
        --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@...> wrote:
        >
        > I'm looking to grab the stock price data from Google Finance's home page:
        >
        > http://www.google.com/finance
        >
        > And insert it into the current document in the following format:
        >
        > Dow -0.4% to 9279. S&P -0.5% to 993. Nasdaq -0.5% to 1960.
        >
        > Ideally, I want to round off the percentages to the nearest 1/10 of a percent, so -0.36%=-0.4% and -0.33%=-0.3%.
        >
        > Can I do this with a clip?
        >
        > Thanks
        >

        Gave it a shot, here's a clip that will insert the current index quotes exactly as you asked (except the download comes from Yahoo), into the current document at the current cursor position. You will need to install the program Wget from here:
        <http://www.christopherlewis.com/WGet/WGetFiles.htm>
        Make sure to change the path to wget in the clip as appropriate for your installation.

        ^!SetScreenUpdate Off
        ^!Set %curdoc%=^$GetDocIndex$
        ^!Set %wget%=^$GetShort("C:\Program Files\wgetb\wget.exe")$
        ^!Set %url%="http://download.finance.yahoo.com/d/quotes.csv"
        ^!Set %url%="^%url%?s=INDU,^GSPC,^IXIC&f=np2l1&e=.csv"
        ^!set %s%=^$GetOutput(^%wget% -O - "^%url%")$
        ^!Set %s%=^$StrCapitalize("^%s")$
        ^!Toolbar New Document
        ^!InsertText ^%s%
        ^!Replace "\x22(Dow|S&P|Nasdaq)[^\x22]+?\x22" >> "$1" RAWS
        ^!Replace ",\x22([^\x22%]+?%)\x22," >> " $1 to " RAWS
        ^!Replace "\R" >> "\x20" RASW
        ^!Jump 1
        ^!Find "\d+\.\d\d(?=%)" RS
        ^!IfError Finish
        ^!InsertText ^$Calc(ROUND(^$GetSelection$*100)/100;1)$
        ^!Goto Skip_-3
        :Finish
        ^!Set %s%=^$StrTrim(^$GetText$)$
        ^!Close Discard
        ^!Setdocindex ^%curdoc%
        ^!InsertText ^%s%^P
        ^!Clearvariable %s%
        ;end of clip
      • Hugo Paulissen
        ... Hi Sheri, Great! Here is the same clip in curl-version . I m not familiar with neither of these grabbers . Hugo ^!SetScreenUpdate Off ^!Set
        Message 3 of 15 , Sep 4, 2009
          > Gave it a shot, here's a clip that will insert the current index quotes
          > exactly as you asked (except the download comes from Yahoo),

          Hi Sheri,

          Great! Here is the same clip in "curl-version". I'm not familiar with neither of these "grabbers".

          Hugo

          ^!SetScreenUpdate Off
          ^!Set %curdoc%=^$GetDocIndex$
          ^!Set %curl%=^$GetShort("C:\Program Files\curl-7.19.5\curl.exe")$
          ^!Set %url%="http://download.finance.yahoo.com/d/quotes.csv"
          ^!Set %url%="^%url%?s=INDU,^GSPC,^IXIC&f=np2l1&e=.csv"
          ^!set %s%=^$GetOutput("^%curl% ^%url%")$
          ^!Set %s%=^$StrCapitalize("^%s")$
          ^!Toolbar New Document
          ^!InsertText ^%s%
          ^!Replace "\x22(Dow|S&P|Nasdaq)[^\x22]+?\x22" >> "$1" RAWS
          ^!Replace ",\x22([^\x22%]+?%)\x22," >> " $1 to " RAWS
          ^!Replace "\R" >> "\x20" RASW
          ^!Jump 1
          ^!Find "\d+\.\d\d(?=%)" RS
          ^!IfError Finish
          ^!InsertText ^$Calc(ROUND(^$GetSelection$*100)/100;1)$
          ^!Goto Skip_-3
          :Finish
          ^!Set %s%=^$StrTrim(^$GetText$)$
          ^!Close Discard
          ^!Setdocindex ^%curdoc%
          ^!InsertText ^%s%^P
          ^!Clearvariable %s%
          ;end of clip





          [Non-text portions of this message have been removed]
        • ehofferino
          ... Wow - Sheri and Hugo - this is exactly what I m looking for! I can t test it properly now because Yahoo Finance apparently resets S&P and Nasdaq to 0.00%
          Message 4 of 15 , Sep 4, 2009
            --- In ntb-clips@yahoogroups.com, Hugo Paulissen <hugopaulissen@...> wrote:
            >
            > > Gave it a shot, here's a clip that will insert the current index quotes
            > > exactly as you asked (except the download comes from Yahoo),
            >
            > Hi Sheri,
            >
            > Great! Here is the same clip in "curl-version". I'm not familiar with neither of these "grabbers".
            >
            > Hugo
            >
            > ^!SetScreenUpdate Off
            > ^!Set %curdoc%=^$GetDocIndex$
            > ^!Set %curl%=^$GetShort("C:\Program Files\curl-7.19.5\curl.exe")$
            > ^!Set %url%="http://download.finance.yahoo.com/d/quotes.csv"
            > ^!Set %url%="^%url%?s=INDU,^GSPC,^IXIC&f=np2l1&e=.csv"
            > ^!set %s%=^$GetOutput("^%curl% ^%url%")$
            > ^!Set %s%=^$StrCapitalize("^%s")$
            > ^!Toolbar New Document
            > ^!InsertText ^%s%
            > ^!Replace "\x22(Dow|S&P|Nasdaq)[^\x22]+?\x22" >> "$1" RAWS
            > ^!Replace ",\x22([^\x22%]+?%)\x22," >> " $1 to " RAWS
            > ^!Replace "\R" >> "\x20" RASW
            > ^!Jump 1
            > ^!Find "\d+\.\d\d(?=%)" RS
            > ^!IfError Finish
            > ^!InsertText ^$Calc(ROUND(^$GetSelection$*100)/100;1)$
            > ^!Goto Skip_-3
            > :Finish
            > ^!Set %s%=^$StrTrim(^$GetText$)$
            > ^!Close Discard
            > ^!Setdocindex ^%curdoc%
            > ^!InsertText ^%s%^P
            > ^!Clearvariable %s%
            > ;end of clip
            >
            >
            >
            >
            >
            > [Non-text portions of this message have been removed]
            >


            Wow - Sheri and Hugo - this is exactly what I'm looking for! I can't test it properly now because Yahoo Finance apparently resets S&P and Nasdaq to 0.00% until the open at some point in the evening, but the clip runs as expected. Will test more thoroughly once the market opens.

            Until then, I'm going to study each line to figure out what you've done here, and will ask if there's anything I can't decipher. This is SO instructive! Thank you so much!!
          • Art Kocsis
            Sheri & Hugo: I have read with great interest your posts regarding this problem. I have just spent over a week trying to program an app in Javascript & HTML to
            Message 5 of 15 , Sep 5, 2009
              Sheri & Hugo:

              I have read with great interest your posts regarding this problem. I have
              just spent over a week trying to program an app in Javascript & HTML to
              extract and format data from some very large (>3.5 MB) web pages. JS seemed
              a natural environment as I could just use the DOM and not have to parse the
              HTML code. However, I ran into cross-scripting security issues and on-load
              event handler problems which turned a (supposed to be) automatic process to
              semi-automatic.
              They also cost a LOT of time debugging the app.

              (Sheri, I thought your suggestion for writing HTAs might be the answer but
              they will only execute in Internet Explorer. That is a deal killer due to
              IE's security holes and its failure to support standard Javascript.)

              In the process of writing clips to post-process the Javascript outputs I
              have learned a great deal and acquired a huge respect for RegEx. So putting
              all three (curl/wget, cross tab editing and RegEx), together I think I can
              rewrite the entire app in NoteTab. Wish me luck!

              [Note: I need your powerful luck as the gremlins have already struck & I
              ran into a bug in ^!Append processing. See separate post.]

              And thank you very much for your posts. They are always informative.

              Namaste', Art

              For every expert, there is an equal and opposite expert.
              Arthur
              C. Clarke

              ----------


              No virus found in this outgoing message.
              Checked by AVG - www.avg.com
              Version: 8.5.409 / Virus Database: 270.13.78/2347 - Release Date: 09/05/09 05:51:00


              [Non-text portions of this message have been removed]
            • silvermoonwoman2001
              ... Actually though HTAs will open in IE if you try, they are supposed to open with mshta.exe as local (not online) apps. Their main drawback is they work only
              Message 6 of 15 , Sep 5, 2009
                --- In ntb-clips@yahoogroups.com, Art Kocsis <artkns@...> wrote:
                >
                > (Sheri, I thought your suggestion for writing HTAs might be the
                > answer but they will only execute in Internet Explorer. That is a
                > deal killer due to IE's security holes and its failure to support
                > standard Javascript.)

                Actually though HTAs will open in IE if you try, they are supposed to open with mshta.exe as local (not online) apps. Their main drawback is they work only on Windows.

                Regards,
                Sheri
              • Art Kocsis
                Actually, windows is not a problem for me but Inernet Explorer is. The app I am writing needs access to the internet (to get the web pages to scrape) and
                Message 7 of 15 , Sep 5, 2009
                  Actually, windows is not a problem for me but Inernet Explorer is.
                  The app I am writing needs access to the internet (to get the web
                  pages to scrape) and approach I took required support of the HTML DOM.
                  Only under pain of excruciating death would I use IE.

                  Fortunately, as I recently posted, thanks to all the helpful posts
                  these past few days, I have reversed my approach and will now
                  do everything in NoteTab at ten times the speed and a fraction
                  of the effort. Thank you RegEx!

                  Although I will accomplish my task this time using only NoteTab,
                  there is a huge need for an app engine that will make leverage
                  Javascript, HTML, the DOMs, etc in creating platform independent
                  apps. Accessing and mashing data from multiple domain is getting
                  quite common and will be more so in the future. The cross domain
                  scripting security problem needs to be solved.

                  Thanks for all your help, Art

                  At 09-05-2009 21:01, you wrote:
                  >In <mailto:ntb-clips%40yahoogroups.com>ntb-clips@yahoogroups.com, Art
                  >Kocsis <artkns@...> wrote:
                  > >
                  > > (Sheri, I thought your suggestion for writing HTAs might be the
                  > > answer but they will only execute in Internet Explorer. That is a
                  > > deal killer due to IE's security holes and its failure to support
                  > > standard Javascript.)
                  >
                  >Actually though HTAs will open in IE if you try, they are supposed to open
                  >with mshta.exe as local (not online) apps. Their main drawback is they
                  >work only on Windows.
                  >
                  >Regards,
                  >Sheri

                  ----------


                  No virus found in this outgoing message.
                  Checked by AVG - www.avg.com
                  Version: 8.5.409 / Virus Database: 270.13.79/2348 - Release Date: 09/05/09 17:50:00


                  [Non-text portions of this message have been removed]
                Your message has been successfully submitted and would be delivered to recipients shortly.