ish_models 0.0.33.87 → 0.0.33.94
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
- data/lib/video.rb +25 -5
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70debd7a9ae9d44c72b135dc07c1d2e72f01d7381c154a68ad47b72600e3f5b7
|
4
|
+
data.tar.gz: c8361dce103b2f3ac55e3aeb440ed967048e40d17e1e495f4b80b4d2c9918885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b0a2d11b62f6841bf034113917f75cca41814cd716205394dc3223ae82134d24bcf59ed9a3f8945a8f520dc58877523a21dbfb56e350bcc8432fce1927de61e
|
7
|
+
data.tar.gz: 90affd7f361d3b63f4b6c4711132614032788d0d41c09551542a0fa467bbe08ee522911c9d68b1ed5521934eba88d27706cb228dce3afcf95a0853fd9c21ebab
|
@@ -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
|
data/lib/video.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Video
|
2
2
|
include Mongoid::Document
|
3
3
|
include Mongoid::Timestamps
|
4
|
+
include Mongoid::Paperclip
|
4
5
|
|
5
6
|
PER_PAGE = 6
|
6
7
|
|
@@ -20,7 +21,7 @@ class Video
|
|
20
21
|
field :lang, :type => String, :default => 'en'
|
21
22
|
|
22
23
|
field :youtube_id, :type => String
|
23
|
-
validates :youtube_id, :uniqueness => true, :presence => true
|
24
|
+
# validates :youtube_id, :uniqueness => true, :presence => true
|
24
25
|
|
25
26
|
belongs_to :tag, :optional => true
|
26
27
|
belongs_to :city, :optional => true
|
@@ -32,7 +33,7 @@ class Video
|
|
32
33
|
accepts_nested_attributes_for :site, :tag, :city
|
33
34
|
|
34
35
|
def self.list
|
35
|
-
[['', nil]] + Video.
|
36
|
+
[['', nil]] + Video.unscoped.order_by( :created_at => :desc ).map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
|
36
37
|
end
|
37
38
|
|
38
39
|
set_callback( :create, :before ) do |doc|
|
@@ -45,9 +46,28 @@ class Video
|
|
45
46
|
|
46
47
|
field :issue
|
47
48
|
|
48
|
-
|
49
|
-
:thumb => { geometry: '192x108', format: 'jpeg' },
|
50
|
-
|
49
|
+
has_mongoid_attached_file :video,
|
50
|
+
# styles: { :thumb => { geometry: '192x108', format: 'jpeg' }, },
|
51
|
+
# processors: [ :transcoder ],
|
52
|
+
:storage => :s3,
|
53
|
+
:s3_credentials => ::S3_CREDENTIALS,
|
54
|
+
:path => "videos/:style/:id/:filename",
|
55
|
+
:s3_protocol => 'https',
|
56
|
+
:s3_permissions => 'public-read',
|
57
|
+
:validate_media_type => false
|
51
58
|
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
|
52
59
|
|
60
|
+
has_mongoid_attached_file :thumb,
|
61
|
+
:styles => {
|
62
|
+
:mini => '20x20#',
|
63
|
+
:thumb => "100x100#",
|
64
|
+
:small => "400x400>",
|
65
|
+
},
|
66
|
+
:storage => :s3,
|
67
|
+
:s3_credentials => ::S3_CREDENTIALS,
|
68
|
+
:path => "videos/:style/:id/thumb_:filename",
|
69
|
+
:s3_protocol => 'https',
|
70
|
+
:validate_media_type => false
|
71
|
+
validates_attachment_content_type :thumb, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
|
72
|
+
|
53
73
|
end
|
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.94
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -14,20 +14,20 @@ dependencies:
|
|
14
14
|
name: mongoid
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 6.1.0
|
20
|
-
- - "
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 6.1.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 6.1.0
|
30
|
-
- - "
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 6.1.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
@@ -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
|
@@ -165,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
166
|
- !ruby/object:Gem::Version
|
166
167
|
version: '0'
|
167
168
|
requirements: []
|
168
|
-
|
169
|
-
rubygems_version: 2.7.3
|
169
|
+
rubygems_version: 3.0.6
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: models of ish
|