iron_warbler 2.0.7.18 → 2.0.7.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascript/iron_warbler/application.js +2 -0
  3. data/app/assets/javascript/iron_warbler/gameui.js +9 -0
  4. data/app/assets/stylesheets/iron_warbler/application.css +13 -3
  5. data/app/assets/stylesheets/iron_warbler/positions.scss +9 -1
  6. data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +191 -0
  7. data/app/assets/stylesheets/iron_warbler/purses_gameui.scss-bk +112 -0
  8. data/app/assets/stylesheets/iron_warbler/utils.scss +82 -0
  9. data/app/controllers/iro/api/stocks_controller.rb +87 -0
  10. data/app/controllers/iro/api_controller.rb +19 -0
  11. data/app/controllers/iro/positions_controller.rb +16 -4
  12. data/app/controllers/iro/purses_controller.rb +8 -3
  13. data/app/controllers/iro/strategies_controller.rb +7 -7
  14. data/app/helpers/iro/application_helper.rb +5 -2
  15. data/app/models/iro/alert.rb +2 -1
  16. data/app/models/iro/datapoint.rb +48 -8
  17. data/app/models/iro/position.rb +55 -14
  18. data/app/models/iro/position_covered_call.rb +4 -0
  19. data/app/models/iro/position_debit_spread.rb +251 -0
  20. data/app/models/iro/price_item.rb +51 -1
  21. data/app/models/iro/stock.rb +5 -2
  22. data/app/models/iro/strategy.rb +76 -10
  23. data/app/models/tda/stock.rb +3 -0
  24. data/app/views/iro/_main_header.haml +18 -17
  25. data/app/views/iro/api/stocks/show.jbuilder +11 -0
  26. data/app/views/iro/positions/_form.haml +11 -38
  27. data/app/views/iro/positions/_formpart_4data.haml +46 -0
  28. data/app/views/iro/positions/_gameui_covered_call.haml +36 -0
  29. data/app/views/iro/positions/_gameui_covered_call.haml-bk +59 -0
  30. data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +37 -0
  31. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +39 -0
  32. data/app/views/iro/positions/_header.haml +6 -0
  33. data/app/views/iro/positions/_header_covered_call.haml +6 -0
  34. data/app/views/iro/positions/_header_long_debit_call_spread.haml +14 -0
  35. data/app/views/iro/positions/_header_short_debit_put_spread.haml +1 -0
  36. data/app/views/iro/positions/_table.haml +118 -123
  37. data/app/views/iro/positions/roll.haml +83 -0
  38. data/app/views/iro/positions/trash/_header_short_debit_put_spread.haml +9 -0
  39. data/app/views/iro/purses/_header.haml +18 -0
  40. data/app/views/iro/purses/gameui.haml +18 -0
  41. data/app/views/iro/purses/gameui.haml-bk +44 -0
  42. data/app/views/iro/purses/gameui.haml-bk2 +89 -0
  43. data/app/views/iro/purses/show.haml +1 -7
  44. data/app/views/iro/stocks/_grid_is_long.haml +13 -0
  45. data/app/views/iro/stocks/_grid_is_short.haml +13 -0
  46. data/app/views/iro/strategies/_form.haml +12 -5
  47. data/app/views/iro/strategies/_show.haml +3 -2
  48. data/app/views/iro/strategies/_table.haml +16 -10
  49. data/app/views/iro/strategies/index.haml +8 -0
  50. data/app/views/layouts/iro/application.haml +1 -1
  51. data/config/routes.rb +14 -1
  52. data/lib/tasks/db_tasks.rake +9 -3
  53. metadata +29 -8
  54. data/app/assets/stylesheets/iron_warbler/alerts.css +0 -8
  55. data/app/assets/stylesheets/iron_warbler/datapoints.css +0 -0
  56. data/app/assets/stylesheets/iron_warbler/profiles.css +0 -4
  57. data/app/assets/stylesheets/iron_warbler/strategies.scss +0 -0
  58. data/app/assets/stylesheets/iron_warbler/utils.css +0 -44
  59. data/app/jobs/iro/application_job.rb-trash +0 -4
@@ -1,23 +1,24 @@
1
1
 
2
- .main-header.maxwidth
2
+ .application-main-header.main-header
3
+ .maxwidth
3
4
 
4
- %i.fa.fa-compress.collapse-expand#collapseHeaderEmail
5
- Iron Warbler
5
+ %i.fa.fa-compress.collapse-expand#collapseHeaderTrading
6
+ Iron Warbler
6
7
 
