Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > yahoo finance api:Timeout::Error: execution expired

Reply
Thread Tools

yahoo finance api:Timeout::Error: execution expired

 
 
Pen Ttt
Guest
Posts: n/a
 
      07-13-2010
i want to download usa stock quote data via ruby-yahoo finance api,
here is my program:
require 'rubygems'
require 'yahoofinance'
file1=open('/home/pt/usacode','r')
file2=open('/home/pt/usadata','a+')
i=0
while line=file1.gets
line=line.chomp
i=i+1
print line," ",i,"\n"
YahooFinance::get_historical_quotes( line,
Date.parse( '2005-09-09' ),
Date.today() ) do |row|
file2.puts "#{line},#{row.join(',')}"
end
end

there are 6000 companies in the file1 ,each company one line ,i use "i"
to count company,the program can run,but each time i can only download
about ten companies data,the output is

Timeout::Error: execution expired
from /usr/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill'
from /usr/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
from /usr/lib/ruby/1.8/net/protocol.rb:86:in `read'
from /usr/lib/ruby/1.8/net/http.rb:2236:in `read_chunked'
from /usr/lib/ruby/1.8/net/http.rb:2211:in `read_body_0'
from /usr/lib/ruby/1.8/net/http.rb:2177:in `read_body'
from /usr/lib/ruby/1.8/net/http.rb:773:in `get'
from /usr/lib/ruby/1.8/net/http.rb:1053:in `request'
from /usr/lib/ruby/1.8/net/http.rb:2140:in `reading_body'
from /usr/lib/ruby/1.8/net/http.rb:1052:in `request'
from /usr/lib/ruby/1.8/net/http.rb:772:in `get'
from
/var/lib/gems/1.8/gems/yahoofinance-1.2.2/lib/yahoofinance.rb:419:in
`retrieve_raw_historical_quotes'
from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
from /usr/lib/ruby/1.8/net/http.rb:440:in `start'
from
/var/lib/gems/1.8/gems/yahoofinance-1.2.2/lib/yahoofinance.rb:409:in
`retrieve_raw_historical_quotes'
from
/var/lib/gems/1.8/gems/yahoofinance-1.2.2/lib/yahoofinance.rb:451:in
`get_historical_quotes'
from (irb):10
from :0irb(main):016:0>
what's wrong??
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      07-13-2010
Pen Ttt wrote:
> i want to download usa stock quote data via ruby-yahoo finance api,
> here is my program:


I don't know anything about the Yahoo Finance API, but I know that if I
were running such a public service, I would probably include some
protection against one person trying to hit it 6000 times repeatedly.
Are you sure you're using the right API call to do what you want?

OTOH, a quick search suggests that Yahoo rate limiting is typically done
over a larger period:
http://developer.yahoo.com/search/rate.html

Anyway, I'd suggest you try the following:

(1) Re-order the list of companies you search. Does it always barf on
the same one, or always the 10th in the list?

(2) Insert a "sleep 1" into the loop, see if the problem goes away

(3) Check that the YahooFinance client module is properly closing each
socket, by using "netstat -n" in another window, and checking how many
sockets are in ESTABLISHED state. If there are lots of ESTABLISHED
sockets then the client code isn't closing sockets, and the server may
have a limit on the number of concurrent requests from the same IP.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mainstream Digital Chooses the BroadSoft Platform to Provide Next Generation Fixed-Mobile Voice Services to SMEs in ... (Market Wire via Yahoo! Finance) admin@ng2000.com UK VOIP 0 02-19-2007 03:02 PM
Affiliated Computer Inks $14M Deal (AP via Yahoo! Finance) info@neobasic.biz Computer Information 0 02-13-2007 07:02 AM
Spot Future Trends and Developments in the Recorded DVD & Video Market in the United Kingdom (Business Wire via Yahoo! Finance) admin@ng2000.com DVD Video 0 02-12-2007 08:02 AM
finance yahoo technology quickcur@yahoo.com Java 1 01-23-2005 05:42 PM
script to download Yahoo Finance data dan roberts Python 13 07-06-2004 10:17 PM



Advertisments