data scraping with Yahoo Finance/ StockWatch
I finally found the way to alter the StockWatch object so I am able to get more data than the standard 5 data. However, there is something strange going on with the URL. I mailed cycling support but they told me to ask it on the forum, so here is the mail I send them:
You have to set the features to get teh data you want. For example, with the original object you get 5 data however, if you add some lettercodes to the URL in the JAVA-code you can get more data (for example, I can receive nowthe opening price becasue I added the code o0). I have to add some more stu Now, what is really weird is that when I delete the original lettercodes in the URL and replace them with my featureset, I get errors when I run the object. However, when I leave those codes in place, the object runs fine although I have duplicate data in the beginning and ending of the URL.
Here is the original URL: "http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv"
here is my URL (this one does not work): "http://finance.yahoo.com/d/quotes.csv?f=c8b2a5a2b3b6b4c1m7m5k4j5p2c6c4h0g0m0w1r1d0y0e0j4e7e9e8f6d1l1k3t1j1j3n0t8o0r5r0m8m6k5j6p0p6r6r7p5s6s1j2s7x0s0m4v0k0j0w0&e=.csv";
Here is my URL but with the beginning and ending from the original (this one works): "http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1v0c4c8b2a5a2b3b6b4c1m7m5k4j5p2c6c4h0g0m0w1r1d0y0e0j4e7e9e8f6d1l1k3t1j1j3n0t8o0r5r0m8m6k5j6p0p6r6r7p5s6s1j2s7x0s0m4v0k0j0w0ohgv&e=.csv";
I am attaching the Javacode of my object so those who want can have a look
Continuing to delve in the StockWatch object, I found that I can use only lettersymbols like AAPL for Apple. When I try to lookup a stock on international markets for example UMI.BR which is Umicore at the Brussels Stock Exchange, I get an error. Every symbol that has a dot or other sign in it gives me errors. I tried to change the dot to HEXcode but i still get errors. I should probably change something in the code but with my limited JAVA-skills that is quite difficult. Anyone can give me a hand here?
What errors are you getting? Are they coming back from the API call?
Let me explain what I do exactly: I took the original Stockwatch object and altered a fw things in the code to get more datapoints. These alterations are:
1) Change the classname into DataScapR
2) change the URL features (more info here on how I did that: http://code.google.com/p/yahoo-finance-managed/wiki/csvQuotesDownload)
3) change the static final int (adding the new datapooints in this list): For example static final int CHANGEREALTIME = 17 ;
4) Equally expand the atomList until 60 (as there are 60 different datapoints I want to dowload each time): Atom.newAtom(nfo[ 32 ]),
5) As I have 60 datapoints the index counts until 61: if(idx >= 61) break;
6) as well as in the addquotes section: _syms.put(sym, new String[61]);
Now, When I lookup Apple (AAPL) or Amzon (AMZN) I have no problems. Looking up Umicore (UMI.BR) I get errors but after a minute he gets the data. Looking up Coal India (COALINDIA.BO) I get the following errors:
Exception in thread "Thread-19" java.lang.NullPointerException
at com.cycling74.max.Atom$StringAtom.(Atom.java:222)
at com.cycling74.max.Atom$StringAtom.(Atom.java:215)
at com.cycling74.max.Atom.newAtom(Atom.java:352)
at DataScapR.run(DataScapR.java:201)
at java.lang.Thread.run(Thread.java:680)
Strangely enough, on the original StockWatch patch, I do not have this problem but I cannot see what I am doing wrong
I am adding my class and the altered StockWatch patch so you can have a look. To use it: Clear all quotes using the clear message, then add a quote (UMI.BR, AAPL and COALINDIA.BO) are included and you should only selct one of those, if you want to change clear the slot first to avoid errors. If everything goes ok, you get to see the data in the Max window and the scroller, otherwise you see errors and the scroller freezes.
You'll need to eyeball the data. I'm guessing that something you're getting back means that you aren't fully populating the string arrays indexed by the quote symbols.
I cannot edit my post so here is what I did (and i am still doing): I started from scratch again with the original StockWatch object and started adding one parameter each time and then compile and run it. What I have noticed is:
1) You really cannot take away the features that were available in the original URL
2) You need to add a redundant feature after the normal parameters otherwise you get errors. For now I just add c8 (after hours change). So that does not show up in the print but somehow I do not get errors