iron_warbler 2.0.7.43 → 2.0.7.45
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/iron_warbler/utils.scss +9 -9
- data/app/controllers/iro/positions_controller.rb +1 -0
- data/app/controllers/iro/purses_controller.rb +3 -1
- data/app/controllers/iro/strategies_controller.rb +8 -3
- data/app/views/iro/positions/_form.haml +1 -1
- data/app/views/iro/positions/{_gameui_long_debit_call_spread.haml-trash → _gameui_spread.haml} +9 -8
- data/app/views/iro/positions/_header_spread.haml +12 -0
- data/app/views/iro/positions/_new.haml +4 -0
- data/app/views/iro/positions/done/_gameui_short_debit_put_spread.haml +1 -0
- data/app/views/iro/positions/done/_header_short_debit_put_spread.haml +1 -0
- data/app/views/iro/purses/_form.haml +3 -3
- data/app/views/iro/purses/index.haml +3 -2
- data/app/views/iro/strategies/_form_spread.haml +69 -0
- data/app/views/iro/strategies/{_form.haml → _form_wheel.haml} +12 -12
- data/app/views/iro/strategies/_header.haml +2 -1
- data/app/views/iro/strategies/_table.haml +3 -5
- data/app/views/iro/strategies/edit.haml +1 -1
- data/app/views/iro/strategies/index.haml +2 -1
- data/app/views/iro/strategies/new.haml +1 -1
- data/app/views/layouts/iro/application.haml +1 -1
- data/config/routes.rb +2 -0
- data/lib/iron_warbler.rb +2 -1
- data/lib/tasks/iro_tasks.rake +6 -0
- metadata +20 -30
- data/app/models/iro/alert.rb +0 -63
- data/app/models/iro/datapoint.rb +0 -187
- data/app/models/iro/date.rb +0 -10
- data/app/models/iro/option.rb +0 -151
- data/app/models/iro/option_black_scholes.rb +0 -149
- data/app/models/iro/position.rb +0 -299
- data/app/models/iro/priceitem.rb +0 -93
- data/app/models/iro/purse.rb +0 -72
- data/app/models/iro/stock.rb +0 -134
- data/app/models/iro/strategy.rb +0 -264
- data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +0 -1
- data/app/views/iro/positions/_gameui_short_debit_put_spread.haml-trash +0 -40
- data/app/views/iro/positions/_header_short_debit_put_spread.haml +0 -1
- data/app/views/iro/positions/roll.haml-trash +0 -42
- /data/app/views/iro/positions/{_gameui_covered_call.haml-bk → done/_gameui_covered_call.haml-bk} +0 -0
- /data/app/views/iro/positions/{_gameui_long_credit_put_spread.haml → done/_gameui_long_credit_put_spread.haml} +0 -0
- /data/app/views/iro/positions/{_gameui_long_debit_call_spread.haml → done/_gameui_long_debit_call_spread.haml} +0 -0
- /data/app/views/iro/positions/{_gameui_short_credit_call_spread.haml → done/_gameui_short_credit_call_spread.haml} +0 -0
- /data/app/views/iro/positions/{_header_long_credit_put_spread.haml → done/_header_long_credit_put_spread.haml} +0 -0
- /data/app/views/iro/positions/{_header_long_debit_call_spread.haml → done/_header_long_debit_call_spread.haml} +0 -0
- /data/app/views/iro/positions/{_header_short_credit_call_spread.haml → done/_header_short_credit_call_spread.haml} +0 -0
- /data/app/views/iro/positions/{roll-cc.haml-bk → done/roll-cc.haml-bk} +0 -0
- /data/app/views/iro/purses/{gameui.haml-bk → done/gameui.haml-bk} +0 -0
- /data/app/views/iro/purses/{gameui.haml-bk2 → done/gameui.haml-bk2} +0 -0
- /data/app/views/iro/stocks/{_grid_is_long.haml → _grid_long.haml} +0 -0
- /data/app/views/iro/stocks/{_grid_is_short.haml → _grid_short.haml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b6eb4da8444c595a5279fbe6242f4bf503313f4e7d01bb0b844a1e45db0caa5
|
4
|
+
data.tar.gz: 7b14b6fd526ed9016b6264470e170442ec852179f175c942e8b437f1af9f103f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ef0a066c968de0c6d4c7285888e09306bebd3c2c09c9153c4e746e4d5a322b7f8d873de39d9f4b753bf605d8f29ff5f5128009f5be21427c6f1e40ca698b55
|
7
|
+
data.tar.gz: 6edb134dd367a3983abfb675032659b25b905b180e7bacee1cf53597d1a120731b236449eb2077e4b7421dbf74cf8870ddbff9b08bc57a91bc8dc6fd834d2a07
|
@@ -5,28 +5,28 @@
|
|
5
5
|
// // content: '[LONG]';
|
6
6
|
// }
|
7
7
|
.long-or-short-item,
|
8
|
-
.long-or-short-container .
|
9
|
-
.long-or-short-container .
|
8
|
+
.long-or-short-container .is-long,
|
9
|
+
.long-or-short-container .is-short {
|
10
10
|
display: flex;
|
11
11
|
flex-direction: column;
|
12
12
|
}
|
13
13
|
|
14
|
-
.long-or-short-container .
|
15
|
-
.
|
14
|
+
.long-or-short-container .is-long,
|
15
|
+
.is-long .long-or-short-item {
|
16
16
|
border-left: 3px solid var(--iro-color-long);
|
17
17
|
padding-left: 5px;
|
18
18
|
}
|
19
|
-
.long-or-short-container .
|
20
|
-
.
|
19
|
+
.long-or-short-container .is-short,
|
20
|
+
.is-short .long-or-short-item {
|
21
21
|
border-left: 3px solid var(--iro-color-short);
|
22
22
|
padding-left: 5px;
|
23
23
|
}
|
24
24
|
|
25
|
-
.
|
25
|
+
.is-short .long-or-short-item::before {
|
26
26
|
// content: '[SHORT]';
|
27
27
|
}
|
28
|
-
.
|
29
|
-
.long-or-short-container .
|
28
|
+
.is-short .long-or-short-item,
|
29
|
+
.long-or-short-container .is-short {
|
30
30
|
flex-direction: column-reverse;
|
31
31
|
}
|
32
32
|
|
@@ -38,6 +38,7 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
38
38
|
|
39
39
|
def new
|
40
40
|
strategy = Iro::Strategy.find params[:position][:strategy_id]
|
41
|
+
|
41
42
|
@position = strategy.next_position
|
42
43
|
@position ||= Iro::Position.new( params[:position].permit!.merge({
|
43
44
|
status: Iro::Position::STATUS_PROPOSED,
|
@@ -36,7 +36,9 @@ class Iro::PursesController < Iro::ApplicationController
|
|
36
36
|
authorize! :show, @purse
|
37
37
|
|
38
38
|
|
39
|
-
@positions = @purse.positions
|
39
|
+
@positions = @purse.positions(
|
40
|
+
).where( status: 'active'
|
41
|
+
).includes( :strategy
|
40
42
|
).order( expires_on: :asc, ticker: :desc, long_or_short: :asc, inner_strike: :asc )
|
41
43
|
|
42
44
|
|
@@ -7,13 +7,18 @@ class Iro::StrategiesController < Iro::ApplicationController
|
|
7
7
|
@strategy = Iro::Strategy.new params[:strategy].permit!
|
8
8
|
authorize! :create, @strategy
|
9
9
|
|
10
|
+
if @strategy[:kind] == Iro::Strategy::KIND_WHEEL
|
11
|
+
@strategy.long_or_short = Iro::Strategy::LONG
|
12
|
+
@strategy.credit_or_debit = Iro::Strategy::DEBIT
|
13
|
+
end
|
14
|
+
|
10
15
|
if @strategy.save
|
11
16
|
flash_notice @strategy
|
17
|
+
redirect_to action: :index
|
12
18
|
else
|
13
19
|
flash_alert @strategy
|
20
|
+
render action: 'new'
|
14
21
|
end
|
15
|
-
|
16
|
-
redirect_to action: :index
|
17
22
|
end
|
18
23
|
|
19
24
|
def destroy
|
@@ -37,7 +42,7 @@ class Iro::StrategiesController < Iro::ApplicationController
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def new
|
40
|
-
@strategy = Iro::Strategy.new
|
45
|
+
@strategy = Iro::Strategy.new({ kind: params[:kind] })
|
41
46
|
authorize! :new, @posision
|
42
47
|
end
|
43
48
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
- long_or_short = position.long_or_short || position.strategy&.long_or_short || params[:long_or_short]
|
3
3
|
|
4
|
-
.positions--form{ class:
|
4
|
+
.positions--form{ class: "is-#{long_or_short}" }
|
5
5
|
= form_for position do |f|
|
6
6
|
.actions
|
7
7
|
= f.submit
|
data/app/views/iro/positions/{_gameui_long_debit_call_spread.haml-trash → _gameui_spread.haml}
RENAMED
@@ -1,17 +1,18 @@
|
|
1
1
|
|
2
|
-
-##
|
3
|
-
-## same for long and short debit spreads
|
4
|
-
-##
|
5
|
-
|
6
2
|
- pos = position
|
7
3
|
- stock = pos.stock
|
8
4
|
- nearest_strike = stock.last.round
|
9
5
|
- u = pos.purse.unit # pixels per dollar
|
10
6
|
|
7
|
+
-#
|
8
|
+
-# 2024-07-30 I have not verified any of this - copied from long_debit_call_spread.
|
9
|
+
-#
|
10
|
+
|
11
11
|
.collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
|
12
12
|
[<>]
|
13
13
|
.maxwidth= render "/iro/positions/header", pos: pos
|
14
14
|
.a
|
15
|
+
- puts! pos, 'pos'
|
15
16
|
= render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
|
16
17
|
.StockCoordinatesW
|
17
18
|
.StockCoordinates{ style: "height: #{pos.q() *pos.purse.height}px " }
|
@@ -21,20 +22,20 @@
|
|
21
22
|
.label Last: #{pp_amount stock.last}
|
22
23
|
.c
|
23
24
|
|
24
|
-
- left = "#{ ( pos.outer.strike - stock.last ) *
|
25
|
-
- width = "#{ ( pos.inner.strike - pos.outer.strike ) *
|
25
|
+
- left = "#{ ( pos.outer.strike - stock.last ).abs() *-1*u}px"
|
26
|
+
- width = "#{ ( pos.inner.strike - pos.outer.strike ).abs() *u}px"
|
26
27
|
.PositionW{ class: pos.strategy.kind, style: "left: #{left}; width: #{width}; " }
|
27
28
|
.Position
|
28
29
|
.MaxGain{ style: "width: #{pos.max_gain * u}px" }
|
29
30
|
.RollGuide
|
30
31
|
|
31
32
|
- if pos.net_amount >= 0
|
32
|
-
.Net.NetPositive{ style: "width: #{ (pos.net_amount
|
33
|
+
.Net.NetPositive{ style: "width: #{ (pos.net_amount) * u }px; right: 0" }
|
33
34
|
.label
|
34
35
|
net
|
35
36
|
= pp_amount pos.net_amount
|
36
37
|
- else
|
37
|
-
.Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount
|
38
|
+
.Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount) * u }px; left: 100%" }
|
38
39
|
.label
|
39
40
|
net
|
40
41
|
= pp_amount pos.net_amount
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
- collapse_key ||= pos.id
|
3
|
+
%i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{collapse_key}" }
|
4
|
+
.maxwidth
|
5
|
+
%ul.m-0.p-0
|
6
|
+
- if !pos.persisted?
|
7
|
+
%li <b>expires_on:</b> #{pos.expires_on}
|
8
|
+
%li <b>inner_strike:</b> #{pp_amount pos.inner_strike}
|
9
|
+
%li <b>next_gain_loss_amount:</b> #{pp_amount pos.next_gain_loss_amount}
|
10
|
+
|
11
|
+
%li <b>begin_inner_price:</b> #{pp_amount pos.inner.begin_price}
|
12
|
+
%li <b>Net:</b> #{pp_amount pos.net_amount} <i>#{pp_percent pos.net_percent}</i>
|
@@ -0,0 +1 @@
|
|
1
|
+
app/views/iro/positions/done/_gameui_long_debit_call_spread.haml
|
@@ -0,0 +1 @@
|
|
1
|
+
app/views/iro/positions/done/_header_long_debit_call_spread.haml
|
@@ -2,9 +2,9 @@
|
|
2
2
|
.iro-purses--form
|
3
3
|
= form_for purse do |f|
|
4
4
|
.flex-row
|
5
|
-
.field
|
6
|
-
|
7
|
-
|
5
|
+
-# .field
|
6
|
+
-# %label stock
|
7
|
+
-# = f.select :stock_id, options_for_select( @stocks_list, selected: purse.stock_id )
|
8
8
|
|
9
9
|
.field
|
10
10
|
%label Slug
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
.strategies--form
|
3
|
+
= form_for strategy do |f|
|
4
|
+
.actions
|
5
|
+
= f.submit
|
6
|
+
|
7
|
+
.row
|
8
|
+
.col-md-6
|
9
|
+
.field
|
10
|
+
%label Kind:
|
11
|
+
= strategy.kind
|
12
|
+
= hidden_field_tag 'strategy[kind]', params[:kind] if params[:kind]
|
13
|
+
.field
|
14
|
+
%label stock
|
15
|
+
= f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
|
16
|
+
.field
|
17
|
+
%label long or short?
|
18
|
+
= f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
|
19
|
+
.field
|
20
|
+
%label credit or debit?
|
21
|
+
= f.select :credit_or_debit, options_for_select([nil, Iro::Strategy::CREDIT, Iro::Strategy::DEBIT], selected: strategy.credit_or_debit)
|
22
|
+
.field
|
23
|
+
%label call or put?
|
24
|
+
.comment This is selected automatically
|
25
|
+
-# = f.select :call_or_put, options_for_select([nil, 'CALL', 'PUT'], selected: strategy.credit_or_debit)
|
26
|
+
|
27
|
+
-# .col-md-6
|
28
|
+
-# .field
|
29
|
+
-# %label slug
|
30
|
+
-# = f.text_field :slug
|
31
|
+
%hr
|
32
|
+
|
33
|
+
|
34
|
+
.field
|
35
|
+
%label Threshold Buffer dollars above water
|
36
|
+
= f.number_field :threshold_buffer_above_water, placeholder: "0.49", step: 0.01
|
37
|
+
.field
|
38
|
+
= f.label :threshold_dte
|
39
|
+
= f.number_field :threshold_dte, placeholder: "1"
|
40
|
+
-# .field
|
41
|
+
-# = f.label :next_max_outer_delta
|
42
|
+
-# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
|
43
|
+
.field
|
44
|
+
= f.label :threshold_delta
|
45
|
+
= f.number_field :threshold_delta, placeholder: "0.14", step: 0.001
|
46
|
+
.field
|
47
|
+
= f.label :threshold_netp
|
48
|
+
= f.number_field :threshold_netp, placeholder: "0.69", step: 0.001
|
49
|
+
|
50
|
+
%hr
|
51
|
+
|
52
|
+
.field
|
53
|
+
= f.label :next_inner_delta
|
54
|
+
= f.number_field :next_inner_delta, placeholder: "0.25", step: 0.001
|
55
|
+
.field
|
56
|
+
= f.label :next_inner_strike
|
57
|
+
= f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
|
58
|
+
.comment Literally the min (max) dollar amount of next strike
|
59
|
+
.field
|
60
|
+
= f.label :next_spread_amount
|
61
|
+
= f.number_field :next_spread_amount, placeholder: "20", step: 0.1
|
62
|
+
.field
|
63
|
+
%label next buffer dollars above water
|
64
|
+
= f.number_field :next_buffer_above_water, placeholder: "80", step: 0.01
|
65
|
+
|
66
|
+
.actions
|
67
|
+
= f.submit
|
68
|
+
|
69
|
+
|
@@ -7,19 +7,21 @@
|
|
7
7
|
.row
|
8
8
|
.col-md-6
|
9
9
|
.field
|
10
|
-
%label Kind
|
11
|
-
=
|
12
|
-
|
13
|
-
%label long or short?
|
14
|
-
= f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
|
10
|
+
%label Kind:
|
11
|
+
= strategy.kind
|
12
|
+
= hidden_field_tag 'strategy[kind]', params[:kind]
|
15
13
|
.field
|
16
14
|
%label stock
|
17
15
|
= f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
|
18
|
-
|
19
|
-
.col-md-6
|
20
16
|
.field
|
21
|
-
%label
|
22
|
-
|
17
|
+
%label long or short?
|
18
|
+
Automatically long
|
19
|
+
.field
|
20
|
+
%label credit or debit?
|
21
|
+
Debit
|
22
|
+
.field
|
23
|
+
%label call or put?
|
24
|
+
Covered call
|
23
25
|
%hr
|
24
26
|
|
25
27
|
|
@@ -47,9 +49,7 @@
|
|
47
49
|
.field
|
48
50
|
= f.label :next_inner_strike
|
49
51
|
= f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
|
50
|
-
|
51
|
-
= f.label :next_spread_amount
|
52
|
-
= f.number_field :next_spread_amount, placeholder: "20", step: 0.1
|
52
|
+
.comment Literally the min (max) dollar amount of next strike
|
53
53
|
.field
|
54
54
|
%label next buffer dollars above water
|
55
55
|
= f.number_field :next_buffer_above_water, placeholder: "80", step: 0.01
|
@@ -10,7 +10,7 @@
|
|
10
10
|
%th kind
|
11
11
|
%th slug
|
12
12
|
%th stock
|
13
|
-
%th long or short
|
13
|
+
-# %th long or short
|
14
14
|
%th next_inner_delta
|
15
15
|
%th.actions
|
16
16
|
%tbody
|
@@ -22,10 +22,8 @@
|
|
22
22
|
= button_to 'x', strategy_path(sss), method: :delete, data: { confirm: 'Are you sure?' }
|
23
23
|
%td= sss.kind
|
24
24
|
%td= link_to sss.slug, strategy_path(sss)
|
25
|
-
%td.stock
|
26
|
-
|
27
|
-
%td.long-or-short
|
28
|
-
= sss.long_or_short
|
25
|
+
%td.stock= sss.stock
|
26
|
+
-# %td.long-or-short= sss.long_or_short
|
29
27
|
%td= sss.next_inner_delta
|
30
28
|
%td
|
31
29
|
= form_tag propose_position_path do
|
data/config/routes.rb
CHANGED
@@ -31,6 +31,8 @@ Iro::Engine.routes.draw do
|
|
31
31
|
get 'stocks/sync', to: 'stocks#sync', as: :sync_stocks
|
32
32
|
resources :stocks
|
33
33
|
|
34
|
+
get 'strategies/new-spread', to: 'strategies#new', as: :new_spread_strategy, defaults: { kind: 'spread' }
|
35
|
+
get 'strategies/new-wheel', to: 'strategies#new', as: :new_wheel_strategy, defaults: { kind: 'wheel' }
|
34
36
|
resources :strategies
|
35
37
|
|
36
38
|
get 'api/oauth2-redirect.html', to: 'api#oauth2_redirect'
|
data/lib/iron_warbler.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'business_time'
|
3
3
|
require 'haml'
|
4
4
|
require 'mongoid'
|
5
|
+
require 'httparty'
|
5
6
|
|
6
7
|
require "iro/engine"
|
7
8
|
|
@@ -178,7 +179,7 @@ class Iro::Iro
|
|
178
179
|
},
|
179
180
|
})
|
180
181
|
out = out.parsed_response
|
181
|
-
puts! out, '
|
182
|
+
puts! out, '#schwab_sync'
|
182
183
|
|
183
184
|
attrs = {
|
184
185
|
schwab_access_token: out['access_token'],
|
data/lib/tasks/iro_tasks.rake
CHANGED
@@ -73,6 +73,12 @@ namespace :iro do
|
|
73
73
|
Iro::Position.active.where({ kind: 'covered_call' }).map &:refresh
|
74
74
|
end
|
75
75
|
|
76
|
+
desc 'sync schwab'
|
77
|
+
task sync_schwab: :environment do
|
78
|
+
Iro::Iro.schwab_sync
|
79
|
+
puts '.'
|
80
|
+
end
|
81
|
+
|
76
82
|
desc 'watch positions'
|
77
83
|
task watch_positions: :environment do
|
78
84
|
while true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_warbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.7.
|
4
|
+
version: 2.0.7.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: business_time
|
@@ -242,16 +242,6 @@ files:
|
|
242
242
|
- app/jobs/tda_job.rb-bk
|
243
243
|
- app/mailers/iro/alert_mailer.rb
|
244
244
|
- app/mailers/iro/application_mailer.rb
|
245
|
-
- app/models/iro/alert.rb
|
246
|
-
- app/models/iro/datapoint.rb
|
247
|
-
- app/models/iro/date.rb
|
248
|
-
- app/models/iro/option.rb
|
249
|
-
- app/models/iro/option_black_scholes.rb
|
250
|
-
- app/models/iro/position.rb
|
251
|
-
- app/models/iro/priceitem.rb
|
252
|
-
- app/models/iro/purse.rb
|
253
|
-
- app/models/iro/stock.rb
|
254
|
-
- app/models/iro/strategy.rb
|
255
245
|
- app/models/tda/option.rb
|
256
246
|
- app/models/tda/stock.rb
|
257
247
|
- app/views/iro/_analytics.erb
|
@@ -269,19 +259,10 @@ files:
|
|
269
259
|
- app/views/iro/positions/_form.haml
|
270
260
|
- app/views/iro/positions/_formpart_4data.haml
|
271
261
|
- app/views/iro/positions/_gameui_covered_call.haml
|
272
|
-
- app/views/iro/positions/
|
273
|
-
- app/views/iro/positions/_gameui_long_credit_put_spread.haml
|
274
|
-
- app/views/iro/positions/_gameui_long_debit_call_spread.haml
|
275
|
-
- app/views/iro/positions/_gameui_long_debit_call_spread.haml-trash
|
276
|
-
- app/views/iro/positions/_gameui_short_credit_call_spread.haml
|
277
|
-
- app/views/iro/positions/_gameui_short_debit_put_spread.haml
|
278
|
-
- app/views/iro/positions/_gameui_short_debit_put_spread.haml-trash
|
262
|
+
- app/views/iro/positions/_gameui_spread.haml
|
279
263
|
- app/views/iro/positions/_header.haml
|
280
264
|
- app/views/iro/positions/_header_covered_call.haml
|
281
|
-
- app/views/iro/positions/
|
282
|
-
- app/views/iro/positions/_header_long_debit_call_spread.haml
|
283
|
-
- app/views/iro/positions/_header_short_credit_call_spread.haml
|
284
|
-
- app/views/iro/positions/_header_short_debit_put_spread.haml
|
265
|
+
- app/views/iro/positions/_header_spread.haml
|
285
266
|
- app/views/iro/positions/_new.haml
|
286
267
|
- app/views/iro/positions/_prepare_covered_call.haml
|
287
268
|
- app/views/iro/positions/_prepare_long_debit_call_spread.haml
|
@@ -289,29 +270,38 @@ files:
|
|
289
270
|
- app/views/iro/positions/_prepare_short_debit_put_spread.haml
|
290
271
|
- app/views/iro/positions/_reasons.haml
|
291
272
|
- app/views/iro/positions/_table.haml
|
273
|
+
- app/views/iro/positions/done/_gameui_covered_call.haml-bk
|
274
|
+
- app/views/iro/positions/done/_gameui_long_credit_put_spread.haml
|
275
|
+
- app/views/iro/positions/done/_gameui_long_debit_call_spread.haml
|
276
|
+
- app/views/iro/positions/done/_gameui_short_credit_call_spread.haml
|
277
|
+
- app/views/iro/positions/done/_gameui_short_debit_put_spread.haml
|
278
|
+
- app/views/iro/positions/done/_header_long_credit_put_spread.haml
|
279
|
+
- app/views/iro/positions/done/_header_long_debit_call_spread.haml
|
280
|
+
- app/views/iro/positions/done/_header_short_credit_call_spread.haml
|
281
|
+
- app/views/iro/positions/done/_header_short_debit_put_spread.haml
|
282
|
+
- app/views/iro/positions/done/roll-cc.haml-bk
|
292
283
|
- app/views/iro/positions/edit.haml
|
293
284
|
- app/views/iro/positions/new.haml
|
294
285
|
- app/views/iro/positions/prepare.haml
|
295
286
|
- app/views/iro/positions/prepare2.haml
|
296
|
-
- app/views/iro/positions/roll-cc.haml-bk
|
297
|
-
- app/views/iro/positions/roll.haml-trash
|
298
287
|
- app/views/iro/purses/_form.haml
|
299
288
|
- app/views/iro/purses/_form_extra_fields.haml
|
300
289
|
- app/views/iro/purses/_header.haml
|
301
290
|
- app/views/iro/purses/_summary.haml
|
291
|
+
- app/views/iro/purses/done/gameui.haml-bk
|
292
|
+
- app/views/iro/purses/done/gameui.haml-bk2
|
302
293
|
- app/views/iro/purses/edit.haml
|
303
294
|
- app/views/iro/purses/gameui.haml
|
304
|
-
- app/views/iro/purses/gameui.haml-bk
|
305
|
-
- app/views/iro/purses/gameui.haml-bk2
|
306
295
|
- app/views/iro/purses/index.haml
|
307
296
|
- app/views/iro/purses/show.haml
|
308
297
|
- app/views/iro/stocks/_form.haml
|
309
|
-
- app/views/iro/stocks/
|
310
|
-
- app/views/iro/stocks/
|
298
|
+
- app/views/iro/stocks/_grid_long.haml
|
299
|
+
- app/views/iro/stocks/_grid_short.haml
|
311
300
|
- app/views/iro/stocks/edit.haml
|
312
301
|
- app/views/iro/stocks/index.haml
|
313
302
|
- app/views/iro/stocks/show.haml
|
314
|
-
- app/views/iro/strategies/
|
303
|
+
- app/views/iro/strategies/_form_spread.haml
|
304
|
+
- app/views/iro/strategies/_form_wheel.haml
|
315
305
|
- app/views/iro/strategies/_header.haml
|
316
306
|
- app/views/iro/strategies/_show.haml
|
317
307
|
- app/views/iro/strategies/_table.haml
|
data/app/models/iro/alert.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
|
2
|
-
class Iro::Alert
|
3
|
-
include Mongoid::Document
|
4
|
-
include Mongoid::Timestamps
|
5
|
-
include Mongoid::Paranoia
|
6
|
-
store_in collection: 'iro_alerts'
|
7
|
-
|
8
|
-
# SLEEP_TIME_SECONDS = Rails.env.production? ? 60 : 15
|
9
|
-
|
10
|
-
DIRECTION_ABOVE = 'ABOVE'
|
11
|
-
DIRECTION_BELOW = 'BELOW'
|
12
|
-
def self.directions_list
|
13
|
-
[ nil, DIRECTION_ABOVE, DIRECTION_BELOW ]
|
14
|
-
end
|
15
|
-
|
16
|
-
STATUS_ACTIVE = 'active'
|
17
|
-
STATUS_INACTIVE = 'inactive'
|
18
|
-
STATUSES = [ nil, 'active', 'inactive' ]
|
19
|
-
field :status, default: STATUS_ACTIVE
|
20
|
-
def self.active
|
21
|
-
where( status: STATUS_ACTIVE )
|
22
|
-
end
|
23
|
-
|
24
|
-
field :class_name, default: 'Iro::Stock'
|
25
|
-
validates :class_name, presence: true
|
26
|
-
|
27
|
-
field :symbol, type: String
|
28
|
-
validates :symbol, presence: true
|
29
|
-
|
30
|
-
field :direction, type: String
|
31
|
-
validates :direction, presence: true
|
32
|
-
|
33
|
-
field :strike, type: Float
|
34
|
-
validates :strike, presence: true
|
35
|
-
|
36
|
-
def do_run
|
37
|
-
alert = self
|
38
|
-
begin
|
39
|
-
price = Tda::Stock.get_quote( alert.symbol )&.last
|
40
|
-
return if !price
|
41
|
-
|
42
|
-
if ( alert.direction == alert.class::DIRECTION_ABOVE && price >= alert.strike ) ||
|
43
|
-
( alert.direction == alert.class::DIRECTION_BELOW && price <= alert.strike )
|
44
|
-
|
45
|
-
if Rails.env.production?
|
46
|
-
Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_later
|
47
|
-
else
|
48
|
-
Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_now
|
49
|
-
end
|
50
|
-
alert.update({ status: alert.class::STATUS_INACTIVE })
|
51
|
-
print '^'
|
52
|
-
|
53
|
-
end
|
54
|
-
rescue => err
|
55
|
-
puts! err, 'err'
|
56
|
-
::ExceptionNotifier.notify_exception(
|
57
|
-
err,
|
58
|
-
data: { alert: alert }
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|