iron_warbler 2.0.7.25 → 2.0.7.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/iron_warbler/Card.scss +6 -0
  3. data/app/assets/stylesheets/iron_warbler/positions.scss +1 -1
  4. data/app/assets/stylesheets/iron_warbler/purses.scss +31 -0
  5. data/app/assets/stylesheets/iron_warbler/purses_summary.scss +31 -19
  6. data/app/assets/stylesheets/iron_warbler/utils.scss +28 -3
  7. data/app/controllers/iro/api/stocks_controller.rb +7 -4
  8. data/app/controllers/iro/application_controller.rb +6 -0
  9. data/app/controllers/iro/positions_controller.rb +188 -199
  10. data/app/controllers/iro/purses_controller.rb +3 -1
  11. data/app/controllers/iro/stocks_controller.rb +21 -2
  12. data/app/models/iro/datapoint.rb +1 -1
  13. data/app/models/iro/option.rb +50 -150
  14. data/app/models/iro/option_black_scholes.rb +149 -0
  15. data/app/models/iro/position.rb +155 -212
  16. data/app/models/iro/{price_item.rb → priceitem.rb} +5 -1
  17. data/app/models/iro/purse.rb +41 -4
  18. data/app/models/iro/stock.rb +2 -0
  19. data/app/models/iro/strategy.rb +121 -82
  20. data/app/models/tda/option.rb +1 -1
  21. data/app/models/tda/stock.rb +1 -1
  22. data/app/views/iro/_main_header.haml +8 -5
  23. data/app/views/iro/api/stocks/index.json.jbuilder +5 -0
  24. data/app/views/iro/api/stocks/show.json.jbuilder +11 -0
  25. data/app/views/iro/api/stocks/show.json.jbuilder-bk +12 -0
  26. data/app/views/iro/options/_show_mini.haml +8 -0
  27. data/app/views/iro/positions/_form.haml +11 -4
  28. data/app/views/iro/positions/_formpart_4data.haml +41 -38
  29. data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +4 -4
  30. data/app/views/iro/positions/_gameui_long_debit_call_spread.haml-trash +42 -0
  31. data/app/views/iro/positions/_gameui_short_credit_call_spread.haml +38 -0
  32. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +1 -0
  33. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml-trash +40 -0
  34. data/app/views/iro/positions/_header.haml +2 -0
  35. data/app/views/iro/positions/_header_long_debit_call_spread.haml +43 -25
  36. data/app/views/iro/positions/_header_short_credit_call_spread.haml +50 -0
  37. data/app/views/iro/positions/_new.haml +23 -0
  38. data/app/views/iro/positions/_prepare_long_debit_call_spread.haml +2 -3
  39. data/app/views/iro/positions/_prepare_short_credit_call_spread.haml +1 -0
  40. data/app/views/iro/positions/_prepare_short_debit_put_spread.haml +2 -1
  41. data/app/views/iro/positions/_table.haml +25 -26
  42. data/app/views/iro/positions/prepare.haml +6 -4
  43. data/app/views/iro/positions/prepare2.haml +15 -4
  44. data/app/views/iro/purses/_form_extra_fields.haml +18 -18
  45. data/app/views/iro/purses/_header.haml +12 -7
  46. data/app/views/iro/purses/_summary.haml +69 -62
  47. data/app/views/iro/purses/show.haml +4 -3
  48. data/app/views/iro/stocks/_form.haml +4 -3
  49. data/app/views/iro/stocks/edit.haml +4 -0
  50. data/app/views/iro/stocks/index.haml +21 -6
  51. data/app/views/iro/strategies/_form.haml +36 -26
  52. data/app/views/iro/strategies/_show.haml +7 -5
  53. data/config/routes.rb +7 -4
  54. data/lib/iro/engine.rb +1 -0
  55. data/lib/iron_warbler.rb +0 -2
  56. data/lib/tasks/iro_tasks.rake +2 -2
  57. metadata +17 -4
  58. data/app/views/iro/api/stocks/show.jbuilder +0 -11
  59. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +0 -40
