ystock 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5af1d3066dbe3fb3ae3288aa4c3b8de657d88ef6
4
+ data.tar.gz: 6d68ba22fb445714c5c71dc866753cf99c0169db
5
+ SHA512:
6
+ metadata.gz: e12f7bdbdc05002dbcfb8a637e7e58d41ff7c5edd813982bb06448d4d984278bd87901999b3e8b170dd355b131f3218aa9c24fa9d9e437392a8f023c04bbe536
7
+ data.tar.gz: be46418c6705a83f57d96fd9f74523fc1dc1fb5ddf27c92610eca1d544efe379baa3d87b2583b52eba28353628e419fe426fdfb9fa98e6f892ec875828448a68
@@ -6,10 +6,10 @@ This gem provides you with the latest market data avalable, pulling from both Go
6
6
  ## Install
7
7
  Add the following to your Gemfile
8
8
  ```ruby
9
- gem "ystock", "~> 0.4.5"
9
+ gem "ystock", "~> 0.4.6"
10
10
 
11
11
  # Or simply install it
12
- gem install ystock -v=0.4.5
12
+ gem install ystock -v=0.4.6
13
13
  ```
14
14
 
15
15
  ## Bundle
@@ -24,59 +24,10 @@ require 'ystock'
24
24
 
25
25
  ----
26
26
 
27
- # Google Usage
27
+ # Google No longer supported :(
28
28
 
29
- This uses the Google Finance API to request the latest market information (up to 15 min delay). The Google Finance API tends to return better and more useful information on the stock requested vs Yahoo.
29
+ Sorry, Google shut this service down. The code will remain in the gem until a later version as a memorial to the Google Finance API.
30
30
 
31
- ## Quote Usage
32
- ```ruby
33
- # Single Stock lookup {String}
34
- Ystock::Google.quote("appl")
35
-
36
- # Multiple Stock lookup {Array}
37
- Ystock::Google.quote(["aapl", "f", "goog"])
38
- ```
39
-
40
- #### Available data
41
- ```
42
- symbol
43
- pretty_symbol
44
- symbol_lookup_url
45
- company
46
- exchange
47
- exchange_timezone
48
- exchange_utc_offset
49
- exchange_closing
50
- divisor
51
- currency
52
- last
53
- high
54
- low
55
- volume
56
- avg_volume
57
- market_cap
58
- open
59
- y_close
60
- change
61
- perc_change
62
- delay
63
- trade_timestamp
64
- trade_date_utc
65
- trade_time_utc
66
- current_date_utc
67
- current_time_utc
68
- symbol_url
69
- chart_url
70
- disclaimer_url
71
- ecn_url
72
- isld_last
73
- isld_trade_date_utc
74
- isld_trade_time_utc
75
- brut_last
76
- brut_trade_date_utc
77
- brut_trade_time_utc
78
- daylight_savings
79
- ```
80
31
 
81
32
  ----
82
33
 
@@ -101,6 +52,12 @@ change_percent
101
52
  open
102
53
  day_high
103
54
  day_low
