ish_manager 0.1.8.59 → 0.1.8.60
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/ish_manager/application.css +12 -0
- data/app/controllers/ish_manager/ally_controller.rb +8 -0
- data/app/controllers/ish_manager/photos_controller.rb +3 -3
- data/app/controllers/ish_manager/stock_actions_controller.rb +60 -0
- data/app/controllers/ish_manager/stock_options_controller.rb +43 -0
- data/app/controllers/ish_manager/stock_watches_controller.rb +6 -6
- data/app/models/ish_manager/ability.rb +1 -1
- data/app/views/ish_manager/ally/home.haml +6 -0
- data/app/views/ish_manager/application/_main_header.haml +5 -1
- data/app/views/ish_manager/stock_actions/_form.haml +27 -0
- data/app/views/ish_manager/stock_actions/index.haml +13 -0
- data/app/views/ish_manager/stock_options/_form.haml +22 -0
- data/app/views/ish_manager/stock_options/index.haml +11 -0
- data/app/views/ish_manager/stock_watches/_form.haml +2 -2
- data/app/views/ish_manager/stock_watches/index.haml +1 -1
- data/config/routes.rb +3 -3
- data/lib/tasks/ish_manager_tasks.rake +16 -8
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19377ade825fddd2bc25dd1c70455449440617c1
|
4
|
+
data.tar.gz: 8c5656d7f405c96d4e066ac95ac969c52a65b7e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2222d95f13995024176f5ce8bb25fc1f57287bdd33d7119cfa7a04531461889300d83e70383a7284bc714e843a6ae2df0c99d9ca04fea0c719c0a2a588e746fc
|
7
|
+
data.tar.gz: 3a1f690799b3570346f1b8468477cf7ba664b0cbc6882d268493f14c0daa60e36cd9600dac280780c5c62c3122b02aae13d5b0fb197d0d5b504049c0014cb6c5
|
@@ -138,3 +138,15 @@ table.stock_watches td {
|
|
138
138
|
table.stock_watches .trashy {
|
139
139
|
background: #cecece;
|
140
140
|
}
|
141
|
+
|
142
|
+
.stock-option {
|
143
|
+
/* border: 1px solid red; */
|
144
|
+
border-radius: 5px;
|
145
|
+
display: inline-block;
|
146
|
+
padding: 5px;
|
147
|
+
box-shadow: 2px 2px 5px grey;
|
148
|
+
margin: 5px;
|
149
|
+
}
|
150
|
+
.stock-option:hover {
|
151
|
+
box-shadow: 3px 3px 5px grey;
|
152
|
+
}
|
@@ -43,13 +43,13 @@ class IshManager::PhotosController < IshManager::ApplicationController
|
|
43
43
|
@photo.gallery.touch
|
44
44
|
|
45
45
|
if @photo.save
|
46
|
-
j = {
|
46
|
+
j = {
|
47
|
+
:name => @photo.photo.original_filename,
|
47
48
|
:size => @photo.photo.size,
|
48
49
|
:url => @photo.photo.url( :large ),
|
49
50
|
:thumbnail_url => @photo.photo.url( :thumb ),
|
50
51
|
:delete_url => photo_path(@photo),
|
51
|
-
:delete_type => 'DELETE'
|
52
|
-
:name => @photo.name
|
52
|
+
:delete_type => 'DELETE'
|
53
53
|
}
|
54
54
|
render :json => [ j ]
|
55
55
|
else
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
class IshManager::StockActionsController < IshManager::ApplicationController
|
3
|
+
|
4
|
+
PERMITTED_PARAMS = [ :stock_watch, :is_active ]
|
5
|
+
|
6
|
+
def index
|
7
|
+
authorize! :index, Ish::StockAction
|
8
|
+
@profiles = IshModels::UserProfile.all
|
9
|
+
@stock_watches_list = Ish::StockWatch.all.map { |w| [w.to_s, w.id] }
|
10
|
+
@stock_options_list = Ish::StockOption.all.map { |o| [ o.to_s, o.id] }
|
11
|
+
@stock_actions = Ish::StockAction.all.includes( :profile )
|
12
|
+
@stock_action = Ish::StockAction.new
|
13
|
+
render 'index', :layout => 'ish_manager/application_no_materialize'
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@stock_action = Ish::StockAction.new params.require(:ish_stock_action).permit( PERMITTED_PARAMS )
|
18
|
+
@stock_action.profile = current_user.profile
|
19
|
+
authorize! :create, @stock_action
|
20
|
+
|
21
|
+
flag = true
|
22
|
+
if params[:ish_stock_action][:stock_options]
|
23
|
+
stock_options = Ish::StockOption.where( :id.in => params[:ish_stock_action][:stock_options] )
|
24
|
+
flag = stock_options.update_all( :stock_action_id => @stock_action.id )
|
25
|
+
end
|
26
|
+
if flag
|
27
|
+
flag = @stock_action.save
|
28
|
+
end
|
29
|
+
if flag
|
30
|
+
flash[:notice] = 'Created stock action.'
|
31
|
+
else
|
32
|
+
flash[:alert] = "Cannot create stock action: #{@stock_action.errors.messages}"
|
33
|
+
end
|
34
|
+
redirect_to :action => 'index'
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
@stock_action = Ish::StockAction.find params[:id]
|
39
|
+
authorize! :update, @stock_action
|
40
|
+
|
41
|
+
flag = true
|
42
|
+
if params[:ish_stock_action][:stock_options]
|
43
|
+
stock_options = Ish::StockOption.where( :id.in => params[:ish_stock_action][:stock_options] )
|
44
|
+
flag = stock_options.update_all( :stock_action_id => @stock_action.id )
|
45
|
+
end
|
46
|
+
if flag
|
47
|
+
flag = @stock_action.update_attributes params.require(:ish_stock_action).permit( PERMITTED_PARAMS )
|
48
|
+
end
|
49
|
+
if flag
|
50
|
+
flash[:notice] = 'Updated stock action.'
|
51
|
+
else
|
52
|
+
flash[:alert] = "Cannot update stock action: #{@stock_action.errors.messages}"
|
53
|
+
end
|
54
|
+
redirect_to :action => 'index'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
class IshManager::StockOptionsController < IshManager::ApplicationController
|
3
|
+
|
4
|
+
def index
|
5
|
+
authorize! :index, Ish::StockOption
|
6
|
+
@profiles = IshModels::UserProfile.all
|
7
|
+
@stock_options = Ish::StockOption.all.includes( :profile )
|
8
|
+
@stock_option = Ish::StockOption.new
|
9
|
+
render 'index', :layout => 'ish_manager/application_no_materialize'
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@stock_option = Ish::StockOption.new params[:ish_stock_option].permit!
|
14
|
+
@stock_option.profile = current_user.profile
|
15
|
+
authorize! :create, @stock_option
|
16
|
+
flag = @stock_option.save
|
17
|
+
|
18
|
+
byebug
|
19
|
+
|
20
|
+
if flag
|
21
|
+
flash[:notice] = 'Created stock option.'
|
22
|
+
else
|
23
|
+
flash[:alert] = "Cannot create stock option: #{@stock_option.errors.messages}"
|
24
|
+
end
|
25
|
+
redirect_to :action => 'index'
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
@stock_option = Ish::StockOption.find params[:id]
|
30
|
+
authorize! :update, @stock_option
|
31
|
+
flag = @stock_option.update_attributes params[:ish_stock_option].permit!
|
32
|
+
if flag
|
33
|
+
flash[:notice] = 'Updated stock option.'
|
34
|
+
else
|
35
|
+
flash[:alert] = "Cannot update stock option: #{@stock_option.errors.messages}"
|
36
|
+
end
|
37
|
+
redirect_to :action => 'index'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
@@ -2,15 +2,15 @@
|
|
2
2
|
class IshManager::StockWatchesController < IshManager::ApplicationController
|
3
3
|
|
4
4
|
def index
|
5
|
-
authorize! :index,
|
5
|
+
authorize! :index, Ish::StockWatch
|
6
6
|
@profiles = IshModels::UserProfile.all
|
7
|
-
@stock_watches =
|
8
|
-
@stock_watch =
|
7
|
+
@stock_watches = Ish::StockWatch.all.includes( :profile )
|
8
|
+
@stock_watch = Ish::StockWatch.new
|
9
9
|
render 'index', :layout => 'ish_manager/application_no_materialize'
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
@stock_watch =
|
13
|
+
@stock_watch = Ish::StockWatch.new params[:ish_stock_watch].permit!
|
14
14
|
authorize! :create, @stock_watch
|
15
15
|
flag = @stock_watch.save
|
16
16
|
if flag
|
@@ -22,9 +22,9 @@ class IshManager::StockWatchesController < IshManager::ApplicationController
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def update
|
25
|
-
@stock_watch =
|
25
|
+
@stock_watch = Ish::StockWatch.find params[:id]
|
26
26
|
authorize! :update, @stock_watch
|
27
|
-
flag = @stock_watch.update_attributes params[:
|
27
|
+
flag = @stock_watch.update_attributes params[:ish_stock_watch].permit!
|
28
28
|
if flag
|
29
29
|
flash[:notice] = 'Updated stock watch.'
|
30
30
|
else
|
@@ -25,7 +25,7 @@ class IshManager::Ability
|
|
25
25
|
can [ :show, :edit, :update, :create_newsitem, :new_feature, :create_feature ], ::Site do |site|
|
26
26
|
!site.is_private && !site.is_trash
|
27
27
|
end
|
28
|
-
can [ :manage ],
|
28
|
+
can [ :manage ], Ish::StockWatch
|
29
29
|
|
30
30
|
# can [ :new_feature, :create_feature ], ::Tag
|
31
31
|
|
@@ -14,6 +14,10 @@
|
|
14
14
|
%li{ :class => params[:controller] == 'ish_manager/tags' ? 'active' : '' }= link_to 'Tags', tags_path
|
15
15
|
%li{ :class => params[:controller] == 'ish_manager/venues' ? 'active' : '' }= link_to 'Venues', venues_path
|
16
16
|
%li{ :class => params[:controller] == 'ish_manager/videos' ? 'active' : '' }= link_to 'Videos', videos_path
|
17
|
-
|
17
|
+
%ul.nav.nav-pills
|
18
|
+
%li{ :class => params[:controller] == 'ish_manager/ally' ? 'active' : '' }= link_to 'Ally', ally_root_path
|
19
|
+
%li{ :class => params[:controller] == 'ish_manager/stock_actions' ? 'active' : '' }= link_to 'Stock Actions', stock_actions_path
|
20
|
+
%li{ :class => params[:controller] == 'ish_manager/stock_options' ? 'active' : '' }= link_to 'Stock Options', stock_options_path
|
21
|
+
%li{ :class => params[:controller] == 'ish_manager/stock_watches' ? 'active' : '' }= link_to 'Stock Watches', stock_watches_path
|
18
22
|
%hr
|
19
23
|
|
@@ -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)
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
= form_for stock_watch, :url => url, :html => { :class => 'form-inline well' } do |f|
|
6
6
|
.form-group
|
7
|
-
= f.select :action, options_for_select(
|
7
|
+
= f.select :action, options_for_select( Ish::StockWatch::ACTIONS.map{|a|[a,a]}, :selected => stock_watch.action )
|
8
8
|
.form-group
|
9
9
|
= f.select :profile, options_for_select( [[nil,nil]]+@profiles.map{|p|[p.email,p.id]}, :selected => stock_watch.profile ? stock_watch.profile.id : nil )
|
10
10
|
.form-group
|
@@ -12,7 +12,7 @@
|
|
12
12
|
= f.text_field :ticker, :class => 'form-control', :placeholder => 'ticker'
|
13
13
|
.form-group
|
14
14
|
%label.control-label Price
|
15
|
-
= f.select :direction, options_for_select(
|
15
|
+
= f.select :direction, options_for_select( Ish::StockWatch::DIRECTIONS.map{|d|[d,d]}, :selected => stock_watch.direction )
|
16
16
|
.form-group
|
17
17
|
%label.control-label $
|
18
18
|
= f.number_field :price, :step => 0.01, :placeholder => "0.01"
|
data/config/routes.rb
CHANGED
@@ -33,10 +33,10 @@ IshManager::Engine.routes.draw do
|
|
33
33
|
resources :reports
|
34
34
|
end
|
35
35
|
|
36
|
+
get 'ally', :to => 'ally#home', :as => :ally_root
|
37
|
+
resources :stock_actions
|
38
|
+
resources :stock_options
|
36
39
|
resources :stock_watches
|
37
|
-
# scope :ally, :as => 'ally' do
|
38
|
-
# root :to => 'ally#home'
|
39
|
-
# end
|
40
40
|
|
41
41
|
resources :tags
|
42
42
|
|
@@ -18,25 +18,33 @@ namespace :ish_manager do
|
|
18
18
|
puts 'OK'
|
19
19
|
end
|
20
20
|
|
21
|
-
desc 'watch the stocks'
|
21
|
+
desc 'watch the stocks, and trigger actions'
|
22
22
|
task :watch_stocks => :environment do
|
23
23
|
while true
|
24
|
-
stocks =
|
24
|
+
stocks = Ish::StockWatch.where( :notification_type => :EMAIL )
|
25
25
|
puts! stocks.map(&:ticker), "Watching these stocks on #{Time.now}"
|
26
26
|
stocks.each do |stock|
|
27
27
|
begin
|
28
28
|
Timeout::timeout( 10 ) do
|
29
29
|
r = HTTParty.get "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=#{stock.ticker}&interval=1min&apikey=X1C5GGH5MZSXMF3O"
|
30
|
-
r = JSON.parse( r.body )['Time Series (1min)']
|
31
|
-
r = r[r.keys.first]['4. close'].to_f
|
32
|
-
if stock.direction == :ABOVE && r >= stock.price ||
|
33
|
-
stock.direction == :BELOW && r <= stock.price
|
34
|
-
IshManager::ApplicationMailer.stock_alert( stock ).deliver
|
35
|
-
end
|
36
30
|
end
|
37
31
|
rescue Exception => e
|
38
32
|
puts! e, 'e in :watch_stocks'
|
39
33
|
end
|
34
|
+
r = JSON.parse( r.body )['Time Series (1min)']
|
35
|
+
r = r[r.keys.first]['4. close'].to_f
|
36
|
+
if stock.direction == :ABOVE && r >= stock.price ||
|
37
|
+
stock.direction == :BELOW && r <= stock.price
|
38
|
+
IshManager::ApplicationMailer.stock_alert( stock ).deliver
|
39
|
+
|
40
|
+
=begin
|
41
|
+
# actions
|
42
|
+
stock.stock_actions.where( :is_active => true ).each do |action|
|
43
|
+
# @TODO: actions
|
44
|
+
end
|
45
|
+
=end
|
46
|
+
|
47
|
+
end
|
40
48
|
end
|
41
49
|
sleep 60
|
42
50
|
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.
|
4
|
+
version: 0.1.8.60
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mongoid-autoinc
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '6.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '6.0'
|
111
125
|
description: Description of IshManager.
|
112
126
|
email:
|
113
127
|
- piousbox@gmail.com
|
@@ -138,6 +152,7 @@ files:
|
|
138
152
|
- app/assets/stylesheets/ish_manager/materialize.css
|
139
153
|
- app/assets/stylesheets/ish_manager/trash/bootstrap.min.css
|
140
154
|
- app/assets/stylesheets/ish_manager/trash/bootstrap.min.css.map
|
155
|
+
- app/controllers/ish_manager/ally_controller.rb
|
141
156
|
- app/controllers/ish_manager/application_controller.rb
|
142
157
|
- app/controllers/ish_manager/cities_controller.rb
|
143
158
|
- app/controllers/ish_manager/features_controller.rb
|
@@ -147,6 +162,8 @@ files:
|
|
147
162
|
- app/controllers/ish_manager/photos_controller.rb
|
148
163
|
- app/controllers/ish_manager/reports_controller.rb
|
149
164
|
- app/controllers/ish_manager/sites_controller.rb
|
165
|
+
- app/controllers/ish_manager/stock_actions_controller.rb
|
166
|
+
- app/controllers/ish_manager/stock_options_controller.rb
|
150
167
|
- app/controllers/ish_manager/stock_watches_controller.rb
|
151
168
|
- app/controllers/ish_manager/tags_controller.rb
|
152
169
|
- app/controllers/ish_manager/user_profiles_controller.rb
|
@@ -162,6 +179,7 @@ files:
|
|
162
179
|
- app/models/ish_manager/ability.rb
|
163
180
|
- app/models/ish_manager/ability.rb~
|
164
181
|
- app/models/ish_manager/application_record.rb
|
182
|
+
- app/views/ish_manager/ally/home.haml
|
165
183
|
- app/views/ish_manager/application/_form_errors.haml
|
166
184
|
- app/views/ish_manager/application/_main_footer.haml
|
167
185
|
- app/views/ish_manager/application/_main_header.haml
|
@@ -256,6 +274,10 @@ files:
|
|
256
274
|
- app/views/ish_manager/sites/index.haml
|
257
275
|
- app/views/ish_manager/sites/new.haml
|
258
276
|
- app/views/ish_manager/sites/show.haml
|
277
|
+
- app/views/ish_manager/stock_actions/_form.haml
|
278
|
+
- app/views/ish_manager/stock_actions/index.haml
|
279
|
+
- app/views/ish_manager/stock_options/_form.haml
|
280
|
+
- app/views/ish_manager/stock_options/index.haml
|
259
281
|
- app/views/ish_manager/stock_watches/_form.haml
|
260
282
|
- app/views/ish_manager/stock_watches/index.haml
|
261
283
|
- app/views/ish_manager/tags/_features.haml
|