@@ -2,5 +2,7 @@
2
2
  .positions--header.maxwidth
3
3
  = pos
4
4
  = link_to '[roll]', prepare_to_roll_position_path(pos) if pos.persisted?
5
+ -# .d-inline-block= button_to 'close', close_position_path(pos), data: { confirm: 'Are you sure?' }
6
+ = link_to '[close]', close_position_path(pos)
5
7
  = link_to '[~]', edit_position_path(pos) if pos.persisted?
6
8
  -# = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
@@ -1,32 +1,50 @@
1
1
 
2
-
2
+ -##
3
3
  -## Same file for the spreads
4
+ -##
5
+
4
6
  - collapse_key ||= pos.id
5
7
  %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{collapse_key}" }
6
8
  .maxwidth
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}
9
+
10
+ %table.bordered{ class: pos.long_or_short }
11
+ %tbody.long-or-short-item
12
+ %tr
13
+ %td <b>#{pp_amount pos.outer.strike}</b>
14
+ %td= pp_amount pos.outer.begin_price
15
+ %td= pos.outer.begin_delta
16
+ %td &nbsp;-&nbsp;
17
+ %td= pp_amount pos.outer.end_price
18
+ %td= pp_delta pos.outer.end_delta
19
+ %tr
20
+ %td <b>#{pp_amount pos.inner.strike}</b>
21
+ %td= pp_amount pos.inner.begin_price
22
+ %td= pp_delta pos.inner.begin_delta
23
+ %td &nbsp;-&nbsp;
24
+ %td= pp_amount pos.inner.end_price
25
+ %td= pp_delta pos.inner.end_delta
26
+
27
+ .header.d-flex
28
+ %ul.mb-0
29
+ %li
30
+ -## yes *100
31
+ <b>max gain:</b> #{pp_amount pos.max_gain} :: #{pp_amount pos.max_gain * 100 * pos.q}
32
+ -# %li
33
+ -# <b>end_outer,inner_price:</b> #{pp_amount pos.end_outer_price} -> #{pp_amount pos.end_inner_price}
34
+ -# &nbsp;&nbsp;
35
+ -# -## yes *100
36
+ -# <b>max loss:</b> #{pp_amount pos.max_loss} :: #{pp_amount pos.max_loss * 100 * pos.q}
37
+
38
+ %li
39
+ <b>Exposure:</b> #{pp_amount pos.max_loss() *100*pos.q()}
11
40
  %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>
41
+ <b>Breakeven:</b> #{pp_amount pos.inner.strike + pos.max_gain()}
42
+ - ## no *100
43
+ %li <b>Net:</b> #{pp_amount pos.net_amount} :: #{pp_amount pos.net_amount() *100*pos.q} &nbsp;&nbsp; <i>#{pp_percent pos.net_percent}</i>
15
44
 
