ish_manager 0.1.8.280 → 0.1.8.287
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ish_manager/option_watches_controller.rb +60 -0
- data/app/controllers/ish_manager/stock_watches_controller.rb +4 -0
- data/app/mailers/ish_manager/application_mailer.rb +4 -1
- data/app/models/ish_manager/ability.rb +3 -1
- data/app/views/ish_manager/application_mailer/option_alert.html.erb +9 -0
- data/app/views/ish_manager/option_watches/_form.haml +37 -0
- data/app/views/ish_manager/stock_watches/index.haml +16 -2
- data/app/views/ish_manager/trash/option_watches-trash/_form.haml +37 -0
- data/app/views/ish_manager/trash/stock_actions/_form.haml +27 -0
- data/app/views/ish_manager/trash/stock_actions/index.haml +13 -0
- data/app/views/ish_manager/trash/stock_options/_form.haml +22 -0
- data/app/views/ish_manager/trash/stock_options/index.haml +11 -0
- data/app/views/ish_manager/trash/stock_watches/_form.haml +28 -0
- data/app/views/ish_manager/trash/stock_watches/index.haml +24 -0
- data/config/routes.rb +1 -0
- data/lib/tasks/ish_manager_tasks.rake +1 -8
- data/lib/tasks/warbler_tasks.rake +57 -0
- data/lib/tasks/warbler_tasks.rake-trash +69 -0
- metadata +61 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 237abaf7bf4203c9e2a2f4f83b44f191f28083cc8d76a97683643446d798d14c
|
4
|
+
data.tar.gz: 3a670cfeb3f49711419734dd1d28f3b241326607550d5231ad9edde1d54b560c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4f055b9d0af25a25a50e4d9ac256e1a350a470fdcde56bd2c923108a26446c00c8ecf0062f3131a49a56f3deb5cd5a249ee2d9abdf1d3872a5bde268ce799a
|
7
|
+
data.tar.gz: 21d8017a28f7a23d24c0163ff4a8ef30acacb75797ff49a40475e75948ff9c3998bc25b1f51feef0b9b10d9448c1ca1a97c2c294824a3f097dbabd03ec0867c5
|
@@ -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
|
-
|
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
|
@@ -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
|
+
|
@@ -0,0 +1,27 @@
|
|
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)
|
@@ -0,0 +1,13 @@
|
|
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
|
+
|
@@ -0,0 +1,22 @@
|
|
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)
|
@@ -0,0 +1,28 @@
|
|
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
|
+
|
@@ -0,0 +1,24 @@
|
|
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
|
data/config/routes.rb
CHANGED
@@ -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, '
|
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
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
def puts! a, b=''
|
3
|
+
puts "+++ +++ #{b}:"
|
4
|
+
pp a
|
5
|
+
end
|
6
|
+
|
7
|
+
namespace :warbler do
|
8
|
+
|
9
|
+
desc 'test placing orders for stock' do
|
10
|
+
task place_order_stock: :environment do
|
11
|
+
opts = {
|
12
|
+
"instruction": "BUY",
|
13
|
+
"price": "1.10",
|
14
|
+
"quantity": 1,
|
15
|
+
"symbol": "BAC",
|
16
|
+
}
|
17
|
+
out = Warbler::Ameritrade::Api.place_stock_limit_order opts
|
18
|
+
puts! out, 'out'
|
19
|
+
end
|
20
|
+
|
21
|
+
## @TODO: this is still in ish_manager namespace, need to actually move it here.
|
22
|
+
desc 'watch the stocks, and trigger actions - not alphavantage, tda now. 2021-08-08'
|
23
|
+
task watch_stocks: :environment do
|
24
|
+
while true
|
25
|
+
stocks = Warbler::StockWatch.where( notification_type: :EMAIL )
|
26
|
+
stocks.each do |stock|
|
27
|
+
begin
|
28
|
+
Timeout::timeout( 10 ) do
|
29
|
+
out = Warbler::Ameritrade::Api.get_quote({ symbol: stock.ticker })
|
30
|
+
r = out[:lastPrice]
|
31
|
+
if stock.direction == :ABOVE && r >= stock.price ||
|
32
|
+
stock.direction == :BELOW && r <= stock.price
|
33
|
+
IshManager::ApplicationMailer.stock_alert( stock ).deliver
|
34
|
+
end
|
35
|
+
end
|
36
|
+
rescue Exception => e
|
37
|
+
puts! e, 'Error in ish_manager:watch_stocks :'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
print '.'
|
41
|
+
sleep Warbler::StockWatch::SLEEP_TIME_SECONDS
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'watch option: contractType=PUT|CALL strike symbol date=yyyy-mm-dd'
|
46
|
+
task watch_options: :environment do
|
47
|
+
while true
|
48
|
+
option_watches = Warbler::OptionWatch.where( notification_type: :EMAIL )
|
49
|
+
option_watches.each do |option|
|
50
|
+
begin
|
51
|
+
Timeout::timeout( 10 ) do
|
52
|
+
## opts = { contractType: 'PUT', strike: 355.0, symbol: 'NVDA', date: '2022-02-18' }
|
53
|
+
out = Warbler::Ameritrade::Api.get_option( option )
|
54
|
+
r = out[:last]
|
55
|
+
if option.direction == :ABOVE && r >= option.price ||
|
56
|
+
option.direction == :BELOW && r <= option.price
|
57
|
+
IshManager::ApplicationMailer.option_alert( option ).deliver
|
58
|
+
end
|
59
|
+
end
|
60
|
+
rescue Exception => e
|
61
|
+
puts! e, 'Error in ish_manager:watch_options :'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
print '.'
|
65
|
+
sleep Warbler::OptionWatch::SLEEP_TIME_SECONDS
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.287
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: cancancan
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: devise
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: haml
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,63 +53,91 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: kaminari-mongoid
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: kaminari-actionview
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: mongoid
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 7.3.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 7.3.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: mongoid_paranoia
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mongoid-paperclip
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mongoid-autoinc
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
129
|
- - "~>"
|
102
130
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
131
|
+
version: '6.0'
|
104
132
|
type: :runtime
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
138
|
+
version: '6.0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
140
|
+
name: rails
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
143
|
- - "~>"
|
@@ -202,6 +230,7 @@ files:
|
|
202
230
|
- app/controllers/ish_manager/maps_controller.rb
|
203
231
|
- app/controllers/ish_manager/markers_controller.rb
|
204
232
|
- app/controllers/ish_manager/newsitems_controller.rb
|
233
|
+
- app/controllers/ish_manager/option_watches_controller.rb
|
205
234
|
- app/controllers/ish_manager/orders_controller.rb
|
206
235
|
- app/controllers/ish_manager/payments_controller.rb
|
207
236
|
- app/controllers/ish_manager/photos_controller.rb
|
@@ -234,6 +263,7 @@ files:
|
|
234
263
|
- app/views/ish_manager/application/_search.haml
|
235
264
|
- app/views/ish_manager/application/home.haml
|
236
265
|
- app/views/ish_manager/application_mailer/condor_followup_alerb.html.erb
|
266
|
+
- app/views/ish_manager/application_mailer/option_alert.html.erb
|
237
267
|
- app/views/ish_manager/application_mailer/shared_galleries.html.erb
|
238
268
|
- app/views/ish_manager/application_mailer/stock_alert.html.erb
|
239
269
|
- app/views/ish_manager/application_mailer/welcome.html.erb
|
@@ -305,6 +335,7 @@ files:
|
|
305
335
|
- app/views/ish_manager/newsitems/edit.haml
|
306
336
|
- app/views/ish_manager/newsitems/index.haml
|
307
337
|
- app/views/ish_manager/newsitems/new.haml
|
338
|
+
- app/views/ish_manager/option_watches/_form.haml
|
308
339
|
- app/views/ish_manager/payments/index.haml
|
309
340
|
- app/views/ish_manager/photos/_meta.haml
|
310
341
|
- app/views/ish_manager/photos/_meta_manager.haml
|
@@ -342,6 +373,13 @@ files:
|
|
342
373
|
- app/views/ish_manager/tags/index.haml
|
343
374
|
- app/views/ish_manager/tags/new.haml
|
344
375
|
- app/views/ish_manager/tags/show.haml
|
376
|
+
- app/views/ish_manager/trash/option_watches-trash/_form.haml
|
377
|
+
- app/views/ish_manager/trash/stock_actions/_form.haml
|
378
|
+
- app/views/ish_manager/trash/stock_actions/index.haml
|
379
|
+
- app/views/ish_manager/trash/stock_options/_form.haml
|
380
|
+
- app/views/ish_manager/trash/stock_options/index.haml
|
381
|
+
- app/views/ish_manager/trash/stock_watches/_form.haml
|
382
|
+
- app/views/ish_manager/trash/stock_watches/index.haml
|
345
383
|
- app/views/ish_manager/user_profiles/_form.haml
|
346
384
|
- app/views/ish_manager/user_profiles/edit.haml
|
347
385
|
- app/views/ish_manager/user_profiles/index.haml
|
@@ -380,6 +418,8 @@ files:
|
|
380
418
|
- lib/systemd/system/watch_stocks.service
|
381
419
|
- lib/tasks/ish_manager_tasks.rake
|
382
420
|
- lib/tasks/migrate.rake
|
421
|
+
- lib/tasks/warbler_tasks.rake
|
422
|
+
- lib/tasks/warbler_tasks.rake-trash
|
383
423
|
homepage: http://wasya.co
|
384
424
|
licenses:
|
385
425
|
- MIT
|