equities 1.0.0

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: f25651f1bbb25015802efeb13715b8a91781d900
4
+ data.tar.gz: a4c013c4af7511e24808c314acd903102b9ccc2d
5
+ SHA512:
6
+ metadata.gz: 6b661e24cb3bb48e14ce49f9f0ac26d02a6c5dff3ccc56919f3a941aa24befe06aa0486a1bd2fd26f05d1165b5ed549198b1d8779efc841e35b39606297f0abd
7
+ data.tar.gz: e0c2f8bb7e84a5fb70f51e38f311bad1a8278c3a545186e78778f9c7ac40967adcb18e7e259fc69631b3de9192c81d84e27400a87540452ae2598331ac5eab08
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in equities.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 JimMayes
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,140 @@
1
+ # Equities
2
+
3
+ Equities is a simple Ruby library that retrieves a stock quote from Yahoo Finance (YQL).
4
+
5
+ Retrieve quotes for a single stock or multiple stocks (passed as an array) in one request. Results are returned converted to OpenStructs for easy access to specific values.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'equities'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install equities
20
+
21
+ ## Usage
22
+
23
+ ### Retrieve quote for a single stock
24
+
25
+ quote = Equities.quote 'aapl'
26
+ p quote.Name
27
+ # => "Apple Inc."
28
+
29
+ ### Retrieve quotes for multiple stocks
30
+
31
+ Provide an array of stock symbols to retrieve quotes for multiple stocks in a single request
32
+
33
+ quotes = Equities.quote ['aapl', 'goog']
34
+
35
+ Directly access an individual stock within the result set by it's symbol
36
+
37
+ p quotes['AAPL'].Name
38
+ # => "Apple Inc."
39
+
40
+ Or loop through the result set
41
+
42
+ quotes.each do |quote|
43
+ p quote.last.Name
44
+ end
45
+ # => "Apple Inc."
46
+ # => "Google Inc."
47
+
48
+ ### Available Stock data
49
+
50
+ symbol
51
+ Ask
52
+ AverageDailyVolume
53
+ Bid
54
+ AskRealtime
55
+ BidRealtime
56
+ BookValue
57
+ Change_PercentChange
58
+ Change
59
+ Commission
60
+ Currency
61
+ ChangeRealtime
62
+ AfterHoursChangeRealtime
63
+ DividendShare
64
+ LastTradeDate
65
+ TradeDate
66
+ EarningsShare
67
+ ErrorIndicationreturnedforsymbolchangedinvalid
68
+ EPSEstimateCurrentYear
69
+ EPSEstimateNextYear
70
+ EPSEstimateNextQuarter
71
+ DaysLow
72
+ DaysHigh
73
+ YearLow
74
+ YearHigh
75
+ HoldingsGainPercent
76
+ AnnualizedGain
77
+ HoldingsGain
78
+ HoldingsGainPercentRealtime
79
+ HoldingsGainRealtime
80
+ MoreInfo
81
+ OrderBookRealtime
82
+ MarketCapitalization
83
+ MarketCapRealtime
84
+ EBITDA
85
+ ChangeFromYearLow
86
+ PercentChangeFromYearLow
87
+ LastTradeRealtimeWithTime
88
+ ChangePercentRealtime
89
+ ChangeFromYearHigh
90
+ PercebtChangeFromYearHigh
91
+ LastTradeWithTime
92
+ LastTradePriceOnly
93
+ HighLimit
94
+ LowLimit
95
+ DaysRange
96
+ DaysRangeRealtime
97
+ FiftydayMovingAverage
98
+ TwoHundreddayMovingAverage
99
+ ChangeFromTwoHundreddayMovingAverage
100
+ PercentChangeFromTwoHundreddayMovingAverage
101
+ ChangeFromFiftydayMovingAverage
102
+ PercentChangeFromFiftydayMovingAverage
103
+ Name
104
+ Notes
105
+ Open
106
+ PreviousClose
107
+ PricePaid
108
+ ChangeinPercent
109
+ PriceSales
110
+ PriceBook
111
+ ExDividendDate
112
+ PERatio
113
+ DividendPayDate
114
+ PERatioRealtime
115
+ PEGRatio
116
+ PriceEPSEstimateCurrentYear
117
+ PriceEPSEstimateNextYear
118
+ Symbol
119
+ SharesOwned
120
+ ShortRatio
121
+ LastTradeTime
122
+ TickerTrend
123
+ OneyrTargetPrice
124
+ Volume
125
+ HoldingsValue
126
+ HoldingsValueRealtime
127
+ YearRange
128
+ DaysValueChange
129
+ DaysValueChangeRealtime
130
+ StockExchange
131
+ DividendYield
132
+ PercentChange
133
+
134
+ ## Contributing
135
+
136
+ 1. Fork it ( https://github.com/JimMayes/equities/fork )
137
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
138
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
139
+ 4. Push to the branch (`git push origin my-new-feature`)
140
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'equities/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "equities"
8
+ spec.version = Equities::VERSION
9
+ spec.authors = ["JimMayes"]
10
+ spec.email = ["jim.mayes@gmail.com"]
11
+ spec.summary = %q{Retrieves a quote for a stock or multiple stocks}
12
+ spec.description = %q{Equities is a simple Ruby library that retrieves a stock quote from Yahoo Finance (YQL).}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rest_client"
22
+ spec.add_dependency "json"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,33 @@
1
+ require "equities/version"
2
+ require "restclient"
3
+ require "json"
4
+
5
+ module Equities
6
+ def self.quote(ticker)
7
+ if ticker.kind_of?(Array)
8
+ ticker = ticker.join(",")
9
+ end
10
+
11
+ resource = RestClient::Resource.new 'http://query.yahooapis.com/v1/public/yql'
12
+
13
+ options = {
14
+ :params => {
15
+ q: "select * from yahoo.finance.quotes where symbol in ('#{ticker}')",
16
+ format: 'json',
17
+ env: 'store://datatables.org/alltableswithkeys'
18
+ }
19
+ }
20
+
21
+ response = JSON.parse(resource.get options)
22
+
23
+ if response["query"]["count"] > 1
24
+ quotes = {}
25
+ response["query"]["results"]["quote"].each do |quote|
26
+ quotes[quote["symbol"]] = OpenStruct.new(quote)
27
+ end
28
+ return quotes
29
+ else
30
+ OpenStruct.new response["query"]["results"]["quote"]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Equities
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: equities
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - JimMayes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest_client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Equities is a simple Ruby library that retrieves a stock quote from Yahoo
70
+ Finance (YQL).
71
+ email:
72
+ - jim.mayes@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - equities.gemspec
83
+ - lib/equities.rb
84
+ - lib/equities/version.rb
85
+ homepage: ''
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Retrieves a quote for a stock or multiple stocks
109
+ test_files: []