16
- %li <b>outer,inner_strike:</b> #{pp_amount pos.outer_strike} -> #{pp_amount pos.inner_strike}
17
- %li
18
- <b>begin_outer,inner_price:</b> #{pp_amount pos.begin_outer_price} -> #{pp_amount pos.begin_inner_price}
19
- &nbsp;&nbsp;
20
- -## yes *100
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}
31
- - ## no *100
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>
45
+ - if 'prepare' == pos.status
46
+ %ul.mb-0
47
+ %li
48
+ <b>next_gain_loss_amount:</b> #{pp_amount pos.next_gain_loss_amount}
49
+ \:: #{pp_amount pos.next_gain_loss_amount * 100 * pos.q}
50
+ &nbsp;&nbsp; <i>#{pp_percent pos.next_gain_loss_amount/pos.max_loss*-1}</i>
@@ -0,0 +1,50 @@
1
+
2
+ -##
3
+ -## Same file for the spreads
4
+ -##
5
+
6
+ - collapse_key ||= pos.id
7
+ %i.fa.fa-expand.collapse-expand.floaty-collapse{ id: "gameui-pos-detail-#{collapse_key}" }
8
+ .maxwidth
9
+
10
+ %table.bordered{ class: pos.long_or_short }
11
+ %tbody.long-or-short-item
12
+ %tr
13
+ %td <b>#{pp_amount pos.outer.strike}</b>
14
+ %td= pp_amount pos.outer.begin_price
15
+ %td= pos.outer.begin_delta
16
+ %td &nbsp;-&nbsp;
17
+ %td= pp_amount pos.outer.end_price
18
+ %td= pp_delta pos.outer.end_delta
19
+ %tr
20
+ %td <b>#{pp_amount pos.inner.strike}</b>
21
+ %td= pp_amount pos.inner.begin_price
22
+ %td= pp_delta pos.inner.begin_delta
23
+ %td &nbsp;-&nbsp;
24
+ %td= pp_amount pos.inner.end_price
25
+ %td= pp_delta pos.inner.end_delta
26
+
27
+ .header.d-flex
28
+ %ul.mb-0
29
+ %li
30
+ -## yes *100
31
+ <b>max gain:</b> #{pp_amount pos.max_gain} :: #{pp_amount pos.max_gain * 100 * pos.q}
32
+ -# %li
33
+ -# <b>end_outer,inner_price:</b> #{pp_amount pos.end_outer_price} -> #{pp_amount pos.end_inner_price}
34
+ -# &nbsp;&nbsp;
35
+ -# -## yes *100
36
+ -# <b>max loss:</b> #{pp_amount pos.max_loss} :: #{pp_amount pos.max_loss * 100 * pos.q}
37
+
38
+ %li
39
+ <b>Exposure:</b> #{pp_amount pos.max_loss() *100*pos.q()}
40
+ %li
41
+ <b>Breakeven:</b> #{pp_amount pos.inner.strike + pos.max_gain()}
42
+ - ## no *100
43
+ %li <b>Net:</b> #{pp_amount pos.net_amount} :: #{pp_amount pos.net_amount() *100*pos.q} &nbsp;&nbsp; <i>#{pp_percent pos.net_percent}</i>
44
+
45
+ - if 'prepare' == pos.status
46
+ %ul.mb-0
47
+ %li
48
+ <b>next_gain_loss_amount:</b> #{pp_amount pos.next_gain_loss_amount}
49
+ \:: #{pp_amount pos.next_gain_loss_amount * 100 * pos.q}
50
+ &nbsp;&nbsp; <i>#{pp_percent pos.next_gain_loss_amount/pos.max_loss*-1}</i>
@@ -0,0 +1,23 @@
1
+
2
+ .d-flex
3
+ .Card
4
+ = form_for Iro::Position.new(strategy: Iro::Strategy.new), url: new_position_path, method: :get do |f|
5
+ = hidden_field_tag 'position[purse_id]', purse.id
6
+
7
+ .formrow-v1
8
+ .label +Position
9
+
10
+ .d-flex.flex-column
11
+ %label Strategy
12
+ = f.select :strategy_id, options_for_select(@strategies_list)
13
+
14
+ .d-flex.flex-column
15
+ %label Expires on
16
+ = f.select :expires_on, options_for_select( Iro::Option.expirations_list )
17
+
18
+ .d-flex.flex-column
19
+ %label Q
20
+ = f.text_field :quantity, class: 'w-3em'
21
+
22
+ = f.submit '>'
23
+
@@ -14,12 +14,11 @@
14
14
  .label Last: #{pos.stock.last }
15
15
 
16
16
  - amnt = pos.next_gain_loss_amount
17
- - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
17
+ - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1*u}px solid red"
18
18
  - width = "#{ ( pos.inner_strike - pos.outer_strike ) * u}px"
19
19
  - left = "#{ ( pos.outer_strike - pos.stock.last ) * u}px"
20
- .PositionW{ style: "width: #{width}; left: #{left}; " }
20
+ .PositionW{ class: pos.strategy.kind, style: "width: #{width}; left: #{left}; " }
21
21
  .Position{ style: " border-right: #{border}; " }