55
+ previous_close
56
+ after_hours_change
57
+ ma50 => 50 day moving average
58
+ ma200 => 200 day moving average
59
+ week52_range => 52 week range
60
+ pe_ratio => P/E Ratio (Realtime)
104
61
  ```
105
62
 
106
63
  ----
@@ -108,10 +65,8 @@ day_low
108
65
  ### Tested with
109
66
  This gem was tested with:
110
67
 
111
- Ruby: 1.9.2 -> No longer supported.
68
+ Ruby: ~~1.9.2~~ -> No longer supported.
112
69
 
113
70
  Ruby: 1.9.3
114
71
 
115
72
  Ruby: 2.0.0
116
-
117
-
@@ -1,7 +1,7 @@
1
1
  module Ystock
2
2
  class Yahoo
3
3
  @@service_uri = "http://download.finance.yahoo.com/d/quotes.csv"
4
-
4
+
5
5
  def self.quote(stocks)
6
6
  if stocks.is_a? Array
7
7
  # => Many stocks
@@ -11,7 +11,7 @@ module Ystock
11
11
  get_quote(stocks)
12
12
  end
13
13
  end
14
-
14
+
15
15
  private
16
16
  def self.find(args)
17
17
  stock_string = ""
@@ -25,22 +25,28 @@ module Ystock
25
25
  end
26
26
  format(send_request(stock_string))
27
27
  end
28
-
28
+
29
29
  def self.get_quote(stock)
30
30
  stock_data = Hash.new
31
31
  s = send_request(stock)
32
- a = s.chomp.split(",")
32
+ a = s.chomp.split(",")
33
33
  return {:symbol => stock,
34
34
  :price => a[0],
35
35
  :change => a[1],
36
36
  :volume => a[2],
37
- :change_percent => a[4],
37
+ :change_percent => a[4].gsub("\r\n", "").gsub('"', ''),
38
38
  :open => a[5],
39
39
  :day_high => a[6],
40
- :day_low => a[7]
40
+ :day_low => a[7],
41
+ :previous_close => a[8],
42
+ :after_hours_change => a[9].gsub("\r\n", "").gsub('"', ''),
43
+ :ma50 => a[10],
44
+ :ma200 => a[11],
45
+ :week52_range => a[12].gsub("\r\n", "").gsub('"', ''),
46
+ :pe_ratio => a[13]
41
47
  }
42
48
  end
43
-
49
+
44
50
  def self.format(results)
45
51
  output = Array.new
46
52
  results.each_line("\n") do |row|
@@ -53,10 +59,16 @@ module Ystock
53
59
  :price => stockdata[0],
54
60
  :change => stockdata[1],
55
61
  :volume => stockdata[2],
56
- :change_percent => stockdata[4],
62
+ :change_percent => stockdata[4].gsub("\r\n", "").gsub('"', ''),
57
63
  :open => stockdata[5],
58
64
  :day_high => stockdata[6],
59
- :day_low => stockdata[7]}
65
+ :day_low => stockdata[7],
66
+ :previous_close => stockdata[8],
67
+ :after_hours_change => stockdata[9].gsub("\r\n", "").gsub('"', ''),
68
+ :ma50 => stockdata[10],
69
+ :ma200 => stockdata[11],
70
+ :week52_range => stockdata[12].gsub("\r\n", "").gsub('"', ''),
71
+ :pe_ratio => stockdata[13]}
60
72
 
61
73
  end
62
74
  end
@@ -65,7 +77,7 @@ module Ystock
65
77
  end
66
78
 
67
79
  def self.send_request(args)
68
- completed_path = @@service_uri + "?f=l1c1vsk2ohg&s=" + args
80
+ completed_path = @@service_uri + "?f=l1c1vsp2ohgpc8m3m4wr2&s=" + args
69
81
  uri = URI.parse(completed_path)
70
82
  response = Net::HTTP.start(uri.host, uri.port) do |http|
71
83
  http.get completed_path
@@ -76,6 +88,6 @@ module Ystock
76
88
  def self.version
77
89
  return Gem::VERSION
78
90
  end
79
-
91
+
80
92
  end
81
- end
93
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ystock'
3
- s.version = "0.4.5"
3
+ s.version = "0.4.6"
4
4
  s.authors = ["Greg Winn"]
5
5
  s.date = %q{2012-06-09}
6
6
  s.description = %q{Grab stock information from Yahoo and Google Finance}
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ystock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
5
- prerelease:
4
+ version: 0.4.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Greg Winn
@@ -14,17 +13,15 @@ dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: httparty
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.10.1
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.10.1
30
27
  description: Grab stock information from Yahoo and Google Finance
@@ -37,32 +34,31 @@ extra_rdoc_files:
37
34
  files:
38
35
  - README.markdown
39
36
  - lib/ystock.rb
40
- - lib/ystock/yahoo.rb
41
37
  - lib/ystock/google.rb
38
+ - lib/ystock/yahoo.rb
42
39
  - ystock.gemspec
43
40
  homepage: http://github.com/gregwinn/ystock
44
41
  licenses:
45
42
  - MIT
43
+ metadata: {}
46
44
  post_install_message:
47
45
  rdoc_options: []
48
46
  require_paths:
49
47
  - lib
50
48
  required_ruby_version: !ruby/object:Gem::Requirement
51
- none: false
52
49
  requirements:
53
- - - ! '>='
50
+ - - ">="
54
51
  - !ruby/object:Gem::Version
55
52
  version: '0'
56
53
  required_rubygems_version: !ruby/object:Gem::Requirement
57
- none: false
58
54
  requirements:
59
- - - ! '>='
55
+ - - ">="
60
56
  - !ruby/object:Gem::Version
61
57
  version: '0'
62
58
  requirements: []
63
59
  rubyforge_project:
64
- rubygems_version: 1.8.25
60
+ rubygems_version: 2.2.2
65
61
  signing_key:
66
- specification_version: 3
62
+ specification_version: 4
67
63
  summary: Grab stock information from Yahoo and Google Finance
68
64
  test_files: []