isis-plugin-stockticker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/stockticker.csv.example +1 -0
- data/isis-plugin-stockticker.gemspec +26 -0
- data/lib/isis/plugin/stockticker.rb +102 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 513051f3ba8ede58c996d92d153cfbf21d6a8e4f
|
4
|
+
data.tar.gz: 4ef435a0ed5de26c35f657af3d356da476c925d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b657c6274389cf9fadcb8cf695f561251a93ade40f92e61bfda1bc0699c62c414c4ac9c2bca91ced3c3d334d8babd83e597002e59029dc14b4667714411bf276
|
7
|
+
data.tar.gz: 114f52766d635ddce091e6a6a0d132da42819766ffef65926a97f6a55e854983c1f1991e0372c1077a78a39afdbfa2f9707c953779b603c45daf5f82abd92300
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Isis plugin: Stock Ticker
|
2
|
+
|
3
|
+
This plugin adds a [Yahoo Finance stock ticker](http://finance.yahoo.com/) command to the [Isis chatbot](https://github.com/silentgrowl/isis)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Copy config/stockticker.csv.example from the gem repo and save as ```config/stockticker.csv``` in your Isis installation.
|
8
|
+
|
9
|
+
Edit the config/stockticker.csv file to define a comma-separated value list of stock symbols to include in the ticker report.
|
10
|
+
|
11
|
+
Add this line to your Isis installation's Gemfile:
|
12
|
+
|
13
|
+
``ruby
|
14
|
+
gem 'isis-plugin-stockticker'
|
15
|
+
``
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To post the latest stock ticker report into a room, type ```!stockticker```, ```!stocks```, ```!stockquotes```, ```!ticker```, or ```!yahoofinance``` into chat.
|
24
|
+
|
25
|
+
## Links
|
26
|
+
|
27
|
+
* [isis-plugin-stockticker on RubyGems](https://rubygems.org/gems/isis-plugin-stockticker)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "isis/plugin/stockticker"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
AAPL,AMZN,CSCO,GOOG,MSFT,ORCL,VMW
|
@@ -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
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "isis-plugin-stockticker"
|
7
|
+
spec.version = "1.0.0"
|
8
|
+
spec.authors = ["Brendon Rapp"]
|
9
|
+
spec.email = ["brendon@silentgrowl.com"]
|
10
|
+
spec.license = 'MIT'
|
11
|
+
|
12
|
+
spec.summary = %q{Isis plugin: Stock Ticker}
|
13
|
+
spec.description = %q{Isis plugin: Stock Ticker}
|
14
|
+
spec.homepage = "https://github.com/silentgrowl/isis-plugin-stockticker"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "yahoofinance"
|
22
|
+
spec.add_runtime_dependency "httparty"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "yahoofinance"
|
2
|
+
require "httparty"
|
3
|
+
require "csv"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Isis
|
7
|
+
module Plugin
|
8
|
+
class StockTicker < Isis::Plugin::Base
|
9
|
+
TRIGGERS = %w(!stockquotes !stocks !stockticker !yahoofinance !ticker)
|
10
|
+
|
11
|
+
def respond_to_msg?(msg, speaker)
|
12
|
+
TRIGGERS.include? msg.downcase
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@symbols = CSV.read(File.expand_path(File.join('config', 'stockticker.csv'))).flatten
|
19
|
+
end
|
20
|
+
|
21
|
+
def response_html
|
22
|
+
output = %Q[<img src="http://i.imgur.com/8QkyRrp.png"> ISIS Stock Ticker] +
|
23
|
+
%Q[ - #{timestamp} #{zone} (powered by Yahoo! Finance)<br>]
|
24
|
+
quotes = YahooFinance.get_standard_quotes(@symbols)
|
25
|
+
quotes.each do |q|
|
26
|
+
symbol = q[0]
|
27
|
+
last_trade = q[1].lastTrade
|
28
|
+
points = q[1].changePoints
|
29
|
+
percent = q[1].changePercent
|
30
|
+
name = company_name(symbol) || q[1].name
|
31
|
+
output += html_output_line(name: name, symbol: symbol, last_trade: last_trade,
|
32
|
+
points: points, percent: percent)
|
33
|
+
end
|
34
|
+
output
|
35
|
+
end
|
36
|
+
|
37
|
+
def response_md
|
38
|
+
output = %Q[ISIS Stock Ticker - #{timestamp} #{zone} (powered by Yahoo! Finance)\n]
|
39
|
+
quotes = YahooFinance.get_standard_quotes(@symbols)
|
40
|
+
quotes.each do |q|
|
41
|
+
symbol = q[0]
|
42
|
+
last_trade = q[1].lastTrade
|
43
|
+
points = q[1].changePoints
|
44
|
+
percent = q[1].changePercent
|
45
|
+
name = company_name(symbol) || q[1].name
|
46
|
+
output += md_output_line(name: name, symbol: symbol, last_trade: last_trade,
|
47
|
+
points: points, percent: percent)
|
48
|
+
end
|
49
|
+
output
|
50
|
+
end
|
51
|
+
|
52
|
+
def response_text
|
53
|
+
output = ["ISIS Stock Ticker - #{timestamp} #{zone} (powered by Yahoo! Finance)"]
|
54
|
+
quotes = YahooFinance.get_standard_quotes(@symbols)
|
55
|
+
quotes.each do |q|
|
56
|
+
symbol = q[0]
|
57
|
+
last_trade = q[1].lastTrade
|
58
|
+
points = q[1].changePoints
|
59
|
+
percent = q[1].changePercent
|
60
|
+
name = company_name(symbol) || q[1].name
|
61
|
+
output.push text_output_line(name: name, symbol: symbol, last_trade: last_trade,
|
62
|
+
points: points, percent: percent)
|
63
|
+
end
|
64
|
+
output
|
65
|
+
end
|
66
|
+
|
67
|
+
def html_output_line(opts)
|
68
|
+
%Q[<b>#{opts[:name]}</b> (#{opts[:symbol]}): #{opts[:last_trade]} (#{pointize(opts[:points])},] +
|
69
|
+
%Q[ #{percentize(opts[:percent])})<br>]
|
70
|
+
end
|
71
|
+
|
72
|
+
def md_output_line(opts)
|
73
|
+
%Q[*#{opts[:name]}* (#{opts[:symbol]}): #{opts[:last_trade]} (#{pointize(opts[:points])},] +
|
74
|
+
%Q[ #{percentize(opts[:percent])})\n]
|
75
|
+
end
|
76
|
+
|
77
|
+
def text_output_line(opts)
|
78
|
+
%Q[#{opts[:name]} (#{opts[:symbol]}): #{opts[:last_trade]} (#{pointize(opts[:points])},] +
|
79
|
+
%[ #{percentize(opts[:percent])})]
|
80
|
+
end
|
81
|
+
|
82
|
+
def percentize(pct)
|
83
|
+
pct.to_s[0] == '-' ? "#{pct}%" : "+#{pct}%"
|
84
|
+
end
|
85
|
+
|
86
|
+
def pointize(pts)
|
87
|
+
pts.to_s[0] == '-' ? "#{pts}" : "+#{pts}"
|
88
|
+
end
|
89
|
+
|
90
|
+
# The silly gem returns truncated company names
|
91
|
+
# So we make a call to Yahoo on our own to fetch the full name
|
92
|
+
# TODO: Fix the gem or just parse this result for all the data
|
93
|
+
def company_name(symbol)
|
94
|
+
url = 'http://d.yimg.com/autoc.finance.yahoo.com/autoc'
|
95
|
+
callback = 'YAHOO.Finance.SymbolSuggest.ssCallback'
|
96
|
+
response = HTTParty.get("#{url}?query=#{symbol}&callback=#{callback}")
|
97
|
+
info = JSON.parse(response.split('YAHOO.Finance.SymbolSuggest.ssCallback(')[1].gsub(')', ''))
|
98
|
+
info['ResultSet']['Result'][0]['name']
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isis-plugin-stockticker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brendon Rapp
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yahoofinance
|
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: httparty
|
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.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: 'Isis plugin: Stock Ticker'
|
70
|
+
email:
|
71
|
+
- brendon@silentgrowl.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- config/stockticker.csv.example
|
84
|
+
- isis-plugin-stockticker.gemspec
|
85
|
+
- lib/isis/plugin/stockticker.rb
|
86
|
+
homepage: https://github.com/silentgrowl/isis-plugin-stockticker
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: 'Isis plugin: Stock Ticker'
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|