7
- -# .header.collapse-expand#IroMenu
8
- -# %h5.title Iron Warbler
8
+ -# .header.collapse-expand#IroMenu
9
+ -# %h5.title Iron Warbler
9
10
 
10
- %ul
11
- %li= link_to 'ROOT', root_path
12
- %li
13
- = link_to "Stocks (#{Iro::Stock.all.length})", stocks_path
14
- -# %li= link_to 'Options', options_path
15
- -# %li Max Pain
16
- %li
17
- = link_to "Alerts (#{Iro::Alert.all.length})", alerts_path
18
- %li
19
- = link_to "Purses (#{Iro::Purse.all.length})", purses_path
20
- %li
21
- = render '/iro/strategies/header'
11
+ %ul
12
+ %li= link_to 'ROOT', root_path
13
+ %li
14
+ = link_to "Stocks (#{Iro::Stock.all.length})", stocks_path
15
+ -# %li= link_to 'Options', options_path
16
+ -# %li Max Pain
17
+ %li
18
+ = link_to "Alerts (#{Iro::Alert.all.length})", alerts_path
19
+ %li
20
+ = link_to "Purses (#{Iro::Purse.all.length})", purses_path
21
+ %li
22
+ = render '/iro/strategies/header'
22
23
 
23
24
 
@@ -0,0 +1,11 @@
1
+
2
+ json.array! @datapoints do |p|
3
+ json.date p[:quote_at].in_time_zone('UTC').to_date
4
+ json.quote_at p[:quote_at]
5
+ json.open p[:open]
6
+ json.high p[:high]
7
+ json.low p[:low]
8
+ json.close p[:value]
9
+ json.volume p[:volume]
10
+ end
11
+
@@ -1,59 +1,32 @@
1
1
 
2
- .positions--form
2
+ .positions--form{ class: params[:long_or_short] || position.strategy&.long_or_short }
3
3
  = form_for position do |f|
4
4
  .actions
5
5
  = f.submit
6
6
 
7
- .field
8
- %label Purse
9
- -# = f.select :purse_id, options_for_select( @
10
- = f.text_field :purse_id
11
-
12
- %label Status
13
- = f.select :status, options_for_select( Iro::Position::STATUSES, selected: position.status )
7
+ .d-flex
8
+ .field
9
+ %label Purse
10
+ -# = f.select :purse_id, options_for_select( @
11
+ = f.text_field :purse_id
14
12
 
15
- %br
16
- %br
13
+ %label Status
14
+ = f.select :status, options_for_select( Iro::Position::STATUSES, selected: position.status )
17
15
 
18
16
  .field
19
- %label Ticker
20
- = f.select :ticker, options_for_select( @tickers_list, selected: position.ticker )
21
-
22
-
23
- %label Kind
24
- = f.select :kind, options_for_select( Iro::Position::KINDS, selected: position.kind )
17
+ %label Stock
18
+ = f.select :stock_id, options_for_select( @stocks_list, selected: position.stock_id )
25
19
  %label Strategy
26
20
  = f.select :strategy_id, options_for_select( @strategies_list, selected: position.strategy_id )
27
21
 
28
-
29
- %label Strike
30
- = f.text_field :strike
31
-
32
22
  .field
33
23
  %label Expires on
34
24
  = f.text_field :expires_on
35
-
36
-
37
25
  %label Quantity
38
26
  = f.text_field :quantity
39
27
 
40
28
  %br
41
- %br
42
-
43
- .flex-row
44
- %label Begin on
45
- = f.text_field :begin_on
46
- %label Begin price
47
- = f.text_field :begin_price
48
- %label Begin delta
49
- = f.text_field :begin_delta
50
- .flex-row
51
- %label End on
52
- = f.text_field :end_on
53
- %label End price
54
- = f.text_field :end_price
55
- %label End delta
56
- = f.text_field :end_delta
29
+ = render 'formpart_4data', f: f, position: position
57
30
 
58
31
  .actions
59
32
  = f.submit
