Coder Social home page Coder Social logo

yahoo_stock's People

Contributors

justincampbell avatar justinlove avatar nas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yahoo_stock's Issues

Syntax error in Ruby 1.9.2p180

in history.rb I had to change

def uri
  frequency = case interval
                when :daily  : 'd'
                when :weekly  : 'w'
                when :monthly : 'm'
              end

to

def uri
  frequency = case interval
                when :daily  then 'd'
                when :weekly  then 'w'
                when :monthly then 'm'
              end

Syntax error in history.rb when using Ruby 1.9

I just installed yahoo_stock 1.02. It looks like the uri method of history.rb (line 86) is using an older syntax for compact case statements.... when :daily : 'd'. This format is no longer supported in Ruby 1.9. The modified code below fixes the issue.

def uri
frequency = case interval
when :daily
'd'
when :weekly
'w'
when :monthly
'm'
end
@uri_parameters = {:a => sprintf("%02d", start_date.month-1), :b => start_date.day,
:c => start_date.year, :d => sprintf("%02d", end_date.month-1),
:e => end_date.day, :f => end_date.year, :s => stock_symbol,
:g => frequency, :ignore => '.csv'}
super()
end

Document history results format better

It would be helpful to add to the readme the format for history results, as it confused me for a while.

ruby-1.9.2-p180 :006 > history.results
=> #<YahooStock::Result:0x00000103d5e400 @context="2011-02-25,16.39,16.77,16.38,16.50,16402400,16.50\n2011-02-24,16.66,16.73,16.04,16.37,31528900,16.37\n">
ruby-1.9.2-p180 :007 > history.values_with_header
=> "Date,Open,High,Low,Close,Volume,Adj Close\n2011-02-25,16.39,16.77,16.38,16.50,16402400,16.50\n2011-02-24,16.66,16.73,16.04,16.37,31528900,16.37\n"

E.g. it is not obvious that every day's results will be formatted as 4 values. I was confused because I thought I would get 1 value for each day. Also, the history.values_with_header method is not featured in the readme. Just some suggestions -- great gem, thanks.

Strange issue with a single stock symbol : LO

I have our gem working for loads of stocks. I get a strange anomaly for a stock named LO.
Instead of LO going in the symbol field, it goes in the ticker_trend.

symbol=YahooStock::Quote.new(:stock_symbols=>['LO'])
symbol.standard
symbol.results(:to_hash).output

Can't get quote if stock_symbol have "^"

Like ^GSPC, some stock symbol have a charactor ^, that causes YahooStock::Interface::InterfaceError: bad URI(is not URI?): error.

I fixed the by replacing in lib/yahoo_stock/interface.rb

response = Net::HTTP.get_response(URI.parse(uri))

to

response = Net::HTTP.get_response(URI.parse(URI.encode(uri)))

I wanted to send Pull Request, but rspec test fails with this code.

rspec ./spec/yahoo_stock/interface/quote_spec.rb:199 # YahooStock::Interface::Quote get should use uri to get the content
rspec ./spec/yahoo_stock/interface/quote_spec.rb:204 # YahooStock::Interface::Quote get should get response for the uri
rspec ./spec/yahoo_stock/interface/quote_spec.rb:209 # YahooStock::Interface::Quote get should parse the uri
rspec ./spec/yahoo_stock/interface/quote_spec.rb:214 # YahooStock::Interface::Quote get should check the response code
rspec ./spec/yahoo_stock/interface/quote_spec.rb:219 # YahooStock::Interface::Quote get should get the body of the response if returned code is 200, ie success
rspec ./spec/yahoo_stock/interface/scrip_symbol_spec.rb:23 # YahooStock::Interface::ScripSymbol get should find or generate the uri once in the get method and once in the et method of the super class

How can I fix uri problem without breaking Rspec test?

Update on other pages.. of Yahoo Finance

Hello there..

Nice to see your work on Yahoo finance gem.. Ok like the repo ur working.. we had also worked on taking yahoo fundamental data by page scraping.. we could do it in slightly different way correctly.. even though we get into error occasional..

Its time that this benefits the open source community...Looking forward for ur update...

https://github.com/ajmal017/yahoo_fundamental

Syntax error on when clausules ⚠️

Steps to reproduce 🦮

  1. Add gem 'yahoo_stock' to Gemfile
  2. bundle install
  3. rails c

The result 🪲

/Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require': /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/yahoo_stock-1.0.2/lib/yahoo_stock/interface/history.rb:86: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
...                when :daily   : 'd'
...                              ^
/Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/yahoo_stock-1.0.2/lib/yahoo_stock/interface/history.rb:87: syntax error, unexpected keyword_when, expecting keyword_end
                    when :weekly  : 'w'
                    ^~~~
/Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/yahoo_stock-1.0.2/lib/yahoo_stock/interface/history.rb:88: syntax error, unexpected keyword_when, expecting keyword_end
                    when :monthly : 'm'
                    ^~~~
/Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/yahoo_stock-1.0.2/lib/yahoo_stock/interface/history.rb:186: syntax error, unexpected keyword_end, expecting end-of-input (SyntaxError)
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/yahoo_stock-1.0.2/lib/yahoo_stock.rb:11:in `<top (required)>'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
	from /Users/victorcosta/Desktop/repositories/factor-investing/config/application.rb:16:in `<top (required)>'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
	from /Users/victorcosta/.rvm/gems/ruby-2.5.5/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
	from /Users/victorcosta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/victorcosta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from -e:1:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.