22
22
  .MaxGain{ style: "width: #{pos.max_gain * u}px" }
23
-
24
23
  .select= button_to 'select', prepare2_position_path(pos.id)
25
24
  .c
@@ -0,0 +1 @@
1
+ app/views/iro/positions/_prepare_short_debit_put_spread.haml
@@ -17,7 +17,8 @@
17
17
  - border = amnt >= 0 ? "#{amnt * u}px solid green" : "#{amnt * -1 * u}px solid red"
18
18
  - width = "#{ ( pos.outer_strike - pos.inner_strike ) * u}px"
19
19
  - left = "#{ ( pos.stock.last - pos.outer_strike ) * u}px"
20
- .PositionW{ style: "width: #{width}; left: #{left}; border-right: #{border};" }
20
+ .PositionW{ class: pos.strategy.kind, style: "width: #{width}; left: #{left}; border-right: #{border};" }
21
21
  .Position
22
22
  .MaxGain{ style: "width: #{pos.max_gain * u}px" }
23
+ .select= button_to 'select', prepare2_position_path(pos.id)
23
24
  .c
@@ -17,12 +17,11 @@
17
17
  Strategy
18
18
  %th.q Q
19
19
  %th.strikes
20
- -# .a outer_strike, inner_strike
21
20
  Strike
22
21
  %th.begin_price
23
- .a Begin outer price, delta
22
+ .a Begin price, delta
24
23
  %th.max-loss Max Loss
25
- %th.max-gain Max Gain
24
+ -# %th.max-gain Max Gain
26
25
  %th
27
26
  .end_price End Price, delta
28
27
  %th
@@ -64,9 +63,8 @@
64
63
  = link_to '[~]', edit_position_path(position)
65
64
  = link_to '[dup]', duplicate_position_path(position)
66
65
  .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
+ = link_to '[sync]', sync_position_path(pos)
67
+ = link_to '[roll]', prepare_to_roll_position_path(pos)
70
68
 
71
69
  %td.ticker
72
70
  = position.stock.ticker
@@ -88,32 +86,32 @@
88
86
  <b>#{position.quantity}</b>
89
87
  %td.strikes
90
88
  .long-or-short-item
91
- .outer-strike= pp_amount position.outer_strike
92
- .inner-strike= pp_amount position.inner_strike
89
+ .outer-strike= pp_amount position.outer.strike
90
+ .inner-strike= pp_amount position.inner.strike
93
91
 
94
92
  %td.begin_price
95
93
  .long-or-short-item
96
94
  .begin-outer-price
97
- = pp_amount position.begin_outer_price
98
- <b>D</b> #{pp_delta position.begin_outer_delta}
95
+ = pp_amount position.outer.begin_price
96
+ &nbsp;<b>D</b>&nbsp; #{pp_delta position.outer.begin_delta}
99
97
  .begin-inner-price
100
- = pp_amount position.begin_inner_price
101
- <b>D</b> #{pp_delta position.begin_inner_delta}
98
+ = pp_amount position.inner.begin_price
99
+ &nbsp;<b>D</b>&nbsp; #{pp_delta position.inner.begin_delta}
102
100
  %td
103
101
  .max-loss= pp_amount position.max_loss * pos.q * 100, precision: 0
104
- %td
105
- .max-gain= pp_amount position.max_gain * pos.q * 100, precision: 0
106
- .max-gainp
107
- -# = pp_percent( -1 * position.max_gain / position.max_loss ) rescue '-' # undef. for covered calls
102
+ -# %td
103
+ -# .max-gain= pp_amount position.max_gain * pos.q * 100, precision: 0
104
+ -# .max-gainp
105
+ -# -# = pp_percent( -1 * position.max_gain / position.max_loss ) rescue '-' # undef. for covered calls
108
106
 
109
- %td.end_price
107
+ %td.end
110
108
  .long-or-short-item
111
109
  .end-outer-price
