ish_manager 0.1.8.279 → 0.1.8.284

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: 5752af378c30ba802cffc2bf97691555c43792e1882b1999f3673af0c9eb86cf
4
- data.tar.gz: c433e153fb732cfd0c9826ab711b73be0e99d18a198fb8ba4dea4b33d8c09fbc
3
+ metadata.gz: 43669b702b07d6fe56625d8627184844ca961c14363abf878edb580f7ea7074f
4
+ data.tar.gz: a775cf8632f0275360b0cb7632bbca30414dcb9b7318f659e8d49b000baf2d24
5
5
  SHA512:
6
- metadata.gz: c1719b020d95788eacfcc5cccdca47a317a7fe67dd6d7fbd4317c2ad6fbe3c9cdcde6fe82df6a253c6c914ef8c6f2d35acc89a2076de69575fca35a63b8a859f
7
- data.tar.gz: ec2d707acb1aa2d9b80aff4612be303d79a12f336eee5238ea898d06a5036b77e208865c6adef090bfa375f056539e5eba240a9946a191c471d5fe3cd9fa65c3
6
+ metadata.gz: 7090d09fc32da154da49bba462130634fc607cc376806c77c110f12e0f25d2ce0f5a50d2fe8189e60b922b056667133350bbff3998be953b2764a51d6bd4a54b
7
+ data.tar.gz: ef0a3e0572f706f8d7b53e73c35114d43ef8c0c5220ee5d6dad48a08e7d9b79d62a464e4cb23818f2b0a5029259e7c93f2556ac50133c5c98ba9dd3041c15da0
@@ -0,0 +1,60 @@
1
+
2
+ class IshManager::OptionWatchesController < IshManager::ApplicationController
3
+
4
+ layout 'ish_manager/application2'
5
+
6
+ ## alphabetized : )
7
+
8
+ def create
9
+ @option_watch = Warbler::OptionWatch.new permitted_params
10
+ authorize! :create, @option_watch
11
+ flag = @option_watch.save
12
+ if flag
13
+ flash[:notice] = 'Created option watch.'
14
+ else
15
+ flash[:alert] = "Cannot create option watch: #{@option_watch.errors.messages}"
16
+ end
17
+ redirect_to controller: 'stock_watches', action: 'index'
18
+ end
19
+
20
+ def destroy
21
+ @w = Warbler::StockWatch.find params[:id]
22
+ authorize! :destroy, @w
23
+ flag = @w.destroy
24
+ if flag
25
+ flash[:notice] = 'Success.'
26
+ else
27
+ flash[:alert] = @w.errors.messages
28
+ end
29
+ redirect_to controller: 'stock_watches', action: 'index'
30
+ end
31
+
32
+ def index
33
+ authorize! :open_permission, IshManager::Ability
34
+ flash[:notice] = 'Redirected option->stock watch index'
35
+ # redirect_to controller: IshManager::StockWatchesController, action: 'index'
36
+ redirect_to controller: 'stock_watches', action: 'index'
37
+ end
38
+
39
+ def update
40
+ @option_watch = Warbler::OptionWatch.find params[:id]
41
+ authorize! :update, @option_watch
42
+ flag = @option_watch.update_attributes permitted_params
43
+ if flag
44
+ flash[:notice] = 'Updated option watch.'
45
+ else
46
+ flash[:alert] = "Cannot update option watch: #{@option_watch.errors.messages}"
47
+ end
48
+ redirect_to controller: 'stock_watches', action: 'index'
49
+ end
50
+
51
+ private
52
+
53
+ def permitted_params
54
+ params[:warbler_option_watch].permit!
55
+ end
56
+
57
+ end
58
+
59
+
60
+
@@ -3,6 +3,8 @@ class IshManager::StockWatchesController < IshManager::ApplicationController
3
3
 
4
4
  layout 'ish_manager/application2'
5
5
 
6
+ ## alphabetized : )
7
+
6
8
  def create
7
9
  @stock_watch = Warbler::StockWatch.new permitted_params
8
10
  authorize! :create, @stock_watch
@@ -33,6 +35,8 @@ class IshManager::StockWatchesController < IshManager::ApplicationController
33
35
  @stock_watches = Warbler::StockWatch.order_by( ticker: :asc, direction: :asc, price: :desc
34
36
  ).includes( :profile )
35
37
  @stock_watch = Warbler::StockWatch.new
38
+ @option_watches = Warbler::OptionWatch.order_by( ticker: :asc, direction: :asc, price: :desc ).includes( :profile )
39
+ @option_watch = Warbler::OptionWatch.new
36
40
  end
37
41
 
38
42
  def update
@@ -15,12 +15,15 @@ module IshManager
15
15
  :subject => 'You got new shared galleries on pi manager' ).deliver
16
16
  end
17
17
 
18
+ def option_alert option
19
+ @option = option
20
+ mail( :to => option.profile.email, :subject => "IshManager Option Alert :: #{option.ticker}" ).deliver
21
+ end
18
22
 