@@ -0,0 +1,46 @@
1
+ .field
2
+ %label Begin on
3
+ = f.text_field :begin_on
4
+
5
+ .long-or-short-item
6
+ .d-flex
7
+ .field
8
+ %label Outer Strike
9
+ = f.number_field :outer_strike, step: 0.01
10
+ .field
11
+ %label Begin outer price
12
+ = f.text_field :begin_outer_price
13
+ .field
14
+ %label Begin outer delta
15
+ = f.text_field :begin_outer_delta
16
+
17
+ .d-flex
18
+ .field
19
+ %label Inner Strike
20
+ = f.number_field :inner_strike, step: 0.01
21
+ .field
22
+ %label Begin inner price
23
+ = f.text_field :begin_inner_price
24
+ .field
25
+ %label Begin inner delta
26
+ = f.text_field :begin_inner_delta
27
+
28
+ %br
29
+ .flex-row
30
+ %label End on
31
+ = f.text_field :end_on
32
+ .long-or-short-item
33
+ .d-flex
34
+ .field
35
+ %label End outer price
36
+ = f.text_field :end_outer_price
37
+ .field
38
+ %label End outer delta
39
+ = f.text_field :end_outer_delta
40
+ .d-flex
41
+ .field
42
+ %label End inner price
43
+ = f.text_field :end_inner_price
44
+ .field
45
+ %label End inner delta
46
+ = f.text_field :end_inner_delta
@@ -0,0 +1,36 @@
1
+
2
+ - pos = position
3
+ - stock = pos.stock
4
+ - nearest_strike = stock.last.round
5
+ - u = @unit # pixels per dollar
6
+
7
+ .collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
8
+ [<>]
9
+ .maxwidth= render "/iro/positions/header", pos: pos
10
+ .a
11
+ = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
12
+ .StockCoordinatesW
13
+ .StockCoordinates
14
+ = render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock
15
+
16
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
17
+ .label Last: #{pp_amount stock.last}
18
+ .c
19
+
20
+ - left = "#{ (stock.last - position.inner_strike - position.begin_inner_price) * u}px"
21
+ - width = "#{ position.begin_inner_price * u}px"
22
+ .PositionW{ style: "left: #{left}; width: #{width}; " }
23
+ .Position
24
+ -# .label
25
+ -# width: #{ ( position.begin_inner_price - position.begin_outer_price - position.outer_strike + position.inner_strike ) }
26
+
27
+ - if position.net_amount >= 0
28
+ .Net.NetPositive{ style: "width: #{ (position.net_amount / 100) * u }px; right: 0" }
29
+ .label
30
+ net
31
+ = pp_amount position.net_amount
32
+ - else
33
+ .Net.NetNegative{ style: "width: #{ (-1 * position.net_amount / 100) * u }px; left: 100%" }
34
+ .label
35
+ net
36
+ = pp_amount position.net_amount
@@ -0,0 +1,59 @@
1
+
2
+ - unit = u = 50 # pixels per dollar
3
+ - grid_size = 100 # dollars to each side of origin
4
+ .purses-gameui.padded
5
+ = render '/iro/purses/header', purse: @purse
6
+
7
+ - @positions.each_with_index do |position, idx|
8
+ - stock = position.stock
9
+ - if idx == 0
10
+ %h4= stock
11
+ - else
12
+ - prev_ = @positions[idx-1]
13
+ - if stock != prev_.stock
14
+ %hr
15
+ %h4= stock
16
+
17
+ .header
18
+ = position.quantity
19
+ = stock
20
+ = position.expires_on.to_datetime.strftime("%b %d")
21
+ = link_to '[roll]', roll_position_path(position)
22
+ = link_to '[~]', edit_position_path(position)
23
+
24
+ - nearest_strike = stock.last.round
25
+ .StockCoordinatesW
26
+
27
+ .StockCoordinates
28
+ .grid-mark.mark0
29
+ .label= nearest_strike
30
+ - (1...grid_size).each_with_index do |idx|
31
+ .grid-mark{ class: "mark#{idx}", style: "left: -#{idx * u}px" }
32
+ .label
33
+ = nearest_strike + idx
34
+ .grid-mark{ class: "mark-#{idx}", style: "left: #{idx * u}px" }
35
+ .label
36
+ = nearest_strike - idx
37
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
38
+ .label
39
+ Last:
40
+ = stock.last
41
+
42
+ - left = "#{ (stock.last - position.inner_strike - position.begin_inner_price) * u}px"
43
+ - width = "#{ position.begin_inner_price * u}px"
44
+ .PositionW{ style: "left: #{left}; width: #{width}; " }
45
+
46
+ .Position
47
+ - if position.net_amount >= 0
48
+ .Net.NetPositive{ style: "width: #{ (position.net_amount / 100) * u }px; right: 0" }
49
+ .label
50
+ net
51
+ = pp_amount position.net_amount
52
+ - else
53
+ .Net.NetNegative{ style: "width: #{ (-1 * position.net_amount / 100) * u }px; left: 100%" }
54
+ .label
55
+ net
56
+ = pp_amount position.net_amount
57
+
58
+ %br
59
+ %br
@@ -0,0 +1,37 @@
1
+
2
+ - pos = position
3
+ - stock = pos.stock
4
+ - nearest_strike = stock.last.round
5
+ - u = @unit # pixels per dollar
6
+
7
+ .collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
8
+ [<>]
9
+ .maxwidth= render "/iro/positions/header", pos: pos
10
+ .a
11
+ = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
12
+ .StockCoordinatesW
13
+ .StockCoordinates
14
+ = render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock
15
+
16
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
17
+ .label Last: #{pp_amount stock.last}
18
+ .c
19
+
20
+ - left = "#{ ( pos.outer_strike - stock.last ) * u}px"
21
+ - width = "#{ ( pos.inner_strike - pos.outer_strike ) * u}px"
22
+ .PositionW{ style: "left: #{left}; width: #{width}; " }
23
+ .Position
24
+ .MaxGain{ style: "width: #{pos.max_gain * u}px" }
25
+
26
+ - if pos.net_amount >= 0
27
+ .Net.NetPositive{ style: "width: #{ (pos.net_amount / 100) * u }px; right: 0" }
28
+ .label
29
+ net
30
+ = pp_amount pos.net_amount
31
+ - else
32
+ .Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount / 100) * u }px; left: 100%" }
33
+ .label
34
+ net
35
+ = pp_amount pos.net_amount
36
+ .c
37
+
@@ -0,0 +1,39 @@
1
+
2
+ - pos = position
3
+ - stock = pos.stock
4
+ - nearest_strike = stock.last.round
5
+ - u = @unit # pixels per dollar
6
+
7
+
8
+ .collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
9
+ [<>]
10
+ .maxwidth= render "/iro/positions/header", pos: pos
11
+ .a
12
+ = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
13
+ .StockCoordinatesW
14
+ .StockCoordinates
15
+ = render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock
16
+
17
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
18
+ .label Last: #{pp_amount stock.last}
19
+ .c
20
+
21
+ -## these are different
22
+ - left = "#{ ( stock.last - pos.outer_strike ) * u}px"
23
+ - width = "#{ ( pos.outer_strike - pos.inner_strike ) * u}px"
24
+ .PositionW{ style: "left: #{left}; width: #{width}; " }
25
+ .Position
26
+ .MaxGain{ style: "width: #{pos.max_gain * u}px" }
27
+
28
+ - if pos.net_amount >= 0
29
+ .Net.NetPositive{ style: "width: #{ (pos.net_amount / 100) * u }px; right: 0" }
30
+ .label
31
+ net
32
+ = pp_amount pos.net_amount
33
+ - else
34
+ .Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount / 100) * u }px; left: 100%" }
35
+ .label
36
+ net
37
+ = pp_amount pos.net_amount
38
+ .c
39
+
@@ -0,0 +1,6 @@
1
+
2
+ .maxwidth
3
+ = pos
4
+ = link_to '[roll]', roll_position_path(pos)
5
+ = link_to '[~]', edit_position_path(pos)
6
+ -# = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
@@ -0,0 +1,6 @@
1
+
2
+ %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{pos.id}" }
3
+ .maxwidth
4
+ %ul.m-0.p-0
5
+ %li <b>begin_inner_price:</b> #{pp_amount pos.begin_inner_price}
6
+ %li <b>Net:</b> #{pp_amount pos.net_amount} &nbsp; <i>#{pp_percent pos.net_percent}</i>
@@ -0,0 +1,14 @@
1
+
2
+
3
+ -## Same file for the spreads
4
+ %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{pos.id}" }
5
+ .maxwidth
6
+ %ul.m-0.p-0
7
+ %li <b>outer,inner_strike:</b> #{pp_amount pos.outer_strike} -> #{pp_amount pos.inner_strike}
8
+ %li
9
+ <b>begin_outer,inner_price:</b> #{pp_amount pos.begin_outer_price} -> #{pp_amount pos.begin_inner_price}
10
+ &nbsp;&nbsp;
11
+ -## yes *100
12
+ <b>max gain:</b> #{pp_amount pos.max_gain} :: #{pp_amount pos.max_gain * 100 * pos.q}
13
+ - ## no *100
14
+ %li <b>Net:</b> #{pp_amount pos.net_amount} :: #{pp_amount pos.net_amount * pos.q} &nbsp;&nbsp; <i>#{pp_percent pos.net_percent}</i>
@@ -0,0 +1 @@
1
+ app/views/iro/positions/_header_long_debit_call_spread.haml
@@ -3,131 +3,126 @@
3
3
 
