iron_warbler 2.0.7.22 → 2.0.7.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/iron_warbler/application.css +12 -0
  3. data/app/assets/stylesheets/iron_warbler/positions.scss +2 -0
  4. data/app/assets/stylesheets/iron_warbler/positions_gameui.scss +11 -0
  5. data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +6 -2
  6. data/app/assets/stylesheets/iron_warbler/purses_summary.scss +98 -0
  7. data/app/assets/stylesheets/iron_warbler/utils.scss +4 -0
  8. data/app/controllers/iro/alerts_controller.rb +2 -0
  9. data/app/controllers/iro/application_controller.rb +13 -0
  10. data/app/controllers/iro/positions_controller.rb +197 -23
  11. data/app/controllers/iro/purses_controller.rb +60 -6
  12. data/app/controllers/iro/stocks_controller.rb +30 -18
  13. data/app/controllers/iro/strategies_controller.rb +12 -1
  14. data/app/models/iro/alert.rb +1 -0
  15. data/app/models/iro/option.rb +1 -0
  16. data/app/models/iro/position.rb +124 -56
  17. data/app/models/iro/purse.rb +15 -4
  18. data/app/models/iro/stock.rb +3 -0
  19. data/app/models/iro/strategy.rb +122 -27
  20. data/app/models/tda/option.rb +3 -3
  21. data/app/views/iro/_main_header.haml +28 -17
  22. data/app/views/iro/application/home.haml +6 -1
  23. data/app/views/iro/positions/_form.haml +1 -2
  24. data/app/views/iro/positions/_gameui_covered_call.haml +10 -13
  25. data/app/views/iro/positions/_gameui_covered_call.haml-bk +8 -0
  26. data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +5 -4
  27. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +5 -4
  28. data/app/views/iro/positions/_header.haml +2 -2
  29. data/app/views/iro/positions/_header_covered_call.haml +7 -1
  30. data/app/views/iro/positions/_header_long_debit_call_spread.haml +19 -1
  31. data/app/views/iro/positions/_prepare_covered_call.haml +25 -0
  32. data/app/views/iro/positions/_prepare_long_debit_call_spread.haml +23 -0
  33. data/app/views/iro/positions/_prepare_short_debit_put_spread.haml +23 -0
  34. data/app/views/iro/positions/_table.haml +33 -24
  35. data/app/views/iro/positions/prepare.haml +24 -0
  36. data/app/views/iro/positions/roll-cc.haml-bk +40 -0
  37. data/app/views/iro/positions/roll.haml-trash +42 -0
  38. data/app/views/iro/purses/_form.haml +9 -0
  39. data/app/views/iro/purses/_form_extra_fields.haml +25 -13
  40. data/app/views/iro/purses/_header.haml +15 -16
  41. data/app/views/iro/purses/_summary.haml +69 -0
  42. data/app/views/iro/purses/gameui.haml +12 -7
  43. data/app/views/iro/purses/index.haml +3 -1
  44. data/app/views/iro/purses/show.haml +5 -1
  45. data/app/views/iro/stocks/_form.haml +5 -0
  46. data/app/views/iro/stocks/_grid_is_long.haml +2 -2
  47. data/app/views/iro/stocks/_grid_is_short.haml +2 -2
  48. data/app/views/iro/stocks/index.haml +3 -2
  49. data/app/views/iro/strategies/_form.haml +12 -6
  50. data/app/views/iro/strategies/_show.haml +3 -3
  51. data/app/views/iro/strategies/_table.haml +15 -6
  52. data/app/views/iro/strategies/show.haml +14 -0
  53. data/app/views/layouts/iro/application.haml +4 -0
  54. data/config/routes.rb +6 -2
  55. metadata +12 -4
  56. data/app/views/iro/positions/roll.haml +0 -83
  57. data/app/views/iro/positions/trash/_header_short_debit_put_spread.haml +0 -9
@@ -2,7 +2,7 @@
2
2
  - pos = position
3
3
  - stock = pos.stock
4
4
  - nearest_strike = stock.last.round