112
- = pp_amount position.end_outer_price
113
- <b>D</b> #{pp_delta position.end_outer_delta}
110
+ = pp_amount position.outer.end_price
111
+ &nbsp;<b>D</b>&nbsp; #{pp_delta position.outer.end_delta}
114
112
  .end-inner-price
115
- = pp_amount position.end_inner_price
116
- <b>D</b> #{pp_delta position.end_inner_delta}
113
+ = pp_amount position.inner.end_price
114
+ &nbsp;<b>D</b>&nbsp; #{pp_delta position.inner.end_delta}
117
115
  %td.net
118
116
  .a= pp_amount position.net_amount * pos.q * 100, precision: 0 rescue '@TODO'
119
117
  .a <i>#{pp_percent position.net_amount / position.max_gain rescue '@TODO'}</i>
@@ -128,12 +126,13 @@
128
126
  - if position.next_reasons.present?
129
127
  %i.fa.fa-expand.collapse-expand{ id: "pos-reasons-#{position.id}" } reasons
130
128
  = render '/iro/positions/reasons', reasons: position.next_reasons
131
- .a= position.next_symbol
132
- .a= position.next_delta
129
+ .a= position.autonxt
133
130
  .a
134
- = pp_amount position.next_mark
135
- \=>
136
- = pp_amount position.next_outcome * 100 * position.quantity rescue nil
131
+ - if pos.autonxt
132
+ = link_to '[autonxt]', prepare2_position_path(pos.autonxt)
133
+ = pp_amount pos.autonxt.prev_gain_loss_amount
134
+ -# \=>
135
+ -# = pp_amount position.next_outcome * 100 * position.quantity rescue nil
137
136
 
138
137
 
139
138
 
@@ -14,10 +14,12 @@
14
14
 
15
15
  = render "/iro/positions/gameui_#{pos.strategy.kind}", position: pos
16
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
17
+ %div{ class: pos.long_or_short }
18
+ .long-or-short-item{ style: "border-left: 0" }
19
+ - @positions.each_with_index do |pos, idx|
20
+ .reviewing
21
+ = render "/iro/positions/header_#{pos.strategy.kind}", pos: pos, collapse_key: 'roll'
22
+ = render "/iro/positions/prepare_#{pos.strategy.kind}", pos: pos
21
23
 
22
24
 
23
25
 
@@ -5,7 +5,18 @@
5
5
  %ul
6
6
  %li
7
7
  buy to close
8
- = pos.prev.outer
9
- %li sell to close
10
- %li buy to open
11
- %li sell to open
8
+ = pos.autoprev.inner
9
+ %li
10
+ sell to close
11
+ = pos.autoprev.outer
12
+ %li
13
+ buy to open
14
+ = pos.outer
15
+ %li
16
+ sell to open
17
+ = pos.inner
18
+ %li
19
+ Query
20
+ %pre= JSON.pretty_generate( @query )
21
+
22
+ = button_to 'Place Order', prepare3_position_path(@position), data: { confirm: 'Are you sure?' }
@@ -1,26 +1,26 @@
1
1
 
2
- .d-flex.flex-wrap
3
- %label unit
4
- = f.number_field :unit
5
- px/usd
6
- &nbsp;&nbsp;
2
+ .purses--form-extra-fields
7
3
 
8
- %label height
9
- = f.number_field :height
10
- px/q
11
- &nbsp;&nbsp;
4
+ .d-flex.flex-wrap
5
+ %label unit
6
+ = f.number_field :unit
7
+ .unit px/usd
12
8
 
13
- %label mark_every_n_usd
14
- = f.number_field :mark_every_n_usd, step: 0.01
15
- &nbsp;&nbsp;
9
+ %label height
10
+ = f.number_field :height
11
+ .unit px/q
16
12
 
17
- %label n_next_positions
18
- = f.number_field :n_next_positions
19
- &nbsp;&nbsp;
13
+ %label summary_unit
14
+ = f.number_field :summary_unit, step: 0.000001
15
+ .unit px/usd
20
16
 
