iron_warbler 2.0.7.19 → 2.0.7.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) 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 +24 -5
  6. data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +214 -0
  7. data/app/assets/stylesheets/iron_warbler/purses_gameui.scss-bk +112 -0
  8. data/app/assets/stylesheets/iron_warbler/utils.scss +81 -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 +35 -4
  12. data/app/controllers/iro/purses_controller.rb +11 -4
  13. data/app/controllers/iro/strategies_controller.rb +7 -7
  14. data/app/helpers/iro/application_helper.rb +5 -2
  15. data/app/jobs/tda_job.rb +14 -0
  16. data/app/models/iro/datapoint.rb +48 -8
  17. data/app/models/iro/position.rb +55 -14
  18. data/app/models/iro/price_item.rb +51 -1
  19. data/app/models/iro/purse.rb +4 -0
  20. data/app/models/iro/stock.rb +5 -2
  21. data/app/models/iro/strategy.rb +84 -10
  22. data/app/models/iro/trash/position_covered_call.rb +4 -0
  23. data/app/models/iro/trash/position_debit_spread.rb +251 -0
  24. data/app/models/tda/option.rb +7 -7
  25. data/app/views/iro/_main_header.haml +18 -17
  26. data/app/views/iro/api/stocks/show.jbuilder +11 -0
  27. data/app/views/iro/positions/_form.haml +11 -38
  28. data/app/views/iro/positions/_formpart_4data.haml +46 -0
  29. data/app/views/iro/positions/_gameui_covered_call.haml +44 -0
  30. data/app/views/iro/positions/_gameui_covered_call.haml-bk +59 -0
  31. data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +37 -0
  32. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +39 -0
  33. data/app/views/iro/positions/_header.haml +6 -0
  34. data/app/views/iro/positions/_header_covered_call.haml +6 -0
  35. data/app/views/iro/positions/_header_long_debit_call_spread.haml +14 -0
  36. data/app/views/iro/positions/_header_short_debit_put_spread.haml +1 -0
  37. data/app/views/iro/positions/_table.haml +120 -123
  38. data/app/views/iro/positions/roll.haml +83 -0
  39. data/app/views/iro/positions/trash/_header_short_debit_put_spread.haml +9 -0
  40. data/app/views/iro/purses/_form.haml +1 -0
  41. data/app/views/iro/purses/_form_extra_fields.haml +14 -0
  42. data/app/views/iro/purses/_header.haml +22 -0
  43. data/app/views/iro/purses/gameui.haml +19 -0
  44. data/app/views/iro/purses/gameui.haml-bk +44 -0
  45. data/app/views/iro/purses/gameui.haml-bk2 +89 -0
  46. data/app/views/iro/purses/show.haml +1 -7
  47. data/app/views/iro/stocks/_grid_is_long.haml +16 -0
  48. data/app/views/iro/stocks/_grid_is_short.haml +16 -0
  49. data/app/views/iro/strategies/_form.haml +12 -5
  50. data/app/views/iro/strategies/_show.haml +3 -2
  51. data/app/views/iro/strategies/_table.haml +16 -10
  52. data/app/views/iro/strategies/index.haml +8 -0
  53. data/app/views/layouts/iro/application.haml +1 -1
  54. data/config/routes.rb +15 -1
  55. data/lib/iro/engine.rb +2 -0
  56. data/lib/tasks/db_tasks.rake +9 -3
  57. metadata +31 -8
  58. data/app/assets/stylesheets/iron_warbler/alerts.css +0 -8
  59. data/app/assets/stylesheets/iron_warbler/datapoints.css +0 -0
  60. data/app/assets/stylesheets/iron_warbler/profiles.css +0 -4
  61. data/app/assets/stylesheets/iron_warbler/strategies.scss +0 -0
  62. data/app/assets/stylesheets/iron_warbler/utils.css +0 -44
  63. data/app/jobs/iro/application_job.rb-trash +0 -4
@@ -0,0 +1 @@
1
+ app/views/iro/positions/_header_long_debit_call_spread.haml
@@ -3,131 +3,128 @@
3
3
 
4
4
  %h5 Positions
5
5
  %table.bordered