5
- - u = @purse.unit # pixels per dollar
5
+ - u = pos.purse.unit # pixels per dollar
6
6
 
7
7
  .collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
8
8
  [<>]
@@ -10,8 +10,8 @@
10
10
  .a
11
11
  = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
12
12
  .StockCoordinatesW
13
- .StockCoordinates{ style: "height: #{pos.purse.height}px " }
14
- = render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock
13
+ .StockCoordinates{ style: "height: #{pos.q() *u}px " }
14
+ .grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
15
15
 
16
16
  .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
17
17
  .label Last: #{pp_amount stock.last}
@@ -19,9 +19,10 @@
19
19
 
20
20
  - left = "#{ ( pos.outer_strike - stock.last ) * u}px"
21
21
  - width = "#{ ( pos.inner_strike - pos.outer_strike ) * u}px"
22
- .PositionW{ style: "left: #{left}; width: #{width}; " }
22
+ .PositionW{ class: pos.strategy.kind, style: "left: #{left}; width: #{width}; " }
23
23
  .Position
24
24
  .MaxGain{ style: "width: #{pos.max_gain * u}px" }
25
+ .RollGuide
25
26
 
26
27
  - if pos.net_amount >= 0
27
28
  .Net.NetPositive{ style: "width: #{ (pos.net_amount / 100) * u }px; right: 0" }
@@ -2,7 +2,7 @@
2
2
  - pos = position
3
3
  - stock = pos.stock
4
4
  - nearest_strike = stock.last.round
5
- - u = @unit # pixels per dollar
5
+ - u = pos.purse.unit # pixels per dollar
6
6
 
7
7
 
8
8
  .collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
@@ -11,8 +11,8 @@
11
11
  .a
12
12
  = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
13
13
  .StockCoordinatesW
14
- .StockCoordinates{ style: "height: #{pos.purse.height}px " }
15
- = render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock
14
+ .StockCoordinates{ style: "height: #{pos.q() *u}px " }
15
+ .grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
16
16
 
17
17
  .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
18
18
  .label Last: #{pp_amount stock.last}
@@ -21,9 +21,10 @@
21
21
  -## these are different
22
22
  - left = "#{ ( stock.last - pos.outer_strike ) * u}px"
23
23
  - width = "#{ ( pos.outer_strike - pos.inner_strike ) * u}px"
24
- .PositionW{ style: "left: #{left}; width: #{width}; " }
24
+ .PositionW{ class: pos.strategy.kind, style: "left: #{left}; width: #{width}; " }
25
25
  .Position
26
26
  .MaxGain{ style: "width: #{pos.max_gain * u}px" }
27
+ .RollGuide
27
28
 
28
29
  - if pos.net_amount >= 0
29
30
  .Net.NetPositive{ style: "width: #{ (pos.net_amount / 100) * u }px; right: 0" }
@@ -1,6 +1,6 @@
1
1
 
2
2
  .positions--header.maxwidth
3
3
  = pos
4
- = link_to '[roll]', roll_position_path(pos)
5
- = link_to '[~]', edit_position_path(pos)
4
+ = link_to '[roll]', prepare_to_roll_position_path(pos) if pos.persisted?
5
+ = link_to '[~]', edit_position_path(pos) if pos.persisted?
6
6
  -# = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
@@ -1,6 +1,12 @@
1
1
 
2
- %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{pos.id}" }
2
+ - collapse_key ||= pos.id
3
+ %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{collapse_key}" }
3
4
  .maxwidth
4
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
+
5
11
  %li <b>begin_inner_price:</b> #{pp_amount pos.begin_inner_price}
6
12
  %li <b>Net:</b> #{pp_amount pos.net_amount} &nbsp; <i>#{pp_percent pos.net_percent}</i>
@@ -1,14 +1,32 @@
1
1
 
2
2
 
3
3
  -## Same file for the spreads
4
- %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{pos.id}" }
4
+ - collapse_key ||= pos.id
5
+ %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{collapse_key}" }
5
6
  .maxwidth