21
- %label summary_scale
22
- = f.number_field :summary_scale, step: 0.000001, style: "width: 120px"
17
+ .d-flex.flex-wrap
18
+ %label mark_every_n_usd
19
+ = f.number_field :mark_every_n_usd, step: 0.01
20
+ .unit
23
21
 
24
- &nbsp;&nbsp;
22
+ %label n_next_positions
23
+ = f.number_field :n_next_positions
24
+ .unit
25
25
 
26
26
 
@@ -4,16 +4,21 @@
4
4
  .header
5
5
  %h5.title
6
6
  Purse `#{purse.slug}`
7
+ -# (#{purse.positions.length})
8
+ &nbsp;
7
9
  = 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})
10
+ = link_to '[table]', purse_path(purse)
11
+ = link_to '[gameUI]', purse_gameui_path(purse)
11
12
 
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 })
13
+ %ul
14
+ %li <b>Total:</b> #{pp_amount purse.balance}
15
+ %li <b>Available:</b> #{pp_amount purse.available}
15
16
 
16
- - if true || params[:template] == 'gameui'
17
+
18
+ = render '/iro/positions/new', purse: purse
19
+
20
+
21
+ - if true # params[:template] == 'gameui'
17
22
  .mini-inputs
18
23
  = form_for purse, html: { class: 'd-flex' } do |f|
19
24
  = render '/iro/purses/form_extra_fields', f: f
@@ -1,69 +1,76 @@
1
1
 
2
2
  - u = @purse.unit
3
- - s_mult = @purse.summary_scale
3
+ - summary_unit = @purse.summary_unit
4
4
  - collapse_key ||= nil
5
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}
6
+ - if @purse.positions.present?
7
+ %i.fa.fa-expand.collapse-expand{ id: "pursesSummary_#{collapse_key}", style: "margin-left: -1em;" } Summary
8
+ .PurseSummaryW
9
+ .PurseSummary
10
+
11
+ .summary-amount
12
+ .max-gl.long.loss{ style: "height: #{@max_loss_long *-1*summary_unit*u}px" }
13
+ %label Long Loss
14
+ .delta
15
+ .begin.long{ style: "height: #{@purse.delta_to_plot_p( :begin, :long, :inner )}" }
16
+ .end.long{ style: "height: #{@purse.delta_to_plot_p( :end, :long, :inner )}" }
17
+
18
+ .max-gl.short.loss{ style: "height: #{@max_loss_short *-1*summary_unit*u}px" }
19
+ %label Short Loss
20
+ .delta
21
+ .begin.short{ style: "height: #{@purse.delta_to_plot_p( :begin, :short, :inner )}" }
22
+ .end.short{ style: "height: #{@purse.delta_to_plot_p( :end, :short, :inner )}" }
23
+
24
+ - if @loss_long
25
+ .net-gl.loss.long.loss-long{ style: "height: #{@loss_long *-1*summary_unit*u}px" }
26
+ - if @loss_short
27
+ .net-gl.loss.short.loss-short{ style: "height: #{@loss_short *-1*summary_unit*u}px" }
28
+
29
+ -# %label Gain
30
+ .summary-amount
31
+ .max-gl.long.gain{ style: "height: #{@max_gain_long *summary_unit*u}px" }
32
+ .max-gl.short.gain{ style: "height: #{@max_gain_short *summary_unit*u}px" }
33
+ - if @gain_long
34
+ .net-gl.gain.long.gain-long{ style: "height: #{@gain_long *summary_unit*u}px" }
35
+ - if @gain_short
36
+ .net-gl.gain.short.gain-short{ style: "height: #{@gain_short *summary_unit*u}px" }
37
+
38
+
39
+
40
+
41
+
42
+
43
+ .legendW
44
+ .legend
45
+ %ul
46
+ %li
47
+ <b>exposure long:</b> #{pp_amount @max_loss_long *-1}
48
+ <b>short:</b> #{pp_amount @max_loss_short *-1}
49
+ %li
50
+ <b>max loss long:</b> #{pp_amount [ @max_loss_long + @max_gain_short, 0].min }
51
+ <b>short:</b> #{pp_amount [ @max_loss_short + @max_gain_long, 0].min }
52
+ %li.gray
53
+ <b>max gain long:</b> #{pp_amount @max_gain_long}
54
+ <b>short:</b> #{pp_amount @max_gain_short}
55
+
56
+ %li
57
+ %hr
58
+ <b>gain long:</b> #{pp_amount @gain_long}
59
+ <b>short:</b> #{pp_amount @gain_short}
60
+ %li
61
+ <b>loss long:</b> #{pp_amount @loss_long}
62
+ <b>short:</b> #{pp_amount @loss_short}
63
+
64
+ %li
65
+ %hr
66
+ <b>Delta long begin:</b> #{pp_delta @purse.delta_wt_avg( :begin, :long, :inner )}
67
+ <b>end:</b> #{pp_delta @purse.delta_wt_avg( :end, :long, :inner )}
68
+ %li
69
+ <b>Delta short begin:</b> #{pp_delta @purse.delta_wt_avg( :begin, :short, :inner )}
70
+ <b>end:</b> #{pp_delta @purse.delta_wt_avg( :end, :short, :inner )}
59
71
 