19
23
  def stock_alert stock
20
24
  @stock = stock
21
25
  mail( :to => stock.profile.email, :subject => "IshManager Stock Alert :: #{stock.ticker}" ).deliver
22
26
  end
23
27
 
24
-
25
28
  end
26
29
  end
@@ -7,7 +7,7 @@ class IshManager::Ability
7
7
  #
8
8
  # signed in user
9
9
  #
10
- unless user.blank?
10
+ if !user.blank?
11
11
 
12
12
  #
13
13
  # only sudoer... total power
@@ -100,6 +100,8 @@ class IshManager::Ability
100
100
  #
101
101
  user ||= ::User.new
102
102
 
103
+ can [ :open_permission ], IshManager::Ability
104
+
103
105
  can [ :show ], ::Gallery do |gallery|
104
106
  gallery.is_public
105
107
  end
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ </head>
4
+ <body>
5
+ <h5>Notice</h5>
6
+ <p>The option <b><%= @option.ticker %> <%= @option.contractType %> <%= @option.date %> <%= @option.strike %></b>
7
+ is trading <%= @option.direction %> <%= @option.price %> at <%= Time.now %>.</p>
8
+ </body>
9
+ </html>
@@ -0,0 +1,37 @@
1
+
2
+ - if option_watch.persisted?
3
+ .float-left= button_to '[X]', option_watch_path(option_watch.id), method: :delete, data: { confirm: 'Are you sure?' }
4
+
5
+
6
+ - url = option_watches_path if !option_watch.persisted?
7
+ - url = option_watch_path( option_watch ) if option_watch.persisted?
8
+
9
+ = form_for option_watch, :url => url, :html => { :class => 'form-inline well' } do |f|
10
+ .flex-row
11
+ .form-group
12
+ = f.label :action
13
+ = f.select :action, options_for_select( Warbler::StockWatch::ACTIONS.map{|a|[a,a]}, :selected => option_watch.action )
14
+ .form-group
15
+ = f.label :profile
16
+ = f.select :profile, options_for_select( [[nil,nil]]+@profiles.map{|p|[p.email,p.id]}, :selected => option_watch.profile ? option_watch.profile.id : nil )
17
+ .form-group
18
+ %label.control-label When
19
+ = f.text_field :ticker, :class => 'form-control', :placeholder => 'ticker'
20
+ .form-group
21
+ %label.control-label Type
22
+ = f.select :contractType, options_for_select( [['none',nil],['PUT', 'PUT'], ['CALL', 'CALL']], :selected => option_watch.contractType )
23
+ .form-group
24
+ %label.control-label On date
25
+ = f.text_field :date, :class => 'form-control', :placeholder => 'date'
26
+ .form-group
27
+ %label.control-label Strike
28
+ = f.number_field :strike, :step => 0.01, :placeholder => "0.01"
29
+ .form-group
30
+ %label.control-label Is
31
+ = f.select :direction, options_for_select( Warbler::StockWatch::DIRECTIONS.map{|d|[d,d]}, :selected => option_watch.direction )
32
+ .form-group
33
+ %label.control-label Price
34
+ = f.number_field :price, :step => 0.01, :placeholder => "0.01"
35
+ .form-group
36
+ = f.submit ">", :class => %w(btn blue)
37
+
@@ -1,10 +1,24 @@
1
1
 
2
2
  %h4 Stock Watches
3
3
 
4
- %hr
5
4
  - @stock_watches.each do |stock|
5
+ %hr
6
6
  = render 'form', :stock_watch => stock
7
-
7
+
8
8
  %hr
9
9
  %h5 New
10
10
  = render 'form', :stock_watch => @stock_watch
11
+
12
+
13
+ %hr
14
+ %hr
15
+
16
+ %h4 Option Watches
17
+
18
+ - @option_watches.each do |option|
19
+ %hr
20
+ = render 'ish_manager/option_watches/form', option_watch: option
21
+
22
+ %hr
23
+ %h5 New
24
+ = render 'ish_manager/option_watches/form', option_watch: @option_watch
data/config/routes.rb CHANGED
@@ -82,6 +82,7 @@ IshManager::Engine.routes.draw do
82
82
  # resources :stock_actions
83
83
  # resources :stock_options
84
84
  resources :stock_watches
85
+ resources :option_watches
85
86
 
86
87
  resources :tags do
87
88
  resources :features
@@ -4,10 +4,6 @@ def puts! a, b=''
4
4
  puts a.inspect
5
5
  end
6
6
 
7
- class Warbler::StockWatch
8
- SLEEP_TIME_SECONDS = 60
9
- end
10
-
11
7
  namespace :ish_manager do
12
8
 
13
9
  desc "every user needs a user_profile"
@@ -27,9 +23,6 @@ namespace :ish_manager do
27
23
  while true
28
24
  stocks = Warbler::StockWatch.where( notification_type: :EMAIL )
29
25
  stocks.each do |stock|
30
-
31
- puts! stock, 'stock'
32
-
33
26
  begin