6
7
  %ul.m-0.p-0
8
+ - if !pos.persisted?
9
+ %li <b>expires_on:</b> #{pos.expires_on}
10
+ %li <b>outer,inner_strike:</b> #{pp_amount pos.outer_strike} -> #{pp_amount pos.inner_strike}
11
+ %li
12
+ <b>next_gain_loss_amount:</b> #{pp_amount pos.next_gain_loss_amount}
13
+ \:: #{pp_amount pos.next_gain_loss_amount * 100 * pos.q}
14
+ &nbsp;&nbsp; <i>#{pp_percent pos.next_gain_loss_amount/pos.max_loss*-1}</i>
15
+
7
16
  %li <b>outer,inner_strike:</b> #{pp_amount pos.outer_strike} -> #{pp_amount pos.inner_strike}
8
17
  %li
9
18
  <b>begin_outer,inner_price:</b> #{pp_amount pos.begin_outer_price} -> #{pp_amount pos.begin_inner_price}
10
19
  &nbsp;&nbsp;
11
20
  -## yes *100
12
21
  <b>max gain:</b> #{pp_amount pos.max_gain} :: #{pp_amount pos.max_gain * 100 * pos.q}
22
+ %li
23
+ <b>end_outer,inner_price:</b> #{pp_amount pos.end_outer_price} -> #{pp_amount pos.end_inner_price}
24
+ &nbsp;&nbsp;
25
+ -## yes *100
26
+ <b>max loss:</b> #{pp_amount pos.max_loss} :: #{pp_amount pos.max_loss * 100 * pos.q}
27
+ %li
28
+ <b>Exposure:</b> #{pp_amount pos.max_loss() *-1*100*pos.q()}
29
+ %li
30
+ <b>Breakeven:</b> #{pp_amount pos.max_gain}
13
31
  - ## no *100
14
32
  %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,25 @@
1
+
2
+
3
+ - u = pos.purse.unit # 50 ## pixels per dollar
4
+ - strategy = pos.strategy
5
+ - nearest_strike = pos.stock.last.round
6
+ - stock = pos.stock
7
+
8
+
9
+ .StockCoordinatesW
10
+ .StockCoordinates{ style: "height: #{@position.purse.height}px " }
11
+
12
+ .grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
13
+
14
+ .Origin{ style: "left: #{ ( nearest_strike - pos.stock.last )* u}px" }
15
+ .label
16
+ Last:
17
+ = pos.stock.last
18
+ - amnt = pos.next_gain_loss_amount
19
+ -# - byebug
20
+ - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
21
+ - width = "#{ pos.begin_inner_price * u}px"
22
+ - left = "#{ (pos.stock.last - pos.inner_strike - pos.begin_inner_price) * u}px"
23
+ .PositionW{ style: "width: #{width}; left: #{left}; border-right: #{border};" }
24
+ .Position
25
+ .c
@@ -0,0 +1,23 @@
1
+
2
+ - u = pos.purse.unit # 50 ## pixels per dollar
3
+ - strategy = pos.strategy
4
+ - nearest_strike = pos.stock.last.round
5
+ - stock = pos.stock
6
+
7
+
8
+ .StockCoordinatesW
9
+ .StockCoordinates{ style: "height: #{@position.purse.height}px " }
10
+
11
+ .grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
12
+
13
+ .Origin{ style: "left: #{ ( nearest_strike - pos.stock.last )* u}px" }
14
+ .label Last: #{pos.stock.last }
15
+
16
+ - amnt = pos.next_gain_loss_amount
17
+ - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
18
+ - width = "#{ ( pos.inner_strike - pos.outer_strike ) * u}px"
19
+ - left = "#{ ( pos.outer_strike - pos.stock.last ) * u}px"
20
+ .PositionW{ style: "width: #{width}; left: #{left}; border-right: #{border};" }
21
+ .Position
22
+ .MaxGain{ style: "width: #{pos.max_gain * u}px" }
23
+ .c
@@ -0,0 +1,23 @@
1
+
2
+ - u = pos.purse.unit # 50 ## pixels per dollar
3
+ - strategy = pos.strategy
4
+ - nearest_strike = pos.stock.last.round
5
+ - stock = pos.stock
6
+
7
+
8
+ .StockCoordinatesW
9
+ .StockCoordinates{ style: "height: #{@position.purse.height}px " }
10
+
11
+ .grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
12
+
13
+ .Origin{ style: "left: #{ ( nearest_strike - pos.stock.last )* u}px" }
14
+ .label Last: #{pos.stock.last }
15
+
16
+ - amnt = pos.next_gain_loss_amount
17
+ - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
18
+ - width = "#{ ( pos.outer_strike - pos.inner_strike ) * u}px"
19
+ - left = "#{ ( pos.stock.last - pos.outer_strike ) * u}px"
20
+ .PositionW{ style: "width: #{width}; left: #{left}; border-right: #{border};" }
21
+ .Position
22
+ .MaxGain{ style: "width: #{pos.max_gain * u}px" }
23
+ .c
@@ -6,6 +6,8 @@
6
6
  %thead