60
- %li
61
72
  %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}
73
+ %li
74
+ <b>Available amount:</b> #{@purse.available_amount}
75
+
69
76
 
@@ -1,8 +1,9 @@
1
1
 
2
2
  .purses-show.padded
3
- .row
4
- .col-md-6
3
+ .row.no-gutters
4
+ .col-md-6.pr-3
5
5
  = render '/iro/purses/header', purse: @purse
6
6
  .col-md-6
7
7
  = render '/iro/purses/summary', purse: @purse, collapse_key: 'views-show'
8
- = render '/iro/positions/table', positions: @purse.positions
8
+
9
+ = render '/iro/positions/table', positions: @positions
@@ -7,14 +7,15 @@
7
7
  - if stock.new_record?
8
8
  %label New
9
9
  - else
10
+ %label status
10
11
  = f.select :status, options_for_select([ Iro::Stock::STATUS_ACTIVE, Iro::Stock::STATUS_INACTIVE ], selected: stock.status)
11
12
  .field
12
13
  = f.label :ticker
13
14
  = f.text_field :ticker
14
15
 
15
- .field
16
- %label Last
17
- = f.number_field :last, placeholder: '80.0', step: 0.01
16
+ -# .field
17
+ -# %label Last
18
+ -# = f.number_field :last, placeholder: '80.0', step: 0.01
18
19
 
19
20
  .field
20
21
  %label options price increment
@@ -0,0 +1,4 @@
1
+
2
+ .stocks-edit.maxwidth
3
+
4
+ = render 'form', stock: @stock
@@ -1,10 +1,25 @@
1
1
 
2
- .stocks--index.padded
2
+ .stocks--index.maxwidth
3
3
  .maxwidth
4
4
  %h5 Stocks
5
5
 
6
- %ul
7
- - @stocks.each do |stock|
8
- %li
9
- = render 'iro/stocks/form', stock: stock
10
- %li= render 'iro/stocks/form', stock: Iro::Stock.new
6
+ %table.bordered.padded
7
+ %thead
8
+ %tr
9
+ %td Ticker
10
+ %td last price
11
+ %td n priceitems
12
+ %tbody
13
+ - @stocks.each do |stock|
14
+ %tr
15
+ %td
16
+ = link_to '[~]', edit_stock_path(stock)
17
+ = link_to '[api]', stock_path(stock, format: :json)
18
+ <b>#{stock.ticker}</b>
19
+ %td
20
+ #{pp_amount stock.last}
21
+ %td
22
+ = stock.priceitems.length
23
+
24
+ %hr
25
+ = render 'iro/stocks/form', stock: Iro::Stock.new