34
27
  Timeout::timeout( 10 ) do
35
28
  out = Warbler::Ameritrade::Api.get_quote({ symbol: stock.ticker })
@@ -40,7 +33,7 @@ namespace :ish_manager do
40
33
  end
41
34
  end
42
35
  rescue Exception => e
43
- puts! e, 'e in :watch_stocks'
36
+ puts! e, 'Error in ish_manager:watch_stocks :'
44
37
  end
45
38
  end
46
39
  sleep Warbler::StockWatch::SLEEP_TIME_SECONDS
@@ -0,0 +1,57 @@
1
+
2
+ def puts! a, b=''
3
+ puts "+++ +++ #{b}:"
4
+ pp a
5
+ end
6
+
7
+ namespace :warbler do
8
+
9
+ ## @TODO: this is still in ish_manager namespace, need to actually move it here.
10
+ desc 'watch the stocks, and trigger actions - not alphavantage, tda now. 2021-08-08'
11
+ task watch_stocks: :environment do
12
+ while true
13
+ stocks = Warbler::StockWatch.where( notification_type: :EMAIL )
14
+ stocks.each do |stock|
15
+ begin
16
+ Timeout::timeout( 10 ) do
17
+ out = Warbler::Ameritrade::Api.get_quote({ symbol: stock.ticker })
18
+ r = out[:lastPrice]
19
+ if stock.direction == :ABOVE && r >= stock.price ||
20
+ stock.direction == :BELOW && r <= stock.price
21
+ IshManager::ApplicationMailer.stock_alert( stock ).deliver
22
+ end
23
+ end
24
+ rescue Exception => e
25
+ puts! e, 'Error in ish_manager:watch_stocks :'
26
+ end
27
+ end
28
+ print '.'
29
+ sleep Warbler::StockWatch::SLEEP_TIME_SECONDS
30
+ end
31
+ end
32
+
33
+ desc 'watch option: contractType=PUT|CALL strike symbol date=yyyy-mm-dd'
34
+ task watch_options: :environment do
35
+ while true
36
+ option_watches = Warbler::OptionWatch.where( notification_type: :EMAIL )
37
+ option_watches.each do |option|
38
+ begin
39
+ Timeout::timeout( 10 ) do
40
+ ## opts = { contractType: 'PUT', strike: 355.0, symbol: 'NVDA', date: '2022-02-18' }
41
+ out = Warbler::Ameritrade::Api.get_option( option )
42
+ r = out[:last]
43
+ if option.direction == :ABOVE && r >= option.price ||
44
+ option.direction == :BELOW && r <= option.price
45
+ IshManager::ApplicationMailer.option_alert( option ).deliver
46
+ end
47
+ end
48
+ rescue Exception => e
49
+ puts! e, 'Error in ish_manager:watch_options :'
50
+ end
51
+ end
52
+ print '.'
53
+ sleep Warbler::OptionWatch::SLEEP_TIME_SECONDS
54
+ end
55
+ end
56
+
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.279
4
+ version: 0.1.8.284
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-28 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -202,6 +202,7 @@ files:
202
202
  - app/controllers/ish_manager/maps_controller.rb
203
203
  - app/controllers/ish_manager/markers_controller.rb
204
204
  - app/controllers/ish_manager/newsitems_controller.rb
205
+ - app/controllers/ish_manager/option_watches_controller.rb
205
206
  - app/controllers/ish_manager/orders_controller.rb
206
207
  - app/controllers/ish_manager/payments_controller.rb
207
208
  - app/controllers/ish_manager/photos_controller.rb
@@ -234,6 +235,7 @@ files:
234
235
  - app/views/ish_manager/application/_search.haml
235
236
  - app/views/ish_manager/application/home.haml
236
237
  - app/views/ish_manager/application_mailer/condor_followup_alerb.html.erb
238
+ - app/views/ish_manager/application_mailer/option_alert.html.erb
237
239
  - app/views/ish_manager/application_mailer/shared_galleries.html.erb
238
240
  - app/views/ish_manager/application_mailer/stock_alert.html.erb
239
241
  - app/views/ish_manager/application_mailer/welcome.html.erb
@@ -305,6 +307,7 @@ files:
305
307
  - app/views/ish_manager/newsitems/edit.haml
306
308
  - app/views/ish_manager/newsitems/index.haml
307
309
  - app/views/ish_manager/newsitems/new.haml
310
+ - app/views/ish_manager/option_watches/_form.haml
308
311
  - app/views/ish_manager/payments/index.haml
309
312
  - app/views/ish_manager/photos/_meta.haml
310
313
  - app/views/ish_manager/photos/_meta_manager.haml
@@ -380,6 +383,7 @@ files:
380
383
  - lib/systemd/system/watch_stocks.service
381
384
  - lib/tasks/ish_manager_tasks.rake
382
385
  - lib/tasks/migrate.rake
386
+ - lib/tasks/warbler_tasks.rake
383
387
  homepage: http://wasya.co
384
388
  licenses:
385
389
  - MIT