7
7
  %tr
8
8
  %th &nbsp;
9
+ %th.ticker
10
+ .a Stock
9
11
  %th
10
12
  .status
11
13
  Status
@@ -13,10 +15,10 @@
13
15
  Expires on
14
16
  %br
15
17
  Strategy
16
- %th.ticker
17
- .a Stock
18
+ %th.q Q
18
19
  %th.strikes
19
- .a outer_strike, inner_strike
20
+ -# .a outer_strike, inner_strike
21
+ Strike
20
22
  %th.begin_price
21
23
  .a Begin outer price, delta
22
24
  %th.max-loss Max Loss
@@ -52,34 +54,38 @@
52
54
  -# %hr
53
55
  .h-50px
54
56
 
57
+ -## tr
55
58
  %tr{ class: [ position.strategy.kind, position.strategy.long_or_short ] }
59
+
56
60
  %td.actions
57
- .flex-row
61
+ = position.status
62
+ .d-flex
58
63
  = button_to 'x', position_path(position), method: :delete, data: { confirm: 'Are you sure?' }
59
64
  = link_to '[~]', edit_position_path(position)
60
- = link_to '[refresh]', refresh_position_path(pos)
61
- - if position.next_reasons.present? && position.should_rollp && position.should_rollp > 0.5
62
- = button_to 'Roll', roll_position_path(position)
63
- - if position.next_reasons.present?
64
- .collapse-expand{ id: "ce-p-#{position.id}" } [Reasons]
65
- = render '/iro/positions/reasons', reasons: position.next_reasons
65
+ = link_to '[dup]', duplicate_position_path(position)
66
+ .d-flex
67
+ = link_to '[re]', refresh_position_path(pos)
68
+ - if true # position.next_reasons.present? && position.rollp > 0.5
69
+ = link_to '[roll]', prepare_to_roll_position_path(pos)
66
70
 
71
+ %td.ticker
72
+ = position.stock.ticker
67
73
 
68
- %td.status.strategy.w-200px
69
- = position.status
70
74
  %br
