ish_manager 0.1.8.287 → 0.1.8.290

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ish_manager/application.js +2 -2
  3. data/app/assets/stylesheets/ish_manager/application.scss +10 -2
  4. data/app/controllers/ish_manager/application_controller.rb +1 -1
  5. data/app/controllers/ish_manager/galleries_controller.rb +5 -4
  6. data/app/controllers/ish_manager/image_assets_controller.rb +10 -0
  7. data/app/controllers/ish_manager/maps_controller.rb +81 -1
  8. data/app/controllers/ish_manager/markers_controller.rb +6 -1
  9. data/app/controllers/ish_manager/sites_controller.rb +46 -48
  10. data/app/helpers/ish_manager/images_helper.rb +38 -37
  11. data/app/models/ish_manager/ability.rb +5 -2
  12. data/app/views/ish_manager/application/_debug.haml +2 -1
  13. data/app/views/ish_manager/application/_main_header_admin.haml +6 -2
  14. data/app/views/ish_manager/image_assets/index.haml +6 -0
  15. data/app/views/ish_manager/maps/_form.haml +4 -0
  16. data/app/views/ish_manager/maps/index.haml +8 -1
  17. data/app/views/ish_manager/maps/map_editor.haml +2 -17
  18. data/app/views/ish_manager/maps/show.haml +10 -2
  19. data/app/views/ish_manager/markers/_index_small.haml +28 -0
  20. data/app/views/ish_manager/photos/_meta.haml +2 -2
  21. data/app/views/ish_manager/videos/show.haml +1 -1
  22. data/app/views/layouts/ish_manager/README.txt +3 -0
  23. data/app/views/layouts/ish_manager/application.haml +1 -0
  24. data/app/views/layouts/ish_manager/application.haml-trash +40 -0
  25. data/app/views/layouts/ish_manager/application2.haml +17 -15
  26. data/config/routes.rb +5 -0
  27. data/config/systemd/system/README.txt +3 -0
  28. data/{lib/systemd/system/watch_stocks.service → config/systemd/system/stockwatcher.service} +0 -0
  29. data/config/systemd/system/watch_stocks.service +13 -0
  30. data/lib/ish_manager/engine.rb +1 -0
  31. data/lib/ish_manager.rb +1 -0
  32. data/lib/tasks/ish_manager_tasks.rake +7 -0
  33. data/lib/tasks/migrate.rake +16 -1
  34. metadata +74 -38
  35. data/app/controllers/ish_manager/features_controller.rb +0 -150
  36. data/app/controllers/ish_manager/option_watches_controller.rb +0 -60
  37. data/app/controllers/ish_manager/stock_watches_controller.rb +0 -63
  38. data/app/views/ish_manager/application/_main_header_admin.haml-trash +0 -21
  39. data/app/views/ish_manager/maps/index.haml-trash +0 -17
  40. data/app/views/ish_manager/option_watches/_form.haml +0 -37
  41. data/app/views/ish_manager/stock_actions/_form.haml +0 -27
  42. data/app/views/ish_manager/stock_actions/index.haml +0 -13
  43. data/app/views/ish_manager/stock_options/_form.haml +0 -22
  44. data/app/views/ish_manager/stock_options/index.haml +0 -11
  45. data/app/views/ish_manager/stock_watches/_form.haml +0 -28
  46. data/app/views/ish_manager/stock_watches/index.haml +0 -24
  47. data/app/views/layouts/ish_manager/application.haml +0 -40
  48. data/lib/tasks/warbler_tasks.rake +0 -57
