iron_warbler 2.0.7.15 → 2.0.7.16
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 +4 -4
- data/app/mailers/iro/alert_mailer.rb +3 -3
- data/app/models/iro/alert.rb +24 -0
- data/app/models/iro/price_item.rb +22 -0
- data/lib/tasks/iro_tasks.rake +1 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18954e909b6d16fbfd4f1edaede8493c0a011308febb3c37ad3e539a6d4d78b0
|
4
|
+
data.tar.gz: 22b2c2e0cd159318cfb8f674aafecdcf70640fabf42872b72b839fcde1ebd099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e0609f0dfd3a5d97ac09523110f558c99f0e2acc2e7d646ef2a974b107b65c4fd0001e44bb64079d1baaaa05dd5d52a8c3e853166cd08a384a7fe0ea0d29d47
|
7
|
+
data.tar.gz: bee57f8a6d5ab1006d5bba159cec53e7cf86dbeeda98f73cc5a6d2c24a89b88c0362639c9b03eabade29316f615f67869114a665a95dfe851efcfca312203cbf
|
@@ -3,10 +3,10 @@ class Iro::AlertMailer < ActionMailer::Base
|
|
3
3
|
default from: 'no-reply@wasya.co'
|
4
4
|
layout 'mailer'
|
5
5
|
|
6
|
-
def stock_alert
|
7
|
-
@alert =
|
6
|
+
def stock_alert id
|
7
|
+
@alert = Iro::Alert.find id
|
8
8
|
mail( to: 'poxlovi@gmail.com',
|
9
|
-
|
9
|
+
subject: 'Iro::AlertMailer#stock_alert' )
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
data/app/models/iro/alert.rb
CHANGED
@@ -32,4 +32,28 @@ class Iro::Alert
|
|
32
32
|
field :strike
|
33
33
|
validates :strike, presence: true
|
34
34
|
|
35
|
+
def do_run
|
36
|
+
alert = self
|
37
|
+
begin
|
38
|
+
price = Tda::Stock.get_quote( alert.symbol ).last
|
39
|
+
|
40
|
+
if alert.direction == self.class::DIRECTION_ABOVE && price >= alert.strike ||
|
41
|
+
alert.direction == self.class::DIRECTION_BELOW && price <= alert.strike
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_later
|
46
|
+
alert.update({ status: self.class::STATUS_INACTIVE })
|
47
|
+
print '^'
|
48
|
+
|
49
|
+
end
|
50
|
+
rescue => err
|
51
|
+
puts! err, 'err'
|
52
|
+
::ExceptionNotifier.notify_exception(
|
53
|
+
err,
|
54
|
+
data: { alert: alert }
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
35
59
|
end
|
@@ -4,4 +4,26 @@ class Iro::PriceItem
|
|
4
4
|
include Mongoid::Timestamps
|
5
5
|
store_in collection: 'iro_price_items'
|
6
6
|
|
7
|
+
field :putCall, type: String
|
8
|
+
field :symbol, type: String
|
9
|
+
field :ticker, type: String
|
10
|
+
|
11
|
+
field :bid, type: Float
|
12
|
+
field :bidSize, type: Integer
|
13
|
+
field :ask, type: Float
|
14
|
+
field :askSize, type: Integer
|
15
|
+
field :last, type: Float
|
16
|
+
|
17
|
+
field :openPrice, type: Float
|
18
|
+
field :closePrice, type: Float
|
19
|
+
field :lowPrice, type: Float
|
20
|
+
field :highPrice, type: Float
|
21
|
+
|
22
|
+
field :quoteTimeInLong, type: Integer
|
23
|
+
field :timestamp, type: Integer
|
24
|
+
field :totalVolume, type: Integer
|
25
|
+
field :mark, type: Float
|
26
|
+
field :exchangeName, type: String
|
27
|
+
field :volatility, type: Float
|
28
|
+
|
7
29
|
end
|
data/lib/tasks/iro_tasks.rake
CHANGED
@@ -6,26 +6,7 @@ namespace :iro do
|
|
6
6
|
print 'iro:alerts'
|
7
7
|
while true
|
8
8
|
Iro::Alert.active.each do |alert|
|
9
|
-
|
10
|
-
|
11
|
-
# price = Iro::Stock.latest( alert.ticker ).price
|
12
|
-
price = Tda::Api.get_quote( alert.symbol ).last
|
13
|
-
|
14
|
-
if alert.direction == Iro::Alert::DIRECTION_ABOVE && price >= alert.strike ||
|
15
|
-
alert.direction == Iro::Alert::DIRECTION_BELOW && price <= alert.strike
|
16
|
-
|
17
|
-
Iro::AlertMailer.stock_alert( alert ).deliver_later
|
18
|
-
alert.update({ status: Iro::Alert::STATUS_INACTIVE })
|
19
|
-
print '^'
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue => err
|
24
|
-
::ExceptionNotifier.notify_exception(
|
25
|
-
err,
|
26
|
-
data: { alert: alert }
|
27
|
-
)
|
28
|
-
end
|
9
|
+
alert.do_run
|
29
10
|
end
|
30
11
|
|
31
12
|
print '.'
|