71
- = position.expires_on.to_datetime.strftime("%b %d")
72
- [#{ ( position.expires_on.to_date - Time.now.to_date ).to_i }&nbsp;DTE]
75
+ = pp_amount position.stock.last
76
+
77
+ %td.status.strategy.w-200px
78
+
79
+ %b
80
+ = position.expires_on.to_datetime.strftime("%b %d")
81
+ [#{ ( position.expires_on.to_date - Time.now.to_date ).to_i }&nbsp;DTE]
73
82
  %br
74
83
  %i.fa.fa-compress.collapse-expand{ id: "ce-pos-reasons-#{position.id}" }
75
84
  #{position.strategy}
76
85
  = render '/iro/strategies/show', strategy: position.strategy
77
86
 
78
- %td.ticker
79
- = position.stock.ticker
80
- <b>(#{position.quantity})</b>
81
- %br
82
- = pp_amount position.stock.last
87
+ %td.q
88
+ <b>#{position.quantity}</b>
83
89
  %td.strikes
84
90
  .long-or-short-item
85
91
  .outer-strike= pp_amount position.outer_strike
@@ -94,9 +100,9 @@
94
100
  = pp_amount position.begin_inner_price
95
101
  <b>D</b> #{pp_delta position.begin_inner_delta}
96
102
  %td
97
- .max-loss= pp_amount position.max_loss * pos.q, precision: 0
103
+ .max-loss= pp_amount position.max_loss * pos.q * 100, precision: 0
98
104
  %td
99
- .max-gain= pp_amount position.max_gain * pos.q, precision: 0
105
+ .max-gain= pp_amount position.max_gain * pos.q * 100, precision: 0
100
106
  .max-gainp
101
107
  -# = pp_percent( -1 * position.max_gain / position.max_loss ) rescue '-' # undef. for covered calls
102
108
 
@@ -109,7 +115,7 @@
109
115
  = pp_amount position.end_inner_price
110
116
  <b>D</b> #{pp_delta position.end_inner_delta}
111
117
  %td.net
112
- .a= pp_amount position.net_amount * pos.q, precision: 0 rescue '@TODO'
118
+ .a= pp_amount position.net_amount * pos.q * 100, precision: 0 rescue '@TODO'
113
119
  .a <i>#{pp_percent position.net_amount / position.max_gain rescue '@TODO'}</i>
114
120
  %td.breakeven
115
121
  = pp_amount pos.breakeven rescue '@TODO'
@@ -117,8 +123,11 @@
117
123
 
118
124
 
119
125
  %td.should_rollp
120
- <i> #{pp_percent position.should_rollp rescue '?'}</i>
121
- %td.next_position.mini
126
+ <i> #{pp_percent position.rollp, precision: 0}</i>
127
+ %td.next_position
128
+ - if position.next_reasons.present?
129
+ %i.fa.fa-expand.collapse-expand{ id: "pos-reasons-#{position.id}" } reasons
130
+ = render '/iro/positions/reasons', reasons: position.next_reasons
122
131
  .a= position.next_symbol
123
132
  .a= position.next_delta
124
133
  .a
@@ -0,0 +1,24 @@
1
+
2
+ - u = @position.purse.unit # 50 ## pixels per dollar
3
+ - strategy = @position.strategy
4
+ - pos = @position
5
+ - nearest_strike = pos.stock.last.round
6
+ - stock = pos.stock
7
+
8
+ .positions--prepare
9
+ = render '/iro/purses/header', purse: pos.purse
10
+
11
+ .purses-gameuiW{ data: { margin: { left: u*@n_dollars } } }
12
+ .purses-gameui
13
+ .purses-gameuiC{ style: "margin-left: #{u*@n_dollars}px; width: 100% " }
14
+
15
+ = render "/iro/positions/gameui_#{pos.strategy.kind}", position: pos
16
+
17
+ - @positions.each_with_index do |pos, idx|
18
+ .reviewing
19
+ = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos, collapse_key: 'roll'
20
+ = render "/iro/positions/prepare_#{pos.strategy.kind}", pos: pos
21
+
22
+
23
+
24
+
@@ -0,0 +1,40 @@
1
+
2
+ - u = @position.purse.unit # 50 ## pixels per dollar
3
+ - strategy = @position.strategy
4
+ - pos = @position
5
+ - nearest_strike = pos.stock.last.round
6
+ - stock = pos.stock
7
+
8
+ = render '/iro/purses/header', purse: pos.purse
9
+
10
+ .purses-gameuiW{ data: { margin: { left: u*@n_dollars } } }
11
+ .purses-gameui
12
+ .purses-gameuiC{ style: "margin-left: #{u*@n_dollars}px; width: 100% " }
13
+
14
+ = render "/iro/positions/gameui_#{pos.strategy.kind}", position: pos
15
+
16
+ - @positions.each_with_index do |pos, idx|
17
+ - stock = pos.stock
18
+ - nearest_strike = pos.stock.last.round
19
+
20
+ .reviewing
21
+ = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos, collapse_key: 'roll'
22
+ .StockCoordinatesW
23
+ .StockCoordinates{ style: "height: #{@position.purse.height}px " }
24
+
25
+ = render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
26
+
27
+ .Origin{ style: "left: #{ ( nearest_strike - pos.stock.last )* u}px" }
28
+ .label
29
+ Last:
30
+ = pos.stock.last
31
+ - amnt = pos.gain_loss_amount
32
+ - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
33
+ - width = "#{ pos.begin_inner_price * u}px"
34
+ - left = "#{ (pos.stock.last - pos.inner_strike - pos.begin_inner_price) * u}px"
35
+ .PositionW{ style: "width: #{width}; left: #{left}; border-right: #{border};" }
36
+ .Position
37
+ .c
38
+
39
+
40
+
@@ -0,0 +1,42 @@
1
+
2
+
3
+ -# .StockCoordinatesW
4
+ -# .StockCoordinates{ style: "height: #{pos.purse.height}px " }
5
+
6
+ -# .grid-mark.mark0
7
+ -# .label= nearest_strike
8
+ -# - (1...@n_dollars).each_with_index do |idx|
9
+ -# .grid-mark{ class: "mark#{idx}", style: "left: -#{idx * u}px" }
10
+ -# .label
11
+ -# = nearest_strike + idx
12
+ -# .grid-mark{ class: "mark-#{idx}", style: "left: #{idx * u}px" }
13
+ -# .label
14
+ -# = nearest_strike - idx
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 - pos.inner_strike) * u}px"
21
+ -# - width = "0px"
22
+ -# .PositionW{ style: "left: #{left} ; width: #{width} " }
23
+ -# .Position
24
+ -# .PositionC
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
+
37
+ -# .Breakeven{ style: "width: #{ pos.begin_inner_price * u }px" }
38
+ -# .label
39
+ -# Breakeven:
40
+ -# = pos.begin_inner_price
41
+ -# .c
42
+
@@ -2,9 +2,18 @@
2
2
  .iro-purses--form
3
3
  = form_for purse do |f|
4
4
  .flex-row
5
+ .field
6
+ %label stock
7
+ = f.select :stock_id, options_for_select( @stocks_list, selected: purse.stock_id )
8
+
5
9
  .field
6
10
  %label Slug
7
11
  = f.text_field :slug
12
+
13
+ .field
14
+ %label available amount
15
+ = f.number_field :available_amount
16
+
8
17
  = render '/iro/purses/form_extra_fields', f: f
9
18
  .actions
10
19
  = f.submit
@@ -1,14 +1,26 @@
1
1
 
2
- %label unit
3
- = f.number_field :unit
4
- px/usd
5
- &nbsp;&nbsp;
6
-
7
- %label height
8
- = f.number_field :height
9
- px
10
- &nbsp;&nbsp;
11
-
12
- %label mark_every_n_usd
13
- = f.number_field :mark_every_n_usd, step: 0.01
14
- &nbsp;&nbsp;
2
+ .d-flex.flex-wrap
3
+ %label unit
4
+ = f.number_field :unit
5
+ px/usd
6
+ &nbsp;&nbsp;
7
+
8
+ -# %label height
9
+ -# = f.number_field :height
10
+ -# px
11
+ -# &nbsp;&nbsp;
12
+
13
+ %label mark_every_n_usd
14
+ = f.number_field :mark_every_n_usd, step: 0.01
15
+ &nbsp;&nbsp;
16
+
17
+ %label n_next_positions
18
+ = f.number_field :n_next_positions
19
+ &nbsp;&nbsp;
20
+
21
+ %label summary_scale
22
+ = f.number_field :summary_scale, step: 0.0001, style: "width: 120px"
23
+
24
+ &nbsp;&nbsp;
25
+
26
+
@@ -1,22 +1,21 @@
1
1
 
2
2
  - purse ||= @purse
3
- .maxwidth
4
- .header
5
- %h5.title
6
- Purse `#{purse.slug}`
7
- = link_to '[~]', edit_purse_path(purse)
8
- = link_to '[view GameUI]', gameui_purse_path(purse)
9
- = link_to '[view]', purse_path(purse)
10
- (#{purse.positions.length})
11
3
 
12
- = link_to '[+position]', new_position_path({ purse_id: purse.id })
13
- = link_to '[+long]', new_position_path({ purse_id: purse.id, long_or_short: Iro::Strategy::LONG })
14
- = link_to '[+short]', new_position_path({ purse_id: purse.id, long_or_short: Iro::Strategy::SHORT })
4
+ .header
5
+ %h5.title
6
+ Purse `#{purse.slug}`
7
+ = link_to '[~]', edit_purse_path(purse)
8
+ = link_to '[view]', purse_path(purse)
9
+ = link_to '[gameUI]', gameui_purse_path(purse)
10
+ (#{purse.positions.length})
15
11
 
16
- - if params[:template] == 'gameui'
17
- .mini-inputs
18
- = form_for purse, html: { class: 'd-flex' } do |f|
19
- = render '/iro/purses/form_extra_fields', f: f
20
- = f.submit '>'
12
+ = link_to '[+position]', new_position_path({ purse_id: purse.id })
13
+ -# = link_to '[+long]', new_position_path({ purse_id: purse.id, long_or_short: Iro::Strategy::LONG })
14
+ = link_to '[+short]', new_position_path({ purse_id: purse.id, long_or_short: Iro::Strategy::SHORT })
21
15
 
16
+ - if true || params[:template] == 'gameui'
17
+ .mini-inputs
18
+ = form_for purse, html: { class: 'd-flex' } do |f|
19
+ = render '/iro/purses/form_extra_fields', f: f
20
+ = f.submit '>'
22
21
  %br
@@ -0,0 +1,69 @@
1
+
2
+ - u = @purse.unit
3
+ - s_mult = @purse.summary_scale
4
+ - collapse_key ||= nil
5
+
6
+ %i.fa.fa-expand.collapse-expand{ id: "pursesSummary_#{collapse_key}", style: "margin-left: -1em;" } Summary
7
+ .PurseSummaryW
8
+
9
+ .PurseSummary
10
+ -## loss
11
+ .summary-amount
12
+ .max-gl.long.loss{ style: "height: #{@max_loss_long *-1*s_mult*u}px" }
13
+ .max-gl.short.loss{ style: "height: #{@max_loss_short *-1*s_mult*u}px" }
14
+ - if @loss_long
15
+ .net-gl.loss.long.loss-long{ style: "height: #{@loss_long *-1*s_mult*u}px" }
16
+ - if @loss_short
17
+ .net-gl.loss.short.loss-short{ style: "height: #{@loss_short *-1*s_mult*u}px" }
18
+
19
+ .summary-delta
20
+ .begin.long{ style: "height: #{@begin_delta_long *s_mult*10000*u}px" }
21
+ .begin.short{ style: "height: #{@begin_delta_short *s_mult*10000*u}px" }
22
+ .end.long{ style: "height: #{@end_delta_long *s_mult*10000*u}px" }
23
+ .end.short{ style: "height: #{@end_delta_short *s_mult*10000*u}px" }
24
+
25
+ -## gain
26
+ .summary-amount
27
+ .max-gl.long.gain{ style: "height: #{@max_gain_long *s_mult*u}px" }
28
+ .max-gl.short.gain{ style: "height: #{@max_gain_short *s_mult*u}px" }
29
+ - if @gain_long
30
+ .net-gl.gain.long.gain-long{ style: "height: #{@gain_long *s_mult*u}px" }
31
+ - if @gain_short
32
+ .net-gl.gain.short.gain-short{ style: "height: #{@gain_short *s_mult*u}px" }
33
+
34
+
35
+
36
+
37
+
38
+
39
+ .legendW
40
+ .legend
41
+ %ul
42
+ %li
43
+ <b>exposure long:</b> #{pp_amount @max_loss_long *-1}
44
+ <b>short:</b> #{pp_amount @max_loss_short *-1}
45
+ %li
46
+ <b>max loss long:</b> #{pp_amount [ @max_loss_long + @max_gain_short, 0].min }
47
+ <b>short:</b> #{pp_amount [ @max_loss_short + @max_gain_long, 0].min }
48
+ %li.gray
49
+ <b>max gain long:</b> #{pp_amount @max_gain_long}
50
+ <b>short:</b> #{pp_amount @max_gain_short}
51
+
52
+ %li
53
+ %hr
54
+ <b>gain long:</b> #{pp_amount @gain_long}
55
+ <b>short:</b> #{pp_amount @gain_short}
56
+ %li
57
+ <b>loss long:</b> #{pp_amount @loss_long}
58
+ <b>short:</b> #{pp_amount @loss_short}
59
+
60
+ %li
61
+ %hr
62
+ <b>begin D long:</b> #{pp_delta @begin_delta_long}
63
+ <b>short:</b> #{pp_delta @begin_delta_short}
64
+ <b>net:</b> #{pp_delta @begin_delta_long - @begin_delta_short}
65
+ %li
66
+ <b>end D long:</b> #{pp_delta @end_delta_long}
67
+ <b>short:</b> #{pp_delta @end_delta_short}
68
+ <b>net:</b> #{pp_delta @end_delta_long - @end_delta_short}
69
+
@@ -1,12 +1,17 @@
1
1
 
2
- = render '/iro/purses/header', purse: @purse
3
-
4
2
  - u = @purse.unit
5
- .purses-gameuiW{ data: { margin: { left: u*@n_dollars } } }
6
- .purses-gameui
7
- .a
8
3
 
9
- %div{ style: "margin-left: #{u*@n_dollars}px; width: 100% " }
4
+ .purses--gameui
5
+ .row
6
+ .col-md-6
7
+ = render '/iro/purses/header', purse: @purse
8
+ .col-md-6
9
+ = render '/iro/purses/summary', purse: @purse, collapse_key: 'views-gameui'
10
+
11
+ .purses-gameuiW{ data: { margin: { left: u*@n_dollars } } }
12
+ .purses-gameui
13
+ .purses-gameuiC{ style: "margin-left: #{u*@n_dollars}px; width: 100% " }
14
+
10
15
  - @positions.each_with_index do |pos, idx|
11
16
  - if idx == 0
12
17
  %h4.maxwidth= pos.stock
@@ -15,5 +20,5 @@
15
20
  - if pos.stock != prev_.stock
16
21
  %hr
17
22
  %h4.maxwidth= pos.stock
18
- -# = pos.strategy.kind
23
+
19
24
  = render "/iro/positions/gameui_#{pos.strategy.kind}", position: pos
@@ -5,7 +5,9 @@
5
5
  %ul
6
6
  - @purses.each do |purse|
7
7
  %li
8
+ .d-inline-block= button_to 'x', purse_path(purse), method: :delete, data: { confirm: 'Are you sure?' }
8
9
  = link_to '[~]', edit_purse_path(purse)
9
10
  = link_to purse.slug, purse_path(purse)
10
11
 
11
- %li= render 'iro/purses/form', purse: Iro::Purse.new
12
+ %hr
13
+ = render 'iro/purses/form', purse: Iro::Purse.new
@@ -1,4 +1,8 @@
1
1
 
2
2
  .purses-show.padded
3
- = render '/iro/purses/header', purse: @purse
3
+ .row
4
+ .col-md-6
5
+ = render '/iro/purses/header', purse: @purse
6
+ .col-md-6
7
+ = render '/iro/purses/summary', purse: @purse, collapse_key: 'views-show'
4
8
  = render '/iro/positions/table', positions: @purse.positions
@@ -15,5 +15,10 @@
15
15
  .field
16
16
  %label Last
17
17
  = f.number_field :last, placeholder: '80.0', step: 0.01
18
+
19
+ .field
20
+ %label options price increment
21
+ = f.number_field :options_price_increment, step: 0.5
22
+
18
23
  .actions
19
24
  = f.submit