@@ -1,150 +0,0 @@
1
-
2
- class IshManager::FeaturesController < IshManager::ApplicationController
3
-
4
- before_action :set_lists
5
-
6
- def new
7
- if params[:city_id]
8
- @city = City.find params[:city_id]
9
- authorize! :new_feature, @city
10
- elsif params[:site_id]
11
- @site = Site.find params[:site_id]
12
- authorize! :new_feature, @site
13
- elsif params[:tag_id]
14
- @tag = Tag.find params[:tag_id]
15
- authorize! :new_feature, @tag
16
- end
17
-
18
- @feature = Feature.new
19
- end
20
-
21
- def create
22
- @feature = Feature.new params[:feature].permit!
23
-
24
- if params[:city_id]
25
- @city = City.find params[:city_id]
26
- authorize! :create_feature, @city
27
- @city.features << @feature
28
- @city.touch
29
- redirect_path = cities_path
30
- end
31
- if params[:site_id]
32
- @site = Site.find params[:site_id]
33
- authorize! :create_feature, @site
34
- @site.features << @feature
35
- @site.touch
36
- redirect_path = sites_path
37
- end
38
- if params[:tag_id]
39
- @tag = Tag.find params[:tag_id]
40
- authorize! :create_feature, @tag
41
- @tag.features << @feature
42
- @tag.touch
43
- redirect_path = tags_path
44
- end
45
-
46
- if (@city && @city.save) || (@site && @site.save) || (@tag && @tag.save)
47
- flash[:notice] = 'Success.'
48
- redirect_to redirect_path
49
- else
50
- flash[:alert] = "No luck: #{pp_errors @feature.errors.messages}"
51
- render :action => :new
52
- end
53
- end
54
-
55
- def edit
56
- if params[:city_id]
57
- @city = City.find params[:city_id]
58
- @feature = @city.features.find params[:id]
59
- authorize! :edit_feature, @city
60
- end
61
-
62
- if params[:site_id]
63
- @site = Site.find params[:site_id]
64
- @feature = @site.features.find params[:id]
65
- authorize! :edit_feature, @site
66
- end
67
-
68
- if params[:tag_id]
69
- @tag = Tag.find params[:tag_id]
70
- @feature = @tag.features.find params[:id]
71
- authorize! :edit_feature, @tag
72
- end
73
-
74
- if params[:venue_id]
75
- @venue = Tag.find params[:venue_id]
76
- @feature = @venue.features.find params[:id]
77
- authorize! :edit_feature, @venue
78
- end
79
-
80
- end
81
-
82
- def update
83
- unless params[:city_id].blank?
84
- @city = City.find params[:city_id]
85
- authorize! :update_feature, @city
86
- @feature = @city.features.find params[:id]
87
- redirect_path = city_path( @city )
88
- end
89
- unless params[:site_id].blank?
90
- @site = Site.find params[:site_id]
91
- authorize! :update_feature, @site
92
- @feature = @site.features.find params[:id]
93
- redirect_path = site_path( @site )
94
- end
95
- unless params[:tag_id].blank?
96
- @tag = Tag.find params[:tag_id]
97
- authorize! :update_feature, @tag
98
- @feature = @tag.features.find params[:id]
99
- redirect_path = tag_path( @tag )
100
- end
101
-
102
- authorize! :update, @feature
103
-
104
- if @feature.update_attributes params[:feature].permit!
105
- @city.touch if @city
106
- @site.touch if @site
107
- @tag.touch if @tag
108
-
109
- flash[:notice] = 'updated feature'
110
- redirect_to redirect_path
111
- else
112
- flash[:alert] = 'No Luck. ' + @feature.errors.messages
113
- render :action => :edit
114
- end
115
- end
116
-
117
- def index
118
- if params[:tag_id]
119
- @resource = Tag.find params[:tag_id]
120
- end
121
- if params[:site_id]
122
- @resource = Site.find params[:site_id]
123
- end
124
- authorize! :features_index, @resource
125
- @features = @resource.features
126
- end
127
-
128
- def destroy
129
- if params[:tag_id]
130
- @resource = Tag.find params[:tag_id]
131
- elsif params[:city_id]
132
- @resource = City.find params[:city_id]
133
- elsif params[:site_id]
134
- @resource = Site.find params[:site_id]
135
- end
136
- authorize! :destroy_feature, @resource
137
- @feature = @resource.features.find params[:id]
138
- authorize! :destroy, @feature
139
-
140
- if @feature.destroy
141
- @resource.touch
142
- flash[:notice] = 'Success.'
143
- else
144
- flash[:alert] = "No luck. " + @feature.errors.messages
145
- end
146
- redirect_to request.referrer
147
- end
148
-
149
- end
150
-
@@ -1,60 +0,0 @@
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
-
@@ -1,63 +0,0 @@
1
-
2
- class IshManager::StockWatchesController < IshManager::ApplicationController
3
-
4
- layout 'ish_manager/application2'
5
-
6
- ## alphabetized : )
7
-
8
- def create
9
- @stock_watch = Warbler::StockWatch.new permitted_params
10
- authorize! :create, @stock_watch
11
- flag = @stock_watch.save
12
- if flag
13
- flash[:notice] = 'Created stock watch.'
14
- else
15
- flash[:alert] = "Cannot create stock watch: #{@stock_watch.errors.messages}"
16
- end
17
- redirect_to :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 action: 'index'
30
- end
31
-
32
- def index
33
- authorize! :index, Warbler::StockWatch
34
- @profiles = Ish::UserProfile.all
35
- @stock_watches = Warbler::StockWatch.order_by( ticker: :asc, direction: :asc, price: :desc
36
- ).includes( :profile )
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
40
- end
41
-
42
- def update
43
- @stock_watch = Warbler::StockWatch.find params[:id]
44
- authorize! :update, @stock_watch
45
- flag = @stock_watch.update_attributes permitted_params
46
- if flag
47
- flash[:notice] = 'Updated stock watch.'
48
- else
49
- flash[:alert] = "Cannot update stock watch: #{@stock_watch.errors.messages}"
50
- end
51
- redirect_to :action => 'index'
52
- end
53
-
54
- private
55
-
56
- def permitted_params
57
- params[:warbler_stock_watch].permit!
58
- end
59
-
60
- end
61
-
62
-
63
-
@@ -1,21 +0,0 @@
1
-
2
-
3
- -# %li{ :class => params[:controller] == 'ish_manager/sites' ? 'active' : '' }= link_to 'Sites', sites_path
4
- -# %li{ :class => params[:controller] == 'ish_manager/tags' ? 'active' : '' }= link_to 'Tags', tags_path
5
- -# %li{ :class => params[:controller] == 'ish_manager/cities' ? 'active' : '' }= link_to 'Cities', cities_path
6
- -# %li{ :class => params[:controller] == 'ish_manager/events' ? 'active' : '' }= link_to 'Events', events_path
7
- -# %li{ :class => params[:controller] == 'ish_manager/venues' ? 'active' : '' }= link_to 'Venues', venues_path
8
- -# %li{ :class => params[:controller] == 'ish_manager/friends ' ? 'active' : '' }= link_to 'Friends', friends_path
9
- - proc do # nothing
10
- %ul.nav.nav-pills
11
- -# %li{ :class => params[:controller] == 'ish_manager/stock_actions' ? 'active' : '' }= link_to 'Stock Actions', stock_actions_path
12
- -# %li{ :class => params[:controller] == 'ish_manager/stock_options' ? 'active' : '' }= link_to 'Stock Options', stock_options_path
13
- -# %li{ :class => params[:controller] == 'ish_manager/iron_condors' ? 'active' : '' }= link_to 'Iron Condors', iron_condors_path
14
- -# %li{ :class => params[:controller] == 'ish_manager/covered_calls' ? 'active' : '' }= link_to 'Covered Calls', covered_calls_path
15
- %ul.nav.nav-pills
16
- %li{ :class => params[:controller] == 'ish_manager/invoices' ? 'active' : '' }= link_to 'Invoices', invoices_path
17
- %li{ :class => params[:controller] == 'ish_manager/payments' ? 'active' : '' }= link_to 'Payments', payments_path
18
- %li{ :class => params[:controller] == 'ish_manager/orders' ? 'active' : '' }= link_to 'Orders', orders_path
19
- %ul.nav.nav-pills
20
- %li{ :class => params[:controller] == 'ish_manager/leads' ? 'active' : '' }= link_to 'Leads', leads_path
21
- %li{ :class => params[:controller] == 'ish_manager/campaigns' ? 'active' : '' }= link_to 'Campaigns', campaigns_path
@@ -1,17 +0,0 @@
1
-
2
- .maps-index
3
- %h1 Maps #{link_to '[+]', new_map_path}
4
- - @maps.each do |map|
5
- .item
6
- .col
7
- = render 'map_meta_row', map: map
8
- .col
9
- .row
10
- .a Markers (#{map.markers.length})
11
- .a #{button_to '+', new_map_marker_path(map), method: :get}
12
- %ul.markers
13
- - map.markers.each do |marker|
14
- %li
15
- = marker.slug
16
- = link_to '[~]', edit_marker_path(marker)
17
-
@@ -1,37 +0,0 @@
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,27 +0,0 @@
1
-
2
- -#
3
- -# ish_manager / stock_actions / _form
4
- -#
5
-
6
- - url = stock_actions_path if !stock_action.persisted?
7
- - url = stock_action_path( stock_action ) if stock_action.persisted?
8
-
9
- - if stock_action.profile
10
- Belongs to #{stock_action.profile.email}
11
- = form_for stock_action, :url => url, :html => { :class => 'form-inline well' } do |f|
12
- .form-group
13
- %label.control-label Active?
14
- = f.check_box :is_active
15
- .form-group
16
- - which_selected = stock_action.stock_watch ? stock_action.stock_watch.id : nil
17
- %label.control-label When stock watch
18
- = f.select :stock_watch, options_for_select( @stock_watches_list, :selected => which_selected )
19
- .form-group
20
- %label.control-label Sell options
21
- - @stock_options_list.each do |item|
22
- - checked = stock_action.stock_options.map(&:id).include?(item[1])
23
- .stock-option
24
- = f.check_box :stock_options, { :multiple => true, :checked => checked }, item[1], nil
25
- = item[0]
26
- .form-group
27
- = f.submit ">", :class => %w(btn blue)
@@ -1,13 +0,0 @@
1
-
2
- %h4 Stock Actions
3
-
4
- %p <b>Note:</b> a stock option cannot belong to two actions.
5
-
6
- %hr
7
- - @stock_actions.each do |stock_action|
8
- = render 'form', :stock_action => stock_action
9
-
10
- %hr
11
- %h5 New
12
- = render 'form', :stock_action => @stock_action
13
-
@@ -1,22 +0,0 @@
1
-
2
- - url = stock_options_path if !stock_option.persisted?
3
- - url = stock_options_path( stock_option ) if stock_option.persisted?
4
-
5
- - if stock_option.profile
6
- Belongs to #{stock_option.profile.email}
7
- = form_for stock_option, :url => url, :html => { :class => 'form-inline well' } do |f|
8
- .form-group
9
- = f.text_field :ticker, :class => 'form-control', :placeholder => 'ticker'
10
- .form-group
11
- = f.text_field :expires_on, :class => 'form-control', :placeholder => 'YYYYMMDD' # :placeholder => 'MON(TH) DD YYYY'
12
- .form-group
13
- %label.control-label $
14
- = f.number_field :strike, :step => 0.01, :class => 'form-control', :placeholder => '0.01'
15
- .form-group
16
- %label.control-label CALL/PUT?
17
- = f.select :direction, options_for_select( Ish::StockOption::DIRECTIONS.map{|d|[d,d]}, :selected => stock_option.direction )
18
- .form-group
19
- %label.control-label quantity:
20
- = f.number_field :quantity, :placeholder => 0
21
- .form-group
22
- = f.submit ">", :class => %w(btn blue)
@@ -1,11 +0,0 @@
1
-
2
- %h4 Stock Options Index
3
-
4
- %hr
5
- - @stock_options.each do |stock_option|
6
- = render 'form', :stock_option => stock_option
7
-
8
- %hr
9
- %h5 New
10
- = render 'form', :stock_option => @stock_option
11
-
@@ -1,28 +0,0 @@
1
-
2
- - if stock_watch.persisted?
3
- .float-left= button_to '[X]', stock_watch_path(stock_watch.id), method: :delete, data: { confirm: 'Are you sure?' }
4
-
5
-
6
- - url = stock_watches_path if !stock_watch.persisted?
7
- - url = stock_watch_path( stock_watch ) if stock_watch.persisted?
8
-
9
- = form_for stock_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 => stock_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 => stock_watch.profile ? stock_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 Price
22
- = f.select :direction, options_for_select( Warbler::StockWatch::DIRECTIONS.map{|d|[d,d]}, :selected => stock_watch.direction )
23
- .form-group
24
- %label.control-label $
25
- = f.number_field :price, :step => 0.01, :placeholder => "0.01"
26
- .form-group
27
- = f.submit ">", :class => %w(btn blue)
28
-
@@ -1,24 +0,0 @@
1
-
2
- %h4 Stock Watches
3
-
4
- - @stock_watches.each do |stock|
5
- %hr
6
- = render 'form', :stock_watch => stock
7
-
8
- %hr
9
- %h5 New
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
@@ -1,40 +0,0 @@
1
- !!!
2
- %html
3
- %head
4
- %title Ish Manager
5
- %link{ :rel => 'icon', :href => "/favicon_#{ENV['RAILS_ENV']}.gif" }
6
- %meta{ :name => :viewport, :content => 'width=device-width, initial-scale=1.0' }
7
- %meta{ :charset => 'UTF-8' }
8
- %meta{ :description => 'some description' }
9
- %script{ :src => "//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" }
10
- %script{ :src => "//cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.3/jquery.tinymce.min.js" }
11
- %script{ :src => "//cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.3/tinymce.min.js" }
12
- %script{ :src => "//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" }
13
- = stylesheet_link_tag "//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"
14
- = stylesheet_link_tag "//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", :media => 'all'
15
- = stylesheet_link_tag "//fonts.googleapis.com/icon?family=Material+Icons"
16
-
17
- = stylesheet_link_tag "ish_manager/materialize", media: "all"
18
- = stylesheet_link_tag "ish_manager/application", media: "all"
19
-
20
- = javascript_include_tag "ish_manager/application"
21
- = javascript_include_tag "ish_manager/materialize"
22
-
23
- = csrf_meta_tags
24
- %body{ class: [ params[:controller].gsub("ish_manager/",""), "#{params[:controller].gsub("ish_manager/","")}-#{params[:action]}", params[:action]] }
25
- .bg-white
26
- - role = current_user ? current_user.profile.role_name : ''
27
- = render :partial => "ish_manager/application/main_header_#{role}"
28
- .container
29
- .row
30
- .col.s12
31
- - if notice
32
- %p.notice= notice
33
- - if alert
34
- %p.alert= alert
35
- .container
36
- = yield
37
- = render 'ish_manager/application/main_footer'
38
- = render 'analytics' unless Rails.env.development?
39
- = render 'debug' if Rails.env.development?
40
-
@@ -1,57 +0,0 @@
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