GetStocks (fetch stock data)

For questions about EViews Add-ins available from the EViews Add-ins webpage. Note each add-in available on our webpage will have its own individual thread.

Moderators: EViews Gareth, EViews Moderator, EViews Esther

rod_jensen
Posts: 4
Joined: Sat Jan 15, 2011 1:40 pm

Re: GetStocks (fetch stock data)

Postby rod_jensen » Sat Jan 15, 2011 5:25 pm

Fantastic. Thanks a million.

acslks
Posts: 1
Joined: Sun Feb 06, 2011 12:10 pm

Re: GetStocks (fetch stock data)

Postby acslks » Sun Feb 06, 2011 12:33 pm

I cannot download commodity futures or indices. Is everything on Yahoo Finance able to be downloaded?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

GetStocks (fetch stock data)

Postby EViews Gareth » Sun Feb 06, 2011 2:28 pm

Which indices?
Follow us on Twitter @IHSEViews

Tom Simpson
Posts: 19
Joined: Fri Oct 09, 2009 1:14 am

Re: GetStocks (fetch stock data)

Postby Tom Simpson » Mon Feb 14, 2011 9:52 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: GetStocks (fetch stock data)

Postby EViews Gareth » Mon Feb 14, 2011 10:00 am

nifty.
Follow us on Twitter @IHSEViews

tchaithonov
Posts: 168
Joined: Mon Apr 13, 2009 7:39 am
Location: New York City

Re: GetStocks (fetch stock data)

Postby tchaithonov » Mon Feb 14, 2011 11:17 am

Would it be even better if you combine the two programs by adding an "Australia or United States" radio button on the ui?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: GetStocks (fetch stock data)

Postby EViews Gareth » Mon Feb 14, 2011 11:25 am

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).
Follow us on Twitter @IHSEViews

Tom Simpson
Posts: 19
Joined: Fri Oct 09, 2009 1:14 am

Re: GetStocks (fetch stock data)

Postby Tom Simpson » Mon Feb 14, 2011 11:30 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: GetStocks (fetch stock data)

Postby EViews Gareth » Mon Feb 14, 2011 11:37 am

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.
Follow us on Twitter @IHSEViews

Tom Simpson
Posts: 19
Joined: Fri Oct 09, 2009 1:14 am

Re: GetStocks (fetch stock data)

Postby Tom Simpson » Mon Feb 14, 2011 11:46 am

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 Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: GetStocks (fetch stock data)

Postby EViews Esther » Fri Mar 04, 2011 5:27 pm

Added new features.

terrya
Posts: 107
Joined: Wed Aug 26, 2009 2:37 pm

Re: GetStocks (fetch stock data)

Postby terrya » Fri Mar 04, 2011 7:35 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: GetStocks (fetch stock data)

Postby EViews Gareth » Fri Mar 04, 2011 8:08 pm

It shouldn't have broken anything. We'll fix it.

Until then, I've uploaded the old one here
Follow us on Twitter @IHSEViews

terrya
Posts: 107
Joined: Wed Aug 26, 2009 2:37 pm

Re: GetStocks (fetch stock data)

Postby terrya » Fri Mar 04, 2011 8:23 pm

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

terrya
Posts: 107
Joined: Wed Aug 26, 2009 2:37 pm

Re: GetStocks (fetch stock data)

Postby terrya » Fri Mar 04, 2011 8:29 pm

Just used you quick-fix and it works as in the past.


Return to “Add-in Support”

Who is online

Users browsing this forum: No registered users and 20 guests