lita-onewheel-finance 0.5.0 → 0.6.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0650867d30743080da877fdbad93bd7ddbd9f525a7921fa566c7da0a64d9850c'
|
4
|
+
data.tar.gz: 0ad45310e357e2e5ed9b2e10bb1721cd0ba91da863507ff5a4dc728b10f14bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 495d556d163bf461fa1d521ed7176054636a591c1fb2772fcad41634740bc54d5bc4c8d8a464dc936a58d9eb2d6066336fed012bed60e292949bdc5344b3e677
|
7
|
+
data.tar.gz: 9b7bc63735e850c56bfe52dd83d39cce2979be507b400237dea7b5f30b50ba35fad55dd5f24fe220b9f927da241295ac65dd73a41426f23bc93a2cc99b933be6
|
@@ -21,7 +21,23 @@ class IrcColors
|
|
21
21
|
@reset = prefix
|
22
22
|
|
23
23
|
class << self
|
24
|
-
attr_reader :white,
|
24
|
+
attr_reader :white,
|
25
|
+
:black,
|
26
|
+
:blue,
|
27
|
+
:green,
|
28
|
+
:red,
|
29
|
+
:brown,
|
30
|
+
:purple,
|
31
|
+
:orange,
|
32
|
+
:yellow,
|
33
|
+
:lime,
|
34
|
+
:teal,
|
35
|
+
:aqua,
|
36
|
+
:royal,
|
37
|
+
:pink,
|
38
|
+
:grey,
|
39
|
+
:silver,
|
40
|
+
:reset
|
25
41
|
end
|
26
42
|
|
27
43
|
def initialize
|
@@ -68,7 +84,7 @@ class AlphaVantageQuote
|
|
68
84
|
end
|
69
85
|
|
70
86
|
class WorldTradeDataQuote
|
71
|
-
attr_reader :open, :high, :low, :price, :volume, :trading_day, :prev_close, :change, :change_percent, :exchange, :error, :name, :message
|
87
|
+
attr_reader :open, :high, :low, :price, :volume, :trading_day, :prev_close, :change, :change_percent, :exchange, :error, :name, :message, :is_index
|
72
88
|
attr_accessor :symbol
|
73
89
|
|
74
90
|
def initialize(symbol, api_key)
|
@@ -80,6 +96,12 @@ class WorldTradeDataQuote
|
|
80
96
|
(@exchange, @symbol) = @symbol.split /:/
|
81
97
|
end
|
82
98
|
|
99
|
+
if @symbol['^']
|
100
|
+
@is_index = true
|
101
|
+
else
|
102
|
+
@is_index = false
|
103
|
+
end
|
104
|
+
|
83
105
|
self.call_api
|
84
106
|
|
85
107
|
hash = JSON.parse(@response)
|
@@ -137,6 +159,10 @@ class WorldTradeDataQuote
|
|
137
159
|
@name = quote[key]
|
138
160
|
end
|
139
161
|
end
|
162
|
+
|
163
|
+
def is_index?
|
164
|
+
is_index
|
165
|
+
end
|
140
166
|
end
|
141
167
|
|
142
168
|
# Let's see what we can get from the api.
|
@@ -202,13 +228,18 @@ module Lita
|
|
202
228
|
str = "`#{stock.symbol}` not found on any stock exchange."
|
203
229
|
end
|
204
230
|
else
|
205
|
-
|
231
|
+
dollar_sign = '$'
|
232
|
+
if stock.is_index?
|
233
|
+
dollar_sign = ''
|
234
|
+
end
|
235
|
+
|
236
|
+
str = "#{IrcColors::grey}#{stock.exchange} - #{IrcColors::reset}#{stock.symbol}: #{IrcColors::blue}#{dollar_sign}#{stock.price}#{IrcColors::reset} "
|
206
237
|
if stock.change >= 0
|
207
238
|
# if irc
|
208
|
-
str += "#{IrcColors::green}
|
239
|
+
str += "#{IrcColors::green} ⬆#{dollar_sign}#{stock.change}#{IrcColors::reset}, #{IrcColors::green}#{stock.change_percent}%#{IrcColors::reset} "
|
209
240
|
str += "#{IrcColors::grey}(#{stock.name})#{IrcColors::reset}"
|
210
241
|
else
|
211
|
-
str += "#{IrcColors::red}
|
242
|
+
str += "#{IrcColors::red} ↯#{dollar_sign}#{stock.change}#{IrcColors::reset}, #{IrcColors::red}#{stock.change_percent}%#{IrcColors::reset} "
|
212
243
|
str += "#{IrcColors::grey}(#{stock.name})#{IrcColors::reset}"
|
213
244
|
end
|
214
245
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
"symbols_requested": 1,
|
3
|
+
"symbols_returned": 1,
|
4
|
+
"data": [
|
5
|
+
{
|
6
|
+
"symbol": "^DJI",
|
7
|
+
"name": "Dow Jones Industrial Average",
|
8
|
+
"currency": "N/A",
|
9
|
+
"price": "25766.64",
|
10
|
+
"price_open": "26526.00",
|
11
|
+
"day_high": "26775.31",
|
12
|
+
"day_low": "25752.82",
|
13
|
+
"52_week_high": "29568.57",
|
14
|
+
"52_week_low": "24680.57",
|
15
|
+
"day_change": "-1190.95",
|
16
|
+
"change_pct": "-4.42",
|
17
|
+
"close_yesterday": "26957.59",
|
18
|
+
"market_cap": "N/A",
|
19
|
+
"volume": "664922874",
|
20
|
+
"volume_avg": "N/A",
|
21
|
+
"shares": "N/A",
|
22
|
+
"stock_exchange_long": "",
|
23
|
+
"stock_exchange_short": "INDEXDJX",
|
24
|
+
"timezone": "EST",
|
25
|
+
"timezone_name": "America/New_York",
|
26
|
+
"gmt_offset": "-18000",
|
27
|
+
"last_trade_time": "2020-02-27 16:17:34",
|
28
|
+
"pe": "N/A",
|
29
|
+
"eps": "N/A"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
@@ -31,6 +31,12 @@ describe Lita::Handlers::OnewheelFinance, lita_handler: true do
|
|
31
31
|
expect(replies.last).to include("\u000314NASDAQ - \u0003LULU: \u000302$233.01\u0003")
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'removes $ from ^ reqs' do
|
35
|
+
mock_up 'worldtradedata-quote-dji'
|
36
|
+
send_command 'q ^dji'
|
37
|
+
expect(replies.last).to include("\u000314INDEXDJX - \u0003^DJI: \u00030225766.64\u0003 \u000304 ↯-1190.95\u0003, \u000304-4.42%\u0003 \u000314(Dow Jones Industrial Average)\u0003")
|
38
|
+
end
|
39
|
+
|
34
40
|
#it 'errors' do
|
35
41
|
# mock_up 'worldtradedata-error'
|
36
42
|
# send_command 'quote in'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-finance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- spec/fixtures/alphavantage-quote-down.json
|
143
143
|
- spec/fixtures/effr.html
|
144
144
|
- spec/fixtures/worldtradedata-error.json
|
145
|
+
- spec/fixtures/worldtradedata-quote-dji.json
|
145
146
|
- spec/fixtures/worldtradedata-quote-down.json
|
146
147
|
- spec/fixtures/worldtradedata-quote-up.json
|
147
148
|
- spec/fixtures/worldtradedata-search-1.json
|
@@ -176,6 +177,7 @@ test_files:
|
|
176
177
|
- spec/fixtures/alphavantage-quote-down.json
|
177
178
|
- spec/fixtures/effr.html
|
178
179
|
- spec/fixtures/worldtradedata-error.json
|
180
|
+
- spec/fixtures/worldtradedata-quote-dji.json
|
179
181
|
- spec/fixtures/worldtradedata-quote-down.json
|
180
182
|
- spec/fixtures/worldtradedata-quote-up.json
|
181
183
|
- spec/fixtures/worldtradedata-search-1.json
|