ish_models 0.0.33.90 → 0.0.33.91
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ish/stockwatcher.rb +29 -0
- data/lib/ish_models.rb +1 -0
- data/lib/ish_models/stock_watch.rb +5 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b71b3055f07ba124932d22bb734bc46dd657ec3f184771d681e0edd99d4aa234
|
4
|
+
data.tar.gz: 692e492b7c58974d2e7567958b29698da66861c1418ddb7449fef5e7ac9ac9ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a5a9fa009383235d00d97333bd658c0cd3a0aa8483b7f4e916a298ad3bb9c18db94eb2adbccb629446444eb007bef57d7376a4a5be40a8b87a64908877aad3
|
7
|
+
data.tar.gz: 79bd225334651885df0ca977ee7c35c6cede1aed2734a78ab774134279c94a983550eb108b83aa0ed1b610ca14f498e068d507668c633d9c23eb21a2c718eb4c
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
class Stockwatcher
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
end
|
6
|
+
|
7
|
+
# every minute, for alphavantage.co
|
8
|
+
def watch
|
9
|
+
stocks = Ish::StockWatch.where( :notification_type => :EMAIL )
|
10
|
+
puts! stocks.map(&:ticker), "Watching these stocks:"
|
11
|
+
stocks.each do |stock|
|
12
|
+
r = HTTParty.get "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=#{stock.ticker}&interval=1min&apikey=X1C5GGH5MZSXMF3O", timeout: 10
|
13
|
+
r2 = JSON.parse( r.body )['Time Series (1min)']
|
14
|
+
r3 = r2[r2.keys.first]['4. close'].to_f
|
15
|
+
if stock.direction == :ABOVE && r3 >= stock.price ||
|
16
|
+
stock.direction == :BELOW && r3 <= stock.price
|
17
|
+
IshManager::ApplicationMailer.stock_alert( stock ).deliver
|
18
|
+
|
19
|
+
## actions
|
20
|
+
## exit the position
|
21
|
+
# stock.stock_actions.where( :is_active => true ).each do |action|
|
22
|
+
# # @TODO: actions
|
23
|
+
# end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/ish_models.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
|
2
|
+
#
|
3
|
+
# See also ish_manager / lib / stockwatcher.rb
|
4
|
+
#
|
5
|
+
|
2
6
|
class IshModels::StockWatch
|
3
7
|
include Mongoid::Document
|
4
8
|
include Mongoid::Timestamps
|
@@ -11,6 +15,7 @@ class IshModels::StockWatch
|
|
11
15
|
NOTIFICATION_SMS = :SMS
|
12
16
|
ACTIONS = NOTIFICATION_TYPES
|
13
17
|
field :notification_type, :type => Symbol, :as => :action
|
18
|
+
|
14
19
|
=begin
|
15
20
|
def action
|
16
21
|
return notification_type
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.33.
|
4
|
+
version: 0.0.33.91
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/ish/stock_action.rb
|
132
132
|
- lib/ish/stock_option.rb
|
133
133
|
- lib/ish/stock_watch.rb
|
134
|
+
- lib/ish/stockwatcher.rb
|
134
135
|
- lib/ish_models.rb
|
135
136
|
- lib/ish_models/cache_key.rb
|
136
137
|
- lib/ish_models/configuration.rb
|