iron_warbler 2.0.7.14 → 2.0.7.16

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: '08950feb78bbd2b496a19f3dd46a8cf689167bba60a700814182aba57e13e56d'
4
- data.tar.gz: a459e6b34168a50c4e68d50c1c7f005027b48760162e662db0f4bf9f746d0a62
3
+ metadata.gz: 18954e909b6d16fbfd4f1edaede8493c0a011308febb3c37ad3e539a6d4d78b0
4
+ data.tar.gz: 22b2c2e0cd159318cfb8f674aafecdcf70640fabf42872b72b839fcde1ebd099
5
5
  SHA512:
6
- metadata.gz: ee7779864feda3323a58c513f31c1b4f8b7d23b3338ddf72d34f404652189577cd759aa0635be173de9e75dec94112714a227cc7c7ca949da16e57ec997c29e3
7
- data.tar.gz: b8ec7aeff649eb60172ff42aaeb5bf33f58e13533ffe04c9e11b5a4b30df70c8cfc9da43a62f10153eec7207a04d9e7973eca21bff2a4f093480a7851e81a50e
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 alert
7
- @alert = alert
6
+ def stock_alert id
7
+ @alert = Iro::Alert.find id
8
8
  mail( to: 'poxlovi@gmail.com',
9
- subject: 'Iro::AlertMailer#stock_alert' )
9
+ subject: 'Iro::AlertMailer#stock_alert' )
10
10
  end
11
11
 
12
12
  end
@@ -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
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7.14
4
+ version: 2.0.7.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev