iron_warbler 2.0.7.22 → 2.0.7.24

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.txt +19 -0
  3. data/app/assets/stylesheets/iron_warbler/application.css +12 -0
  4. data/app/assets/stylesheets/iron_warbler/positions.scss +2 -0
  5. data/app/assets/stylesheets/iron_warbler/positions_gameui.scss +11 -0
  6. data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +11 -32
  7. data/app/assets/stylesheets/iron_warbler/purses_summary.scss +98 -0
  8. data/app/assets/stylesheets/iron_warbler/utils.scss +4 -0
  9. data/app/controllers/iro/alerts_controller.rb +2 -0
  10. data/app/controllers/iro/application_controller.rb +13 -0
  11. data/app/controllers/iro/positions_controller.rb +197 -23
  12. data/app/controllers/iro/purses_controller.rb +60 -6
  13. data/app/controllers/iro/stocks_controller.rb +30 -18
  14. data/app/controllers/iro/strategies_controller.rb +12 -1
  15. data/app/models/iro/alert.rb +1 -0
  16. data/app/models/iro/datapoint.rb +7 -7
  17. data/app/models/iro/option.rb +174 -3
  18. data/app/models/iro/position.rb +124 -56
  19. data/app/models/iro/purse.rb +18 -4
  20. data/app/models/iro/stock.rb +84 -0
  21. data/app/models/iro/strategy.rb +122 -27
  22. data/app/models/tda/option.rb +104 -8
  23. data/app/views/iro/_main_header.haml +28 -17
  24. data/app/views/iro/application/home.haml +6 -1
  25. data/app/views/iro/positions/_form.haml +1 -2
  26. data/app/views/iro/positions/_gameui_covered_call.haml +10 -13
  27. data/app/views/iro/positions/_gameui_covered_call.haml-bk +8 -0
  28. data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +5 -4
  29. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +5 -4
  30. data/app/views/iro/positions/_header.haml +2 -2
  31. data/app/views/iro/positions/_header_covered_call.haml +7 -1
  32. data/app/views/iro/positions/_header_long_debit_call_spread.haml +19 -1
  33. data/app/views/iro/positions/_prepare_covered_call.haml +25 -0
  34. data/app/views/iro/positions/_prepare_long_debit_call_spread.haml +23 -0
  35. data/app/views/iro/positions/_prepare_short_debit_put_spread.haml +23 -0
  36. data/app/views/iro/positions/_table.haml +33 -24
  37. data/app/views/iro/positions/prepare.haml +24 -0
  38. data/app/views/iro/positions/roll-cc.haml-bk +40 -0
  39. data/app/views/iro/positions/roll.haml-trash +42 -0
  40. data/app/views/iro/purses/_form.haml +9 -0
  41. data/app/views/iro/purses/_form_extra_fields.haml +25 -13
  42. data/app/views/iro/purses/_header.haml +15 -16
  43. data/app/views/iro/purses/_summary.haml +69 -0
  44. data/app/views/iro/purses/gameui.haml +13 -7
  45. data/app/views/iro/purses/index.haml +3 -1
  46. data/app/views/iro/purses/show.haml +5 -1
  47. data/app/views/iro/stocks/_form.haml +5 -0
  48. data/app/views/iro/stocks/_grid_is_long.haml +2 -2
  49. data/app/views/iro/stocks/_grid_is_short.haml +2 -2
  50. data/app/views/iro/stocks/index.haml +3 -2
  51. data/app/views/iro/strategies/_form.haml +12 -6
  52. data/app/views/iro/strategies/_show.haml +3 -3
  53. data/app/views/iro/strategies/_table.haml +15 -6
  54. data/app/views/iro/strategies/show.haml +14 -0
  55. data/app/views/layouts/iro/application.haml +4 -0
  56. data/config/routes.rb +6 -2
  57. data/lib/tasks/db_tasks.rake +1 -1
  58. data/lib/tasks/test_tasks.rake +54 -0
  59. metadata +28 -6
  60. data/app/models/iro/trash/position_covered_call.rb +0 -4
  61. data/app/models/iro/trash/position_debit_spread.rb +0 -251
  62. data/app/views/iro/positions/roll.haml +0 -83
  63. data/app/views/iro/positions/trash/_header_short_debit_put_spread.haml +0 -9
@@ -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  
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 } 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 } 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,18 @@
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
+
6
+ .row.padded
7
+ .col-md-6
8
+ = render '/iro/purses/header', purse: @purse
9
+ .col-md-6
10
+ = render '/iro/purses/summary', purse: @purse, collapse_key: 'views-gameui'
11
+
12
+ .purses-gameuiW{ data: { margin: { left: u*@n_dollars } } }
13
+ .purses-gameui
14
+ .purses-gameuiC{ style: "margin-left: #{u*@n_dollars}px; width: 100% " }
15
+
10
16
  - @positions.each_with_index do |pos, idx|
11
17
  - if idx == 0
12
18
  %h4.maxwidth= pos.stock
@@ -15,5 +21,5 @@
15
21
  - if pos.stock != prev_.stock
16
22
  %hr
17
23
  %h4.maxwidth= pos.stock
18
- -# = pos.strategy.kind
24
+
19
25
  = 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
@@ -1,7 +1,7 @@
1
1
 
2
2
  - nearest_strike = stock.last.round
3
- - u = @purse.unit
4
- - every_n = @purse.mark_every_n_usd
3
+ - u = position.purse.unit
4
+ - every_n = position.purse.mark_every_n_usd
5
5
 
6
6
  .grid-mark.mark0
7
7
  .label
@@ -1,7 +1,7 @@
1
1
 
2
2
  - nearest_strike = stock.last.round
3
- - u = @purse.unit
4
- - every_n = @purse.mark_every_n_usd
3
+ - u = position.purse.unit
4
+ - every_n = position.purse.mark_every_n_usd
5
5
 
6
6
  .grid-mark.mark0
7
7
  .label
@@ -1,6 +1,7 @@
1
1
 
2
- .stocks--index
3
- %h5 Stocks [+]
2
+ .stocks--index.padded
3
+ .maxwidth
4
+ %h5 Stocks
4
5
 
5
6
  %ul
6
7
  - @stocks.each do |stock|
@@ -8,6 +8,9 @@
8
8
  .field
9
9
  %label Kind
10
10
  = f.select :kind, options_for_select( Iro::Strategy::KINDS, selected: strategy.kind )
11
+ .field
12
+ %label stock
13
+ = f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
11
14
  .field
12
15
  %label slug
13
16
  = f.text_field :slug
@@ -19,15 +22,18 @@
19
22
  .field
20
23
  = f.label :buffer_above_water
21
24
  = f.number_field :buffer_above_water, placeholder: "0.49", step: 0.01
25
+ -# .field
26
+ -# = f.label :next_max_outer_delta
27
+ -# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
22
28
  .field
23
- = f.label :next_max_outer_delta
24
- = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
29
+ = f.label :next_inner_delta
30
+ = f.number_field :next_inner_delta, placeholder: "0.25", step: 0.01
25
31
  .field
26
- = f.label :next_max_inner_delta
27
- = f.number_field :next_max_inner_delta, placeholder: "0.25", step: 0.01
32
+ = f.label :next_inner_strike
33
+ = f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
28
34
  .field
29
- = f.label :next_min_strike
30
- = f.number_field :next_min_strike, placeholder: "20.0", step: 0.01
35
+ = f.label :next_spread_amount
36
+ = f.number_field :next_spread_amount, placeholder: "20", step: 0.1
31
37
  .field
32
38
  = f.label :threshold_delta
33
39
  = f.number_field :threshold_delta, placeholder: "0.14", step: 0.01
@@ -10,9 +10,9 @@
10
10
 
11
11
  %li <b>buffer_above_water:</b> #{strategy.buffer_above_water}
12
12
 
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}
15
- %li <b>next_min_strike:</b> #{strategy.next_min_strike}
13
+ %li <b>next_inner_delta:</b> #{strategy.next_inner_delta}
14
+ -# %li <b>next_outer_delta:</b> #{strategy.next_max_outer_delta}
15
+ %li <b>next_inner_strike:</b> #{strategy.next_inner_strike}
16
16
 
17
17
  %li <b>threshold_delta:</b> #{strategy.threshold_delta}
18
18
  %li <b>threshold_netp:</b> #{strategy.threshold_netp}
@@ -9,16 +9,25 @@
9
9
  %th.actions &nbsp;
10
10
  %th kind
11
11
  %th slug
12
- %th next_max_inner_delta
12
+ %th next_inner_delta
13
+ %th.actions &nbsp;
13
14
  %tbody
14
15
  - strategies.each do |sss|
15
16
  %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?' }
17
+ %td.actions
18
+ .d-flex
19
+ = link_to '[~]', edit_strategy_path(sss)
20
+ = button_to 'x', strategy_path(sss), method: :delete, data: { confirm: 'Are you sure?' }
19
21
  %td= sss.kind
20
- %td= sss.slug
21
- %td= sss.next_max_inner_delta
22
+ %td= link_to sss.slug, strategy_path(sss)
23
+ %td= sss.next_inner_delta
24
+ %td
25
+ = form_tag propose_position_path do
26
+ = hidden_field_tag :strategy_id, sss.id
27
+ .d-flex
28
+ %label new position for
29
+ = select_tag :purse_id, options_for_select(@purses_list), class: 'select2'
30
+ = submit_tag 'Go'
22
31
 
23
32
  .h-50px
24
33
 
@@ -0,0 +1,14 @@
1
+
2
+ .strategies-show.maxwidth
3
+ .header
4
+ %h5.title Strategy #{@strategy}
5
+ %ul
6
+ -# %li Purse #{@strategy.purses}
7
+ -# %li= link_to 'Next position', strategy_next_position_path(@strategy)
8
+
9
+ .row
10
+ .col-md-6
11
+ = render '/iro/strategies/form', strategy: @strategy
12
+ .col-md-6
13
+ %h5 Next Position:
14
+
@@ -48,6 +48,10 @@
48
48
 
49
49
  %span.absolute.collapse-expand#mainW
50
50
  = yield
51
+ %br
52
+ %br
51
53
 
52
54
  = render '/wco/main_footer'
53
55
  = render '/iro/analytics' if Rails.env.production?
56
+ %br
57
+ %br
data/config/routes.rb CHANGED
@@ -9,8 +9,10 @@ Iro::Engine.routes.draw do
9
9
 
10
10
  resources :option_watches
11
11
 
12
- get 'positions/:id/roll', to: 'positions#roll', as: :roll_position
13
- post 'positions/:id/roll', to: 'positions#do_roll'
12
+ get 'positions/duplicate/:id', to: 'positions#new', as: :duplicate_position
13
+ post 'positions/propose', to: 'positions#propose', as: :propose_position
14
+ get 'positions/:id/prepare', to: 'positions#prepare', as: :prepare_to_roll_position, defaults: { template: 'gameui' }
15
+ post 'positions/:id/roll', to: 'positions#do_roll', as: :roll_position
14
16
  get 'positions/:id/refresh', to: 'positions#refresh', as: :refresh_position
15
17
  resources :positions
16
18
  resources :profiles
@@ -19,7 +21,9 @@ Iro::Engine.routes.draw do
19
21
  get 'purses/:id', to: 'purses#show', as: :purse, defaults: { template: 'show' }
20
22
  resources :purses
21
23
 
24
+ get 'stocks/refresh', to: 'stocks#refresh', as: :refresh_stocks
22
25
  resources :stocks
26
+
23
27
  resources :strategies
24
28
 
25
29
  namespace :api do
@@ -1,7 +1,7 @@
1
1
 
2
2
  namespace :db do
3
3
 
4
- ## date, volume, open, high, low, close
4
+ ## Date, Volume, Open, High, Low, Close
5
5
  desc 'import_stock symbol=GME path=./data/GME-test.csv'
6
6
  task import_stock: :environment do
7
7
  Iro::Datapoint.import_stock( symbol: ENV['symbol'], path: ENV['path'] )