iron_warbler 2.0.7.24 → 2.0.7.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/iron_warbler/Card.scss +6 -0
- data/app/assets/stylesheets/iron_warbler/positions.scss +1 -1
- data/app/assets/stylesheets/iron_warbler/positions_gameui.scss +8 -0
- data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +2 -4
- data/app/assets/stylesheets/iron_warbler/purses_summary.scss +31 -19
- data/app/controllers/iro/application_controller.rb +6 -0
- data/app/controllers/iro/positions_controller.rb +186 -137
- data/app/controllers/iro/purses_controller.rb +3 -1
- data/app/controllers/iro/stocks_controller.rb +2 -2
- data/app/models/iro/option.rb +41 -148
- data/app/models/iro/option_black_scholes.rb +149 -0
- data/app/models/iro/position.rb +156 -205
- data/app/models/iro/purse.rb +34 -4
- data/app/models/iro/strategy.rb +49 -47
- data/app/views/iro/_main_header.haml +4 -2
- data/app/views/iro/options/_show_mini.haml +8 -0
- data/app/views/iro/positions/_form.haml +8 -3
- data/app/views/iro/positions/_formpart_4data.haml +41 -38
- data/app/views/iro/positions/_gameui_covered_call.haml +1 -1
- data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +5 -5
- data/app/views/iro/positions/_gameui_long_debit_call_spread.haml-trash +42 -0
- data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +1 -0
- data/app/views/iro/positions/_gameui_short_debit_put_spread.haml-trash +40 -0
- data/app/views/iro/positions/_header.haml +2 -0
- data/app/views/iro/positions/_header_long_debit_call_spread.haml +43 -25
- data/app/views/iro/positions/_prepare_long_debit_call_spread.haml +6 -5
- data/app/views/iro/positions/_prepare_short_debit_put_spread.haml +2 -1
- data/app/views/iro/positions/_table.haml +25 -26
- data/app/views/iro/positions/prepare.haml +6 -4
- data/app/views/iro/positions/prepare2.haml +22 -0
- data/app/views/iro/purses/_form_extra_fields.haml +8 -4
- data/app/views/iro/purses/_header.haml +19 -5
- data/app/views/iro/purses/_summary.haml +69 -62
- data/app/views/iro/purses/show.haml +1 -1
- data/app/views/iro/strategies/_form.haml +26 -19
- data/app/views/iro/strategies/_show.haml +6 -4
- data/config/routes.rb +10 -7
- metadata +8 -2
- data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +0 -40
data/app/models/iro/strategy.rb
CHANGED
@@ -18,6 +18,7 @@ class Iro::Strategy
|
|
18
18
|
has_many :positions, class_name: 'Iro::Position', inverse_of: :strategy
|
19
19
|
|
20
20
|
belongs_to :stock, class_name: 'Iro::Stock', inverse_of: :strategies
|
21
|
+
has_and_belongs_to_many :purses, class_name: 'Iro::Purse', inverse_of: :strategies
|
21
22
|
|
22
23
|
KIND_COVERED_CALL = 'covered_call'
|
23
24
|
KIND_LONG_DEBIT_CALL_SPREAD = 'long_debit_call_spread'
|
@@ -43,74 +44,74 @@ class Iro::Strategy
|
|
43
44
|
end
|
44
45
|
|
45
46
|
field :buffer_above_water, type: :float
|
46
|
-
field :threshold_delta,
|
47
|
-
field :threshold_netp,
|
48
|
-
|
49
|
-
|
50
|
-
field :
|
51
|
-
field :
|
52
|
-
field :
|
47
|
+
field :threshold_delta, type: :float
|
48
|
+
field :threshold_netp, type: :float
|
49
|
+
field :min_dte, type: :integer, default: 0
|
50
|
+
|
51
|
+
field :next_inner_delta, type: :float
|
52
|
+
field :next_outer_delta, type: :float
|
53
|
+
field :next_inner_strike, type: :float
|
54
|
+
field :next_outer_strike, type: :float
|
53
55
|
field :next_spread_amount, type: :float # e.g. $20 for a $2000 NVDA spread
|
54
|
-
|
56
|
+
field :next_buffer_above_water, type: :float
|
55
57
|
|
56
58
|
def self.for_ticker ticker
|
57
59
|
where( ticker: ticker )
|
58
60
|
end
|
59
61
|
|
60
62
|
def breakeven_covered_call p
|
61
|
-
p.
|
63
|
+
p.inner.strike + p.inner.begin_price
|
62
64
|
end
|
63
65
|
def breakeven_long_debit_call_spread p
|
64
|
-
p.
|
66
|
+
p.inner.strike - p.max_gain
|
65
67
|
end
|
66
68
|
alias_method :breakeven_short_debit_put_spread, :breakeven_long_debit_call_spread
|
67
69
|
|
68
70
|
def max_gain_covered_call p
|
69
|
-
#
|
70
|
-
p.begin_inner_price * 100 - 0.66 # @TODO: is this *100 really?
|
71
|
+
p.inner.begin_price * 100 - 0.66 # @TODO: is this *100 really?
|
71
72
|
end
|
72
73
|
def max_gain_long_debit_call_spread p
|
73
74
|
## 100 * disalloed for gameui
|
74
|
-
( p.
|
75
|
+
( p.inner.strike - p.outer.strike - p.outer.begin_price + p.inner.begin_price ) # - 2*0.66
|
75
76
|
end
|
76
77
|
def max_gain_short_debit_put_spread p
|
77
78
|
## 100 * disalloed for gameui
|
78
|
-
( p.
|
79
|
+
( p.outer.strike - p.inner.strike - p.outer.begin_price + p.inner.begin_price ) # - 2*0.66
|
79
80
|
end
|
80
81
|
|
81
82
|
def net_amount_covered_call p
|
82
|
-
( p.
|
83
|
+
( p.inner.begin_price - p.inner.end_price )
|
83
84
|
end
|
84
85
|
def net_amount_long_debit_call_spread p
|
85
|
-
outer = p.
|
86
|
-
inner = p.
|
86
|
+
outer = p.outer.end_price - p.outer.begin_price
|
87
|
+
inner = p.inner.begin_price - p.inner.end_price
|
87
88
|
out = ( outer + inner )
|
88
89
|
end
|
89
90
|
alias_method :net_amount_short_debit_put_spread, :net_amount_long_debit_call_spread
|
90
91
|
|
91
92
|
def max_loss_covered_call p
|
92
|
-
p.
|
93
|
+
p.inner.begin_price*10 # just suppose 10,000%
|
93
94
|
end
|
94
95
|
def max_loss_long_debit_call_spread p
|
95
|
-
out = p.
|
96
|
+
out = p.outer.strike - p.inner.strike
|
96
97
|
end
|
97
98
|
def max_loss_short_debit_put_spread p # different
|
98
|
-
out = p.
|
99
|
+
out = p.inner.strike - p.outer.strike
|
99
100
|
end
|
100
101
|
|
101
102
|
def begin_delta_covered_call p
|
102
|
-
p.
|
103
|
+
p.inner.begin_delta
|
103
104
|
end
|
104
105
|
def begin_delta_long_debit_call_spread p
|
105
|
-
p.
|
106
|
+
p.outer.begin_delta - p.inner.begin_delta
|
106
107
|
end
|
107
108
|
alias_method :begin_delta_short_debit_put_spread, :begin_delta_long_debit_call_spread
|
108
109
|
|
109
110
|
def end_delta_covered_call p
|
110
|
-
p.
|
111
|
+
p.inner.end_delta
|
111
112
|
end
|
112
113
|
def end_delta_long_debit_call_spread p
|
113
|
-
p.
|
114
|
+
p.outer.end_delta - p.inner.end_delta
|
114
115
|
end
|
115
116
|
alias_method :end_delta_short_debit_put_spread, :end_delta_long_debit_call_spread
|
116
117
|
|
@@ -126,18 +127,18 @@ class Iro::Strategy
|
|
126
127
|
return [ 0.99, '0 DTE, must exit' ]
|
127
128
|
end
|
128
129
|
|
129
|
-
if ( stock.last - buffer_above_water ) < p.
|
130
|
+
if ( stock.last - buffer_above_water ) < p.inner.strike
|
130
131
|
return [ 0.98, "Last #{'%.2f' % stock.last} is " +
|
131
|
-
"#{'%.2f' % [p.
|
132
|
-
"below #{'%.2f' % [p.
|
132
|
+
"#{'%.2f' % [p.inner.strike + buffer_above_water - stock.last]} " +
|
133
|
+
"below #{'%.2f' % [p.inner.strike + buffer_above_water]} water" ]
|
133
134
|
end
|
134
135
|
|
135
|
-
if p.
|
136
|
-
return [ 0.61, "Delta #{p.
|
136
|
+
if p.inner.end_delta < threshold_delta
|
137
|
+
return [ 0.61, "Delta #{p.inner.end_delta} is lower than #{threshold_delta} threshold." ]
|
137
138
|
end
|
138
139
|
|
139
|
-
if 1 - p.
|
140
|
-
return [ 0.51, "made enough #{'%.
|
140
|
+
if 1 - p.inner.end_price/p.inner.begin_price > threshold_netp
|
141
|
+
return [ 0.51, "made enough #{'%.02f' % [(1.0 - p.inner.end_price/p.inner.begin_price )*100]}% profit." ]
|
141
142
|
end
|
142
143
|
|
143
144
|
return [ 0.33, '-' ]
|
@@ -153,18 +154,18 @@ class Iro::Strategy
|
|
153
154
|
return [ 0.99, '1 DTE, must exit' ]
|
154
155
|
end
|
155
156
|
|
156
|
-
if ( stock.last - buffer_above_water ) < p.
|
157
|
+
if ( stock.last - buffer_above_water ) < p.inner.strike
|
157
158
|
return [ 0.95, "Last #{'%.2f' % stock.last} is " +
|
158
|
-
"#{'%.2f' % [stock.last - p.
|
159
|
-
"below #{'%.2f' % [p.
|
159
|
+
"#{'%.2f' % [stock.last - p.inner.strike - buffer_above_water]} " +
|
160
|
+
"below #{'%.2f' % [p.inner.strike + buffer_above_water]} water" ]
|
160
161
|
end
|
161
162
|
|
162
|
-
if p.
|
163
|
-
return [ 0.79, "Delta #{p.
|
163
|
+
if p.inner.end_delta < threshold_delta
|
164
|
+
return [ 0.79, "Delta #{p.inner.end_delta} is lower than #{threshold_delta} threshold." ]
|
164
165
|
end
|
165
166
|
|
166
|
-
if 1 - p.
|
167
|
-
return [ 0.51, "made enough #{'%.
|
167
|
+
if 1 - p.inner.end_price/p.inner.begin_price > threshold_netp
|
168
|
+
return [ 0.51, "made enough #{'%.02f' % [(1.0 - p.inner.end_price/p.inner.begin_price )*100]}% profit^" ]
|
168
169
|
end
|
169
170
|
|
170
171
|
return [ 0.33, '-' ]
|
@@ -173,22 +174,22 @@ class Iro::Strategy
|
|
173
174
|
## @TODO
|
174
175
|
def calc_rollp_short_debit_put_spread p
|
175
176
|
|
176
|
-
if ( p.expires_on.to_date - Time.now.to_date ).to_i
|
177
|
-
return [ 0.99,
|
177
|
+
if ( p.expires_on.to_date - Time.now.to_date ).to_i <= min_dte
|
178
|
+
return [ 0.99, "< #{min_dte}DTE, must exit" ]
|
178
179
|
end
|
179
180
|
|
180
|
-
if
|
181
|
+
if stock.last + buffer_above_water > p.inner.strike
|
181
182
|
return [ 0.98, "Last #{'%.2f' % stock.last} is " +
|
182
|
-
"#{'%.2f' % [stock.last - p.
|
183
|
-
"above #{'%.2f' % [p.
|
183
|
+
"#{'%.2f' % [stock.last + buffer_above_water - p.inner.strike]} " +
|
184
|
+
"above #{'%.2f' % [p.inner.strike - buffer_above_water]} water" ]
|
184
185
|
end
|
185
186
|
|
186
|
-
if p.
|
187
|
-
return [ 0.79, "Delta #{p.
|
187
|
+
if p.inner.end_delta.abs < threshold_delta.abs
|
188
|
+
return [ 0.79, "Delta #{p.inner.end_delta} is lower than #{threshold_delta} threshold." ]
|
188
189
|
end
|
189
190
|
|
190
|
-
if
|
191
|
-
return [ 0.51, "made enough #{'%.0f' % [
|
191
|
+
if p.net_percent > threshold_netp
|
192
|
+
return [ 0.51, "made enough #{'%.0f' % [p.net_percent*100]}% > #{"%.2f" % [threshold_netp*100]}% profit," ]
|
192
193
|
end
|
193
194
|
|
194
195
|
return [ 0.33, '-' ]
|
@@ -205,3 +206,4 @@ class Iro::Strategy
|
|
205
206
|
[[nil,nil]] + these.map { |ttt| [ ttt, ttt.id ] }
|
206
207
|
end
|
207
208
|
end
|
209
|
+
|
@@ -9,7 +9,7 @@
|
|
9
9
|
%ul{ style: "margin-top: 2em;" }
|
10
10
|
%li
|
11
11
|
= link_to "Stocks (#{Iro::Stock.all.length})", stocks_path
|
12
|
-
= link_to '[
|
12
|
+
= link_to '[sync]', sync_stocks_path
|
13
13
|
-# %li= link_to 'Options', options_path
|
14
14
|
-# %li Max Pain
|
15
15
|
%li
|
@@ -23,7 +23,9 @@
|
|
23
23
|
= link_to 'Purses', purses_path
|
24
24
|
%ul
|
25
25
|
- @purses.each do |p|
|
26
|
-
%li
|
26
|
+
%li
|
27
|
+
= link_to p, purse_path(p)
|
28
|
+
= link_to '[ui]', purse_gameui_path(p)
|
27
29
|
.a
|
28
30
|
= link_to 'Strategies', strategies_path
|
29
31
|
%ul
|
@@ -15,12 +15,17 @@
|
|
15
15
|
.field
|
16
16
|
%label Stock
|
17
17
|
= f.select :stock_id, options_for_select( @stocks_list, selected: position.stock_id )
|
18
|
-
|
19
|
-
|
18
|
+
|
19
|
+
.field
|
20
|
+
%label long or short?
|
21
|
+
= f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: position.long_or_short || params[:long_or_short] )
|
22
|
+
|
23
|
+
%label Strategy
|
24
|
+
= f.select :strategy_id, options_for_select( @strategies_list, selected: position.strategy_id )
|
20
25
|
|
21
26
|
.field
|
22
27
|
%label Expires on
|
23
|
-
= f.
|
28
|
+
= f.select :expires_on, options_for_select( Iro::Option.expirations_list, selected: position.expires_on )
|
24
29
|
%label Quantity
|
25
30
|
= f.text_field :quantity
|
26
31
|
|
@@ -1,46 +1,49 @@
|
|
1
1
|
.field
|
2
2
|
%label Begin on
|
3
|
-
= f.text_field :begin_on
|
3
|
+
= f.text_field :begin_on, value: position.begin_on || Time.now.to_date.to_s
|
4
4
|
|
5
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
6
|
|
17
7
|
.d-flex
|
18
|
-
.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
= fields_for :outer, position.outer do |f_outer|
|
9
|
+
.field
|
10
|
+
%label Outer Strike
|
11
|
+
= f_outer.number_field :strike, step: 0.01
|
12
|
+
.field
|
13
|
+
%label Begin outer price
|
14
|
+
= f_outer.text_field :begin_price
|
15
|
+
.field
|
16
|
+
%label Begin outer delta
|
17
|
+
= f_outer.text_field :begin_delta
|
27
18
|
|
28
|
-
%br
|
29
|
-
.flex-row
|
30
|
-
%label End on
|
31
|
-
= f.text_field :end_on
|
32
|
-
.long-or-short-item
|
33
19
|
.d-flex
|
34
|
-
.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
20
|
+
= fields_for :inner, position.inner do |f_inner|
|
21
|
+
.field
|
22
|
+
%label Inner Strike
|
23
|
+
= f_inner.number_field :strike, step: 0.01
|
24
|
+
.field
|
25
|
+
%label Begin inner price
|
26
|
+
= f_inner.text_field :begin_price
|
27
|
+
.field
|
28
|
+
%label Begin inner delta
|
29
|
+
= f_inner.text_field :begin_delta
|
30
|
+
|
31
|
+
-# %br
|
32
|
+
-# .flex-row
|
33
|
+
-# %label End on
|
34
|
+
-# = f.text_field :end_on
|
35
|
+
-# .long-or-short-item
|
36
|
+
-# .d-flex
|
37
|
+
-# .field
|
38
|
+
-# %label End outer price
|
39
|
+
-# = f.text_field :end_outer_price
|
40
|
+
-# .field
|
41
|
+
-# %label End outer delta
|
42
|
+
-# = f.text_field :end_outer_delta
|
43
|
+
-# .d-flex
|
44
|
+
-# .field
|
45
|
+
-# %label End inner price
|
46
|
+
-# = f.text_field :end_inner_price
|
47
|
+
-# .field
|
48
|
+
-# %label End inner delta
|
49
|
+
-# = f.text_field :end_inner_delta
|
@@ -10,7 +10,7 @@
|
|
10
10
|
.a
|
11
11
|
= render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
|
12
12
|
.StockCoordinatesW
|
13
|
-
.StockCoordinates{ style: "height: #{pos.q() *
|
13
|
+
.StockCoordinates{ style: "height: #{pos.q() * pos.purse.height}px " }
|
14
14
|
.grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
|
15
15
|
|
16
16
|
.Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
|
@@ -10,27 +10,27 @@
|
|
10
10
|
.a
|
11
11
|
= render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
|
12
12
|
.StockCoordinatesW
|
13
|
-
.StockCoordinates{ style: "height: #{pos.q() *
|
13
|
+
.StockCoordinates{ style: "height: #{pos.q() *pos.purse.height}px " }
|
14
14
|
.grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
|
15
15
|
|
16
16
|
.Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
|
17
17
|
.label Last: #{pp_amount stock.last}
|
18
18
|
.c
|
19
19
|
|
20
|
-
- left = "#{ ( pos.
|
21
|
-
- width = "#{ ( pos.
|
20
|
+
- left = "#{ ( pos.outer.strike - stock.last ).abs() *-1*u}px"
|
21
|
+
- width = "#{ ( pos.inner.strike - pos.outer.strike ).abs() *u}px"
|
22
22
|
.PositionW{ class: pos.strategy.kind, style: "left: #{left}; width: #{width}; " }
|
23
23
|
.Position
|
24
24
|
.MaxGain{ style: "width: #{pos.max_gain * u}px" }
|
25
25
|
.RollGuide
|
26
26
|
|
27
27
|
- if pos.net_amount >= 0
|
28
|
-
.Net.NetPositive{ style: "width: #{ (pos.net_amount
|
28
|
+
.Net.NetPositive{ style: "width: #{ (pos.net_amount) * u }px; right: 0" }
|
29
29
|
.label
|
30
30
|
net
|
31
31
|
= pp_amount pos.net_amount
|
32
32
|
- else
|
33
|
-
.Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount
|
33
|
+
.Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount) * u }px; left: 100%" }
|
34
34
|
.label
|
35
35
|
net
|
36
36
|
= pp_amount pos.net_amount
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
-##
|
3
|
+
-## same for long and short debit spreads
|
4
|
+
-##
|
5
|
+
|
6
|
+
- pos = position
|
7
|
+
- stock = pos.stock
|
8
|
+
- nearest_strike = stock.last.round
|
9
|
+
- u = pos.purse.unit # pixels per dollar
|
10
|
+
|
11
|
+
.collapse-expand.d-flex{ id: "gameui-pos-#{pos.id}" }
|
12
|
+
[<>]
|
13
|
+
.maxwidth= render "/iro/positions/header", pos: pos
|
14
|
+
.a
|
15
|
+
= render "/iro/positions/header_#{pos.strategy.kind}", pos: pos
|
16
|
+
.StockCoordinatesW
|
17
|
+
.StockCoordinates{ style: "height: #{pos.q() *pos.purse.height}px " }
|
18
|
+
.grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
|
19
|
+
|
20
|
+
.Origin{ style: "left: #{ ( nearest_strike - stock.last )* u}px" }
|
21
|
+
.label Last: #{pp_amount stock.last}
|
22
|
+
.c
|
23
|
+
|
24
|
+
- left = "#{ ( pos.outer.strike - stock.last ) * u}px"
|
25
|
+
- width = "#{ ( pos.inner.strike - pos.outer.strike ) * u}px"
|
26
|
+
.PositionW{ class: pos.strategy.kind, style: "left: #{left}; width: #{width}; " }
|
27
|
+
.Position
|
28
|
+
.MaxGain{ style: "width: #{pos.max_gain * u}px" }
|
29
|
+
.RollGuide
|
30
|
+
|
31
|
+
- if pos.net_amount >= 0
|
32
|
+
.Net.NetPositive{ style: "width: #{ (pos.net_amount / 100) * u }px; right: 0" }
|
33
|
+
.label
|
34
|
+
net
|
35
|
+
= pp_amount pos.net_amount
|
36
|
+
- else
|
37
|
+
.Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount / 100) * u }px; left: 100%" }
|
38
|
+
.label
|
39
|
+
net
|
40
|
+
= pp_amount pos.net_amount
|
41
|
+
.c
|
42
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
app/views/iro/positions/_gameui_long_debit_call_spread.haml
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
- pos = position
|
3
|
+
- stock = pos.stock
|
4
|
+
- nearest_strike = stock.last.round
|
5
|
+
- u = pos.purse.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{ style: "height: #{pos.q() *u}px " }
|
15
|
+
.grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
|
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{ class: pos.strategy.kind, style: "left: #{left}; width: #{width}; " }
|
25
|
+
.Position
|
26
|
+
.MaxGain{ style: "width: #{pos.max_gain * u}px" }
|
27
|
+
.RollGuide
|
28
|
+
|
29
|
+
- if pos.net_amount >= 0
|
30
|
+
.Net.NetPositive{ style: "width: #{ (pos.net_amount / 100) * u }px; right: 0" }
|
31
|
+
.label
|
32
|
+
net
|
33
|
+
= pp_amount pos.net_amount
|
34
|
+
- else
|
35
|
+
.Net.NetNegative{ style: "width: #{ (-1 * pos.net_amount / 100) * u }px; left: 100%" }
|
36
|
+
.label
|
37
|
+
net
|
38
|
+
= pp_amount pos.net_amount
|
39
|
+
.c
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
%
|
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 -
|
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 -
|
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
|
+
-#
|
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>
|
13
|
-
|
14
|
-
|
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} <i>#{pp_percent pos.net_percent}</i>
|
15
44
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
%li
|
23
|
-
<b>end_outer,inner_price:</b> #{pp_amount pos.end_outer_price} -> #{pp_amount pos.end_inner_price}
|
24
|
-
|
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} <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
|
+
<i>#{pp_percent pos.next_gain_loss_amount/pos.max_loss*-1}</i>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
.StockCoordinatesW
|
9
|
-
.StockCoordinates{ style: "height: #{@position.purse.height}px " }
|
9
|
+
.StockCoordinates{ style: "height: #{@position.q * @position.purse.height}px " }
|
10
10
|
|
11
11
|
.grid= render "/iro/stocks/grid_#{pos.strategy.long_or_short}", stock: stock, position: pos
|
12
12
|
|
@@ -14,10 +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
|
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};
|
21
|
-
.Position
|
22
|
-
|
20
|
+
.PositionW{ class: pos.strategy.kind, style: "width: #{width}; left: #{left}; " }
|
21
|
+
.Position{ style: " border-right: #{border}; " }
|
22
|
+
.MaxGain{ style: "width: #{pos.max_gain * u}px" }
|
23
|
+
.select= button_to 'select', prepare2_position_path(pos.id)
|
23
24
|
.c
|
@@ -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
|