iron_warbler 2.0.7.15 → 2.0.7.17
Sign up to get free protection for your applications and to get access to all the features.
- 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: a9a1d4d1eda9f6a71ac418d24a0e8588efbbe3d8d0c145964f55feef14393aed
|
4
|
+
data.tar.gz: 30c1242bfd9f12e1809a8fb2aa4289057aa8b1cc336e3e7020d98c9f98c84768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2fcb877e026eabbb1786607e5c64256946f029f8d5175e53cb2295f8b8adf262222ca1af39810bc68aed6ce6953f78c716bf7985bb3d24b92c0d1d907af90f
|
7
|
+
data.tar.gz: 4020c6358719dea41655172bbc96d3fbc15124a2af4797ceeaa24bb76d8b36cea199c6dfa3cf1c3a63982f83fde03aa4930eeeb011f73014c7bcd3d559d37cd9
|
@@ -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 == alert.class::DIRECTION_ABOVE && price >= alert.strike ||
|
41
|
+
alert.direction == alert.class::DIRECTION_BELOW && price <= alert.strike
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_later
|
46
|
+
alert.update({ status: alert.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 '.'
|