6
- %tr
7
- %th  
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  
120
- -# %td.end_on  
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  
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 Max Loss
23
+ %th.max-gain Max 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.kind, 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
+ = 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
66
+
67
+
68
+ %td.status.strategy.w-200px
69
+ = position.status
70
+ %br
71
+ = position.expires_on.to_datetime.strftime("%b %d")
72
+ [#{ ( position.expires_on.to_date - Time.now.to_date ).to_i } DTE]
73
+ %br
74
+ %i.fa.fa-compress.collapse-expand{ id: "ce-pos-reasons-#{position.id}" }
75
+ #{position.strategy}
76
+ = render '/iro/strategies/show', strategy: position.strategy
77
+
78
+ %td.ticker
79
+ = position.stock.ticker
80
+ <b>(#{position.quantity})</b>
81
+ %br
82
+ = pp_amount position.stock.last
83
+ %td.strikes
84
+ .long-or-short-item
85
+ .outer-strike= pp_amount position.outer_strike
86
+ .inner-strike= pp_amount position.inner_strike
87
+
88
+ %td.begin_price
89
+ .long-or-short-item
90
+ .begin-outer-price
91
+ = pp_amount position.begin_outer_price
92
+ <b>D</b> #{pp_delta position.begin_outer_delta}
93
+ .begin-inner-price
94
+ = pp_amount position.begin_inner_price
95
+ <b>D</b> #{pp_delta position.begin_inner_delta}
96
+ %td
97
+ .max-loss= pp_amount position.max_loss * pos.q, precision: 0
98
+ %td
99
+ .max-gain= pp_amount position.max_gain * pos.q, precision: 0
100
+ .max-gainp
101
+ -# = pp_percent( -1 * position.max_gain / position.max_loss ) rescue '-' # undef. for covered calls
102
+
103
+ %td.end_price
104
+ .long-or-short-item
105
+ .end-outer-price
106
+ = pp_amount position.end_outer_price
107
+ <b>D</b> #{pp_delta position.end_outer_delta}
108
+ .end-inner-price
109
+ = pp_amount position.end_inner_price
110
+ <b>D</b> #{pp_delta position.end_inner_delta}
111
+ %td.net
112
+ .a= pp_amount position.net_amount * pos.q, precision: 0 rescue '@TODO'
113
+ .a <i>#{pp_percent position.net_amount / position.max_gain rescue '@TODO'}</i>
114
+ %td.breakeven
115
+ = pp_amount pos.breakeven rescue '@TODO'
116
+
117
+
118
+
119
+ %td.should_rollp
120
+ <i> #{pp_percent position.should_rollp rescue '?'}</i>
121
+ %td.next_position.mini
122
+ .a= position.next_symbol
123
+ .a= position.next_delta
124
+ .a
125
+ = pp_amount position.next_mark
126
+ \=>
127
+ = pp_amount position.next_outcome * 100 * position.quantity rescue nil
131
128
 
132
129
 
133
130
 
@@ -0,0 +1,83 @@
1
+
2
+ - u = @purse.unit # 50 ## pixels per dollar
3
+ - strategy = @position.strategy
4
+
5
+ .purses-gameui.padded
6
+ = render '/iro/purses/header', purse: @position.purse
7
+
8
+ .a
9
+ - position = @position
10
+ - stock = position.stock
11
+ %h4= stock
12
+
13
+ .header
14
+ = position.quantity
15
+ = stock
16
+ = position.expires_on.to_datetime.strftime("%b %d")
17
+ = link_to '[roll]', roll_position_path(position)
18
+ = link_to '[~]', edit_position_path(position)
19
+
20
+ - nearest_strike = stock.last.round
21
+ .StockCoordinatesW
22
+
23
+ .StockCoordinates
24
+ .grid-mark.mark0
25
+ .label= nearest_strike
26
+ - (1...@n_dollars).each_with_index do |idx|
27
+ .grid-mark{ class: "mark#{idx}", style: "left: -#{idx * u}px" }
28
+ .label
29
+ = nearest_strike + idx
30
+ .grid-mark{ class: "mark-#{idx}", style: "left: #{idx * u}px" }
31
+ .label
32
+ = nearest_strike - idx
33
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
34
+ .label
35
+ Last:
36
+ = stock.last
37
+
38
+
39
+ .PositionW{ style: "width: #{ position.begin_inner_price * u}px; left: #{ (stock.last - position.inner_strike - position.begin_inner_price) * u}px" }
40
+
41
+ .Position
42
+ - if position.net_amount >= 0
43
+ .Net.NetPositive{ style: "width: #{ (position.net_amount / 100) * u }px; right: 0" }
44
+ .label
45
+ net
46
+ = pp_amount position.net_amount
47
+ - else
48
+ .Net.NetNegative{ style: "width: #{ (-1 * position.net_amount / 100) * u }px; left: 100%" }
49
+ .label
50
+ net
51
+ = pp_amount position.net_amount
52
+ .c
53
+
54
+ - @positions.each do |position|
55
+ .reviewing
56
+ - stock = position.stock
57
+ - nearest_strike = stock.last.round
58
+ .StockCoordinatesW
59
+ .StockCoordinates
60
+ .grid-mark.mark0
61
+ .label= nearest_strike
62
+ - (1...@n_dollars).each_with_index do |idx|
63
+ .grid-mark{ class: "mark#{idx}", style: "left: -#{idx * u}px" }
64
+ .label
65
+ = nearest_strike + idx
66
+ .grid-mark{ class: "mark-#{idx}", style: "left: #{idx * u}px" }
67
+ .label
68
+ = nearest_strike - idx
69
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
70
+ .label
71
+ Last:
72
+ = stock.last
73
+ - amnt = position.gain_loss_amount
74
+ - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
75
+ .PositionW{ style: "width: #{ position.begin_inner_price * u}px; left: #{ (stock.last - position.inner_strike - position.begin_inner_price) * u}px; border: #{border}; border-bottom-width: 2px" }
76
+ .Position
77
+ .c
78
+
79
+
80
+
81
+
82
+ %br
83
+ %br
@@ -0,0 +1,9 @@
1
+
2
+ .maxwidth
3
+ %ul.m-0.p-0
4
+ %li <b>outer,inner_strike:</b> #{pp_amount pos.outer_strike} -> #{pp_amount pos.inner_strike}
5
+ %li
6
+ <b>begin_outer,inner_price:</b> #{pp_amount pos.begin_outer_price} -> #{pp_amount pos.begin_inner_price}
7
+ &nbsp;&nbsp;
8
+ <b>max gain:</b> #{pp_amount pos.max_gain}
9
+ %li <b>Net:</b> #{pp_amount pos.net_amount} &nbsp;&nbsp; <i>#{pp_percent pos.net_percent}</i>
@@ -5,5 +5,6 @@
5
5
  .field
6
6
  %label Slug
7
7
  = f.text_field :slug
8
+ = render '/iro/purses/form_extra_fields', f: f
8
9
  .actions
9
10
  = f.submit
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,22 @@
1
+
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
+
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 })
15
+
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 '>'
21
+
22
+ %br
@@ -0,0 +1,19 @@
1
+
2
+ = render '/iro/purses/header', purse: @purse
3
+
4
+ - u = @purse.unit
5
+ .purses-gameuiW{ data: { margin: { left: u*@n_dollars } } }
6
+ .purses-gameui
7
+ .a
8
+
9
+ %div{ style: "margin-left: #{u*@n_dollars}px; width: 100% " }
10
+ - @positions.each_with_index do |pos, idx|
11
+ - if idx == 0
12
+ %h4.maxwidth= pos.stock
13
+ - else
14
+ - prev_ = @positions[idx-1]
15
+ - if pos.stock != prev_.stock
16
+ %hr
17
+ %h4.maxwidth= pos.stock
18
+ -# = pos.strategy.kind
19
+ = render "/iro/positions/gameui_#{pos.strategy.kind}", position: pos
@@ -0,0 +1,44 @@
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
+
8
+ - @positions.each_with_index do |position, idx|
9
+ .CoordinatesW
10
+ .Origin
11
+ .Coordinates
12
+ -# .Coordinates{ style: "left: #{ (position.inner_strike - position.stock.last) * u }px" }
13
+ .grid-mark.mark0.origin
14
+ .label
15
+ Begin strike:
16
+ = position.inner_strike
17
+
18
+ - (1...grid_size).each_with_index do |idx|
19
+ .grid-mark{ class: "mark#{idx}", style: "left: #{idx * u}px" }
20
+ .label
21
+ = position.inner_strike + idx
22
+ .grid-mark{ class: "mark-#{idx}", style: "left: -#{idx * u}px" }
23
+ .label
24
+ = position.inner_strike - idx
25
+
26
+ .Net{ style: "width: #{ (position.net_amount / 100) * u }px" }
27
+ .label
28
+ Net:
29
+ = pp_amount position.net_amount
30
+
31
+ .marker.sprite-bottom.Breakeven{ style: "width: #{ (position.begin_inner_price) * u }px" }
32
+ .half-circle
33
+ .label.hide
34
+ Breakeven:
35
+ = position.inner_strike + position.begin_inner_price
36
+
37
+ .marker.Last{ style: "left: #{ (position.stock.last - position.inner_strike) * u }px" }
38
+ .label
39
+ Last:
40
+ = position.stock.last
41
+
42
+
43
+ %br
44
+ %br
@@ -0,0 +1,89 @@
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
+
8
+ -# - @positions.map &:id
9
+ - @positions.each_with_index do |position, idx|
10
+ - stock = position.stock
11
+ - if idx == 0
12
+ %h4= stock
13
+ - else
14
+ - prev_ = @positions[idx-1]
15
+ - if stock != prev_.stock
16
+ %hr
17
+ %h4= stock
18
+
19
+
20
+
21
+
22
+ .header
23
+ = position.quantity
24
+ = stock
25
+ = position.expires_on.to_datetime.strftime("%b %d")
26
+ = link_to '[roll]', roll_position_path(position)
27
+ = link_to '[~]', edit_position_path(position)
28
+
29
+ - nearest_strike = stock.last.round
30
+ - # for Mu ( positions in one stock )
31
+ .StockCoordinatesW
32
+
33
+ .StockCoordinates
34
+ .grid-mark.mark0
35
+ .label= nearest_strike
36
+ - (1...grid_size).each_with_index do |idx|
37
+ .grid-mark{ class: "mark#{idx}", style: "left: -#{idx * u}px" }
38
+ .label
39
+ = nearest_strike + idx
40
+ .grid-mark{ class: "mark-#{idx}", style: "left: #{idx * u}px" }
41
+ .label
42
+ = nearest_strike - idx
43
+ .Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
44
+ .label
45
+ Last:
46
+ = stock.last
47
+
48
+
49
+ .PositionW{ style: "width: #{ position.begin_inner_price * u}px; left: #{ (stock.last - position.inner_strike - position.begin_inner_price) * u}px" }
50
+
51
+ .Position
52
+ -# .label
53
+ -# BeginStrike:
54
+ -# = position.inner_strike
55
+ -# .label
56
+ -# begin inner price:
57
+ -# = position.begin_inner_price
58
+ - if position.net_amount >= 0
59
+ .Net.NetPositive{ style: "width: #{ (position.net_amount / 100) * u }px; right: 0" }
60
+ .label
61
+ net
62
+ = pp_amount position.net_amount
63
+ - else
64
+ .Net.NetNegative{ style: "width: #{ (-1 * position.net_amount / 100) * u }px; left: 100%" }
65
+ .label
66
+ net
67
+ = pp_amount position.net_amount
68
+
69
+
70
+ -# .label
71
+ -# net:
72
+ -# = pp_amount position.net_amount
73
+
74
+ -# .BeginInnerPrice
75
+ -# .label
76
+ -# Begin Inner Price:
77
+ -# = pp_amount position.begin_inner_price
78
+
79
+ -# .marker.sprite-bottom.Breakeven{ style: "width: #{ (position.begin_inner_price) * u }px" }
80
+ -# .half-circle
81
+ -# .label.hide
82
+ -# Breakeven:
83
+ -# = position.inner_strike + position.begin_inner_price
84
+
85
+
86
+
87
+
88
+ %br
89
+ %br
@@ -1,10 +1,4 @@
1
1
 
