GetStocks (fetch stock data)
Moderators: EViews Gareth, EViews Moderator, EViews Esther
-
- Posts: 4
- Joined: Sat Jan 15, 2011 1:40 pm
Re: GetStocks (fetch stock data)
Fantastic. Thanks a million.
Re: GetStocks (fetch stock data)
I cannot download commodity futures or indices. Is everything on Yahoo Finance able to be downloaded?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
-
- Posts: 19
- Joined: Fri Oct 09, 2009 1:14 am
Re: GetStocks (fetch stock data)
Love this code, you guys are awesome. I tweaked the code a little (tweaked code attached) so that it pullls australian stock market data rather than US (can't just use the icharts .ax suffix as this would imply a period in the output eviews object names). australian users might find it useful.
- Attachments
-
- getstocks.prg
- (8.31 KiB) Downloaded 475 times
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
-
- Posts: 168
- Joined: Mon Apr 13, 2009 7:39 am
- Location: New York City
Re: GetStocks (fetch stock data)
Would it be even better if you combine the two programs by adding an "Australia or United States" radio button on the ui?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
Re: GetStocks (fetch stock data)
Even better would be a drop down with a whole bunch of countries to select from.
I'm a bit tied down with other projects at the moment, but I'll put some thought into a refresh at some point in the future (unless anyone else wants to take a stab).
I'm a bit tied down with other projects at the moment, but I'll put some thought into a refresh at some point in the future (unless anyone else wants to take a stab).
Follow us on Twitter @IHSEViews
-
- Posts: 19
- Joined: Fri Oct 09, 2009 1:14 am
Re: GetStocks (fetch stock data)
tchaithonov wrote:Would it be even better if you combine the two programs by adding an "Australia or United States" radio button on the ui?
i could probably do that actually, there are only a few lines needed changing... just have a radio button attached to a !market = 1, have "if !market >0 then /bla bla bla with the .ax suffix/ else /"bla bla bla without the .ax" /endif each time the lines come up...
i was just adding in some code to pulll mcap and book/val ratios (lil bit more tricky), i might get back to the us/aus switch afterwards
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
Re: GetStocks (fetch stock data)
If you're fiddling around with the code, somewhere in there I put in a hack to allow stocks with names that EViews doesn't like:
This could probably be change to use the @makevalidname function, which would handle all illegal characters, rather than just a starting "^". That might help you out with your periods too.
Code: Select all
if @left(%stock,1) = "^" then 'handle the case where a stock name starts with "^", which is an invalid EViews name.
%stock = "_" + @mid(%stock,2)
endif
This could probably be change to use the @makevalidname function, which would handle all illegal characters, rather than just a starting "^". That might help you out with your periods too.
Follow us on Twitter @IHSEViews
-
- Posts: 19
- Joined: Fri Oct 09, 2009 1:14 am
Re: GetStocks (fetch stock data)
EViews Gareth wrote:If you're fiddling around with the code, somewhere in there I put in a hack to allow stocks with names that EViews doesn't like:Code: Select all
if @left(%stock,1) = "^" then 'handle the case where a stock name starts with "^", which is an invalid EViews name.
%stock = "_" + @mid(%stock,2)
endif
This could probably be change to use the @makevalidname function, which would handle all illegal characters, rather than just a starting "^". That might help you out with your periods too.
I saw that, v. clever but I think the radio button solution is probably the way to go (if only because i can default it to .ax, saves me having to add .ax all the time!). Most users probably arent familiar with the icharts .ax suffix as it is so keeping it simple is probably better - but of course adapting your hack would allow (i presume) the use of ALL the stocks on the icharts db, pretty cool.... hmmm...
-
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: GetStocks (fetch stock data)
Added new features.
Re: GetStocks (fetch stock data)
While this change might seem great to some, it appears that you have destroyed some of the flexibility of the previous version. Previously, I had no trouble downloading mixed currency stocks (e.g. ^nz50,^aord,^gspc,^nyse, ....etc). Now I can't. So a number of programmes that used the old version have been rendered useless. Do you think you could resore the previous version under a new name perhaps.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
Re: GetStocks (fetch stock data)
Follow us on Twitter @IHSEViews
Re: GetStocks (fetch stock data)
The problem is that us stocks have to have us currency, nz stocks nz currency, aussie stoocks aussie currency, etc. I liked the old programme because I could download sp500, nz50, aord etc into a single workfile and EViews did the date matching for me to make it easier to get a common sample. The new version can't do this. I've included a sample of code to show you what I've been able to do. Also, it seemed to me that the new add-in didn't always create a new workfile when I wanted it to so do.
Code: Select all
'change path
%path = @runpath
cd %path
'retrieve data
getstocks(c, start = "2010/01/01", end="2011/12/31") ^nz50 ^aord ^axjo ^gspc ^nya ^dji ^ixic
rename _aord_close aao
rename _axjo_close asx200
rename _dji_close dji
rename _gspc_close sp500
rename _ixic_close nasdaq
rename _nya_close nyse
rename _nz50_close nz50
group stocks aao asx200 dji nasdaq nyse nz50 sp500
save anzuscfsd.xls
Re: GetStocks (fetch stock data)
Just used you quick-fix and it works as in the past.
Who is online
Users browsing this forum: No registered users and 20 guests