4
4
  %h5 Positions
5
5
  %table.bordered
6
- %tr
7
- %th &nbsp;
8
- %th
9
- .status
10
- Status
11
- %br
12
- Strategy
13
- %th.ticker
14
- .a Ticker
15
- %th
16
- .kind
17
- Kind
18
- -# covered call (mounted elephant),
19
- -# reckless defence (credit put spread) (spearman)
20
- -# reckless re-defence (soaring eagle)
21
- %th.strike
22
- .a Strike
23
- %th
24
- .expires_on Expires On
25
- %th
26
- .end_n_days End N Days
27
- %th
28
- .quantity Q
29
-
30
- %th
31
- .begin_on begin_on
32
- %th.begin_price
33
- .a Begin price
34
- %th.to_open
35
- .a To open
36
- %th
37
- .begin_delta begin_delta
38
-
39
- %th
40
- .end_price End Price
41
- %th
42
- .net_amount Net Amount
43
- %th
44
- .net_percent Net %
45
- %th.end_delta
46
- .a end_delta
47
- -# %th
48
- -# .end_n_days End n days
49
- -# %th
50
- -# .end_on End on
51
- %th.should_rollp
52
- .a should_rollp
53
- %th.next_position
54
- .a
55
- next_symbol
56
- %br
57
- next_delta
58
- %br
59
- next_outcome
60
-
61
- - positions.each_with_index do |position, idx|
62
- - if idx > 0
63
- - prev_position = positions[idx-1]
64
- - if prev_position && position[:expires_on] != prev_position[:expires_on]
65
- %tr
66
- %td{ colspan: 18 }
67
- %hr
68
-
6
+ %thead
69
7
  %tr
