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