2
2
  .purses-show.padded
3
-
4
- .maxwidth
5
- .header
6
- %h5.title Purse `#{@purse.slug}` (#{@purse.positions.length})
7
- %ul.menu-secondary
8
- %li= link_to '[+position]', new_position_path({ purse_id: @purse.id })
9
-
3
+ = render '/iro/purses/header', purse: @purse
10
4
  = render '/iro/positions/table', positions: @purse.positions
@@ -0,0 +1,16 @@
1
+
2
+ - nearest_strike = stock.last.round
3
+ - u = @purse.unit
4
+ - every_n = @purse.mark_every_n_usd
5
+
6
+ .grid-mark.mark0
7
+ .label
8
+ .labelC= nearest_strike
9
+ - (1...@n_dollars).each_with_index do |idx|
10
+ - idx = idx * every_n
11
+ .grid-mark{ class: "mark#{idx}", style: "left: #{idx * u}px" }
12
+ .label
13
+ .labelC= nearest_strike + idx
14
+ .grid-mark{ class: "mark-#{idx}", style: "left: -#{idx * u}px" }
15
+ .label
16
+ .labelC= nearest_strike - idx
@@ -0,0 +1,16 @@
1
+
2
+ - nearest_strike = stock.last.round
3
+ - u = @purse.unit
4
+ - every_n = @purse.mark_every_n_usd
5
+
6
+ .grid-mark.mark0
7
+ .label
8
+ .labelC= nearest_strike
9
+ - (1...@n_dollars).each_with_index do |idx|
10
+ - idx = idx * every_n
11
+ .grid-mark{ class: "mark#{idx}", style: "left: -#{idx * u}px" }
12
+ .label
13
+ .labelC= nearest_strike + idx
14
+ .grid-mark{ class: "mark-#{idx}", style: "left: #{idx * u}px" }
15
+ .label
16
+ .labelC= nearest_strike - idx
@@ -4,20 +4,27 @@
4
4
  .actions
5
5
  = f.submit
6
6
 
7
- .field
8
- %label Ticker
9
- = f.select :ticker, options_for_select( @tickers_list, selected: strategy.ticker )
10
7
 
8
+ .field
9
+ %label Kind
10
+ = f.select :kind, options_for_select( Iro::Strategy::KINDS, selected: strategy.kind )
11
11
  .field
12
12
  %label slug
13
13
  = f.text_field :slug
14
+ .field
15
+ %label long or short?
16
+ = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
17
+
14
18
 
15
19
  .field
16
20
  = f.label :buffer_above_water
17
21
  = f.number_field :buffer_above_water, placeholder: "0.49", step: 0.01
18
22
  .field
19
- = f.label :next_max_delta
20
- = f.number_field :next_max_delta, placeholder: "0.25", step: 0.01
23
+ = f.label :next_max_outer_delta
24
+ = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
25
+ .field
26
+ = f.label :next_max_inner_delta
27
+ = f.number_field :next_max_inner_delta, placeholder: "0.25", step: 0.01
21
28
  .field
22
29
  = f.label :next_min_strike
23
30
  = f.number_field :next_min_strike, placeholder: "20.0", step: 0.01
@@ -5,12 +5,13 @@
5
5
  = link_to '[~]', edit_strategy_path(strategy)
6
6
  = strategy
7
7
  %ul
8
- %li <b>ticker:</b> #{strategy.ticker}
8
+ -# %li <b>ticker:</b> #{strategy.ticker}
9
9
  %li <b>slug:</b> #{strategy.slug}
10
10
 
11
11
  %li <b>buffer_above_water:</b> #{strategy.buffer_above_water}
12
12
 
13
- %li <b>next_max_delta:</b> #{strategy.next_max_delta}
13
+ %li <b>next_max_inner_delta:</b> #{strategy.next_max_inner_delta}
14
+ %li <b>next_max_outer_delta:</b> #{strategy.next_max_outer_delta}
14
15
  %li <b>next_min_strike:</b> #{strategy.next_min_strike}
15
16
 
16
17
  %li <b>threshold_delta:</b> #{strategy.threshold_delta}
@@ -4,15 +4,21 @@
4
4
  .strategies--table
5
5
 
6
6
  %table.bordered
7
- %tr
8
- %th &nbsp;
9
- %th ticker
10
- %th slug
11
- %th next_max_delta
12
- - strategies.each do |sss|
7
+ %thead
13
8
  %tr
14
- %td= link_to '[~]', edit_strategy_path(sss)
15
- %td= sss.ticker
16
- %td= sss.slug
17
- %td= sss.next_max_delta
9
+ %th.actions &nbsp;
10
+ %th kind
11
+ %th slug
12
+ %th next_max_inner_delta
13
+ %tbody
14
+ - strategies.each do |sss|
15
+ %tr
16
+ %td.actions.d-flex
17
+ = link_to '[~]', edit_strategy_path(sss)
18
+ = button_to 'x', strategy_path(sss), method: :delete, data: { confirm: 'Are you sure?' }
19
+ %td= sss.kind
20
+ %td= sss.slug
21
+ %td= sss.next_max_inner_delta
22
+
23
+ .h-50px
18
24