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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dce275679a63eca4f511e9bd09c9d9d59144d4d2d7d4234794a3a3b54f530b3f
4
- data.tar.gz: ecbd9e67e94e462255793c7f98d86b88edb22cd89f8239c5ac613abdb836b26f
3
+ metadata.gz: b71b3055f07ba124932d22bb734bc46dd657ec3f184771d681e0edd99d4aa234
4
+ data.tar.gz: 692e492b7c58974d2e7567958b29698da66861c1418ddb7449fef5e7ac9ac9ab
5
5
  SHA512:
6
- metadata.gz: 164fcd6404de1fcc3305e26e22a5963deb4389554716ca5e6cc91420beeb8ae899a32057b6d84288f32f60b140b31282a2678955dbee51b1514e7f99613df338
7
- data.tar.gz: 5da90016b92e6c2f601682db9cc8a4eddc487e7fc2cd54a953634c3b865971d2f49c10b6dbe74cb1045ca913353b6165d50180113d787435c2257899f64925f1
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
@@ -32,6 +32,7 @@ require 'ish/payment.rb'
32
32
  require 'ish/stock_action.rb'
33
33
  require 'ish/stock_option.rb'
34
34
  require 'ish/stock_watch.rb'
35
+ require 'ish/stockwatcher.rb'
35
36
  require 'ish/invoice.rb'
36
37
  require 'ish/lead.rb'
37
38
  require 'ish/campaign.rb'
@@ -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.90
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