iron_warbler 2.0.7.14 → 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 +25 -1
- data/app/models/iro/price_item.rb +22 -0
- data/lib/tasks/iro_tasks.rake +13 -24
- 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
@@ -4,7 +4,7 @@ class Iro::Alert
|
|
4
4
|
include Mongoid::Timestamps
|
5
5
|
store_in collection: 'iro_alerts'
|
6
6
|
|
7
|
-
SLEEP_TIME_SECONDS = Rails.env.production? ? 60 : 15
|
7
|
+
# SLEEP_TIME_SECONDS = Rails.env.production? ? 60 : 15
|
8
8
|
|
9
9
|
DIRECTION_ABOVE = 'ABOVE'
|
10
10
|
DIRECTION_BELOW = 'BELOW'
|
@@ -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
@@ -1,6 +1,19 @@
|
|
1
1
|
|
2
2
|
namespace :iro do
|
3
3
|
|
4
|
+
desc 'alerts'
|
5
|
+
task alerts: :environment do
|
6
|
+
print 'iro:alerts'
|
7
|
+
while true
|
8
|
+
Iro::Alert.active.each do |alert|
|
9
|
+
alert.do_run
|
10
|
+
end
|
11
|
+
|
12
|
+
print '.'
|
13
|
+
sleep Rails.env.production? ? 60 : 15
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
4
17
|
desc 'recommend position actions'
|
5
18
|
task recommend_position_actions: :environment do
|
6
19
|
Iro::Position.active.where({ kind: 'covered_call' }).map &:should_roll?
|
@@ -53,30 +66,6 @@ namespace :iro do
|
|
53
66
|
end
|
54
67
|
end
|
55
68
|
|
56
|
-
desc 'alerts'
|
57
|
-
task alerts: :environment do
|
58
|
-
print 'iro:alerts'
|
59
|
-
while true
|
60
|
-
Iro::Alert.active.each do |alert|
|
61
|
-
|
62
|
-
# price = Iro::Stock.latest( alert.ticker ).price
|
63
|
-
price = Tda::Api.get_quote( alert.symbol ).last
|
64
|
-
|
65
|
-
if alert.direction == Iro::Alert::DIRECTION_ABOVE && price >= alert.strike ||
|
66
|
-
alert.direction == Iro::Alert::DIRECTION_BELOW && price <= alert.strike
|
67
|
-
|
68
|
-
Iro::AlertMailer.stock_alert( alert ).deliver_later
|
69
|
-
alert.update({ status: Iro::Alert::STATUS_INACTIVE })
|
70
|
-
print '^'
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
print '.'
|
76
|
-
sleep Iro::Alert::SLEEP_TIME_SECONDS
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
69
|
end
|
81
70
|
|
82
71
|
|