70
- %td.actions
71
- .flex-row
72
- = button_to 'x', position_path(position), method: :delete, data: { confirm: 'Are you sure?' }
73
- = link_to '[~]', edit_position_path(position)
74
- - if position.next_reasons.present? && position.should_rollp && position.should_rollp > 0.5
75
- = button_to 'Roll', roll_position_path(position)
76
- - if position.next_reasons.present?
77
- .collapse-expand{ id: "ce-p-#{position.id}" } [Reasons]
78
- = render '/iro/positions/reasons', reasons: position.next_reasons
79
-
80
-
81
- %td.status.strategy
82
- = position.status
83
- -# %br
84
- -# = link_to "[~ #{position.strategy}]", edit_strategy_path(position.strategy)
85
- .collapse-expand{ id: "ce-pos-reasons-#{position.id}" }
86
- [#{position.strategy}]
87
- = render '/iro/strategies/show', strategy: position.strategy
88
-
89
- %td.ticker
90
- = position.ticker
91
- %br
92
- = pp_amount position.current_underlying_strike
93
- %td.kind.mini
94
- = position.kind
95
- %td.strike
96
- = pp_amount position.strike
97
- %td.expires_on.mini
98
- = position.expires_on rescue nil
99
- %td.end_n_days
100
- -# = ( position.expires_on.to_date - position.begin_on.to_date ).to_i
101
- %b= ( position.expires_on.to_date - Time.now.to_date ).to_i
102
- %td= position.quantity
103
-
104
- %td.begin_on.mini
105
- = position.begin_on rescue nil
106
- %td.begin_price
107
- = pp_amount position.begin_price
108
- %td.to_open
109
- = pp_amount( position.begin_price * 100 * position.quantity )
110
- %td= position.begin_delta
111
-
112
- %td.end_price
113
- = pp_amount position.end_price
114
- %td.net_amount
115
- = pp_amount ( position.begin_price - position.end_price ) * 100 * position.quantity rescue nil
116
- %td.net_percent
117
- = pp_percent( ( position.begin_price - position.end_price ) / position.begin_price ) rescue nil
118
- %td.end_delta= position.end_delta
119
- -# %td.end_n_days &nbsp;
120
- -# %td.end_on &nbsp;
121
-
122
- %td.should_rollp
123
- = pp_percent position.should_rollp rescue nil
124
- %td.next_position.mini
125
- .a= position.next_symbol
126
- .a= position.next_delta
8
+ %th &nbsp;
9
+ %th
10
+ .status
11
+ Status
12
+ %br
13
+ Expires on
14
+ %br
15
+ Strategy
16
+ %th.ticker
17
+ .a Stock
18
+ %th.strikes
19
+ .a outer_strike, inner_strike
20
+ %th.begin_price
21
+ .a Begin outer price, delta
22
+ %th.max_loss
23
+ .a Max Loss, gain
24
+ %th
25
+ .end_price End Price, delta
26
+ %th
27
+ .net Net Amount (%)
28
+ %th
29
+ .breakeven Breakeven
30
+
31
+
32
+ %th.should_rollp
33
+ .a should_rollp
34
+ %th.next_position
127
35
  .a
128
- = pp_amount position.next_mark
129
- \=>
130
- = pp_amount position.next_outcome * 100 * position.quantity rescue nil
36
+ next_symbol
37
+ %br
38
+ next_delta
39
+ %br
40
+ next_outcome
41
+
42
+ -# wtf caching issue?!
43
+ - positions.map &:id
44
+ %tbody
45
+ - positions.each_with_index do |position, idx|
46
+ - pos = position
47
+ - if idx > 0
48
+ - prev_position = positions[idx-1]
49
+ - if prev_position && position.expires_on != prev_position.expires_on
50
+ %tr
51
+ %td{ colspan: 18 }
52
+ -# %hr
53
+ .h-50px
54
+
55
+ %tr{ class: position.strategy.long_or_short }
56
+ %td.actions
57
+ .flex-row
58
+ = button_to 'x', position_path(position), method: :delete, data: { confirm: 'Are you sure?' }
59
+ = link_to '[~]', edit_position_path(position)
60
+ - if position.next_reasons.present? && position.should_rollp && position.should_rollp > 0.5
61
+ = button_to 'Roll', roll_position_path(position)
62
+ - if position.next_reasons.present?
63
+ .collapse-expand{ id: "ce-p-#{position.id}" } [Reasons]
64
+ = render '/iro/positions/reasons', reasons: position.next_reasons
65
+
66
+
67
+ %td.status.strategy.w-200px
68
+ = position.status
69
+ %br
70
+ = position.expires_on.to_datetime.strftime("%b %d")
71
+ [#{ ( position.expires_on.to_date - Time.now.to_date ).to_i }&nbsp;DTE]
72
+ %br
73
+ %i.fa.fa-compress.collapse-expand{ id: "ce-pos-reasons-#{position.id}" }
74
+ #{position.strategy}
75
+ = render '/iro/strategies/show', strategy: position.strategy
76
+
77
+ %td.ticker
78
+ = position.stock.ticker
79
+ <b>(#{position.quantity})</b>
80
+ %br
81
+ = pp_amount position.stock.last
82
+ %td.strikes
83
+ .long-or-short-item
84
+ .a= pp_amount position.outer_strike
85
+ .a= pp_amount position.inner_strike
86
+
87
+ %td.begin_price
88
+ .long-or-short-item
89
+ .a
90
+ = pp_amount position.begin_outer_price
91
+ <b>D</b> #{pp_delta position.begin_outer_delta}
92
+ .a
93
+ = pp_amount position.begin_inner_price
94
+ <b>D</b> #{pp_delta position.begin_inner_delta}
95
+ %td.max_loss.max_gain
96
+ = pp_amount position.max_loss * pos.q, precision: 0
97
+ %br
98
+ = pp_amount position.max_gain * pos.q, precision: 0
99
+ %br
100
+ = pp_percent( -1 * position.max_gain / position.max_loss ) rescue '-' # undef. for covered calls
101
+ %td.end_price
102
+ .long-or-short-item
103
+ .a
104
+ = pp_amount position.end_outer_price
105
+ <b>D</b> #{pp_delta position.end_outer_delta}
106
+ .a
107
+ = pp_amount position.end_inner_price
108
+ <b>D</b> #{pp_delta position.end_inner_delta}
109
+ %td.net
110
+ .a= pp_amount position.net_amount * pos.q, precision: 0 rescue '@TODO'
111
+ .a <i>#{pp_percent position.net_amount / position.max_gain rescue '@TODO'}</i>
112
+ %td.breakeven
113
+ = pp_amount pos.breakeven rescue '@TODO'
114
+
115
+
116
+
117
+ %td.should_rollp
118
+ <i> #{pp_percent position.should_rollp rescue '?'}</i>
119
+ %td.next_position.mini
120
+ .a= position.next_symbol
121
+ .a= position.next_delta
122
+ .a
123
+ = pp_amount position.next_mark
124
+ \=>
125
+ = pp_amount position.next_outcome * 100 * position.quantity rescue nil
131
126
 
132
127
 
133
128