iron_warbler 2.0.7.24 → 2.0.7.25
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/positions_gameui.scss +8 -0
- data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +2 -4
- data/app/controllers/iro/positions_controller.rb +67 -1
- data/app/models/iro/option.rb +5 -0
- data/app/models/iro/position.rb +6 -0
- data/app/views/iro/positions/_gameui_covered_call.haml +1 -1
- data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +1 -1
- data/app/views/iro/positions/_prepare_long_debit_call_spread.haml +6 -4
- data/app/views/iro/positions/prepare2.haml +11 -0
- data/app/views/iro/purses/_form_extra_fields.haml +2 -2
- data/config/routes.rb +6 -5
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8184e7abf0df5faad6e8d99504be22235e0fa846801be7bd2869e7f81631349b
|
4
|
+
data.tar.gz: ac0dab40337f109eadccd06b943203e19c507abc9a05cc3e66f0f453b8275d82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e892adf76bb1fecaf319f614bb4249689bd5b761e46b234f5e27b89d3640b0f6fcfb7f9cfba5ecd25873b8c9af40ab7d9e8e706293d09879447c7188ae47303d
|
7
|
+
data.tar.gz: e037e728a1a2beb3f4f07ec46f5c40c188514960bd961570fb603e5a73842377a01268c9e1ff8538e8c7bc1afc213dc4df5a73fd826be9209838318f2aaee65b
|
@@ -52,7 +52,7 @@
|
|
52
52
|
.Position {
|
53
53
|
position: absolute;
|
54
54
|
width: 100%;
|
55
|
-
height:
|
55
|
+
height: 100%;
|
56
56
|
|
57
57
|
left: 0;
|
58
58
|
top: 0;
|
@@ -64,8 +64,6 @@
|
|
64
64
|
background: rgba(255,153,51, 0.5);
|
65
65
|
position: absolute;
|
66
66
|
|
67
|
-
/* HEREHERE: either left, or right 0, this orange strip flips. */
|
68
|
-
// left: 0;
|
69
67
|
right: 0;
|
70
68
|
|
71
69
|
width: 10000px;
|
@@ -76,7 +74,7 @@
|
|
76
74
|
.Breakeven {
|
77
75
|
position: absolute;
|
78
76
|
right: 0;
|
79
|
-
bottom:
|
77
|
+
bottom: 0;
|
80
78
|
border: 2px dotted green;
|
81
79
|
background: rgba(0,255,0, 0.5);
|
82
80
|
height: 0.5em;
|
@@ -47,6 +47,7 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
47
47
|
authorize! :edit, @position
|
48
48
|
end
|
49
49
|
|
50
|
+
## this is auto-driven
|
50
51
|
def propose
|
51
52
|
@strategy = Iro::Strategy.find params[:strategy_id]
|
52
53
|
authorize! :show, @strategy
|
@@ -112,6 +113,68 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
112
113
|
redirect_to request.referrer || purse_path( @position.purse )
|
113
114
|
end
|
114
115
|
|
116
|
+
-## long debit call spread
|
117
|
+
def prepare2
|
118
|
+
@position = Iro::Position.find params[:id]
|
119
|
+
authorize! :roll, @position
|
120
|
+
|
121
|
+
pos = @position
|
122
|
+
stock = @position.stock
|
123
|
+
|
124
|
+
next_outer = @position.outer || Iro::Option.create({
|
125
|
+
stock: stock,
|
126
|
+
strike: pos.outer_strike,
|
127
|
+
expires_on: pos.expires_on,
|
128
|
+
position: pos,
|
129
|
+
last: pos.begin_outer_price,
|
130
|
+
})
|
131
|
+
|
132
|
+
next_inner = @position.inner || Iro::Option.create({
|
133
|
+
stock: stock,
|
134
|
+
strike: pos.inner_strike,
|
135
|
+
expires_on: pos.expires_on,
|
136
|
+
position: pos,
|
137
|
+
last: pos.begin_inner_price,
|
138
|
+
})
|
139
|
+
|
140
|
+
prev_outer = pos.prev.outer
|
141
|
+
prev_inner = pos.prev.inner
|
142
|
+
|
143
|
+
price = pos.prev.outer.last - pos.prev.inner.last + pos.nxt.inner.last - pos.nxt.outer.last
|
144
|
+
|
145
|
+
@query = {
|
146
|
+
orderType: "NET_DEBIT",
|
147
|
+
session: "NORMAL",
|
148
|
+
price: price,
|
149
|
+
duration: "DAY",
|
150
|
+
orderStrategyType: "SINGLE",
|
151
|
+
orderLegCollection: [
|
152
|
+
## @TODO: this is only entering the next position, need to also close out the previous.
|
153
|
+
{
|
154
|
+
instruction: "BUY_TO_OPEN",
|
155
|
+
quantity: q,
|
156
|
+
instrument: {
|
157
|
+
symbol: outer.symbol,
|
158
|
+
assetType: "OPTION",
|
159
|
+
},
|
160
|
+
},
|
161
|
+
{
|
162
|
+
instruction: "SELL_TO_OPEN",
|
163
|
+
quantity: q,
|
164
|
+
instrument: {
|
165
|
+
symbol: inner.symbol,
|
166
|
+
assetType: "OPTION",
|
167
|
+
},
|
168
|
+
},
|
169
|
+
],
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
173
|
+
-## long debit call spread
|
174
|
+
def prepare3
|
175
|
+
out = Tda::Option.roll_long_debit_call_spread( position )
|
176
|
+
end
|
177
|
+
|
115
178
|
def prepare
|
116
179
|
@position = Iro::Position.find params[:id]
|
117
180
|
authorize! :roll, @position
|
@@ -188,7 +251,8 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
188
251
|
def _prepare_long_debit_call_spread
|
189
252
|
@positions = []
|
190
253
|
(-@nn..@nn).each do |idx|
|
191
|
-
next_ = Iro::Position.
|
254
|
+
next_ = Iro::Position.find_or_create_by({
|
255
|
+
status: 'prepare',
|
192
256
|
stock: @stock,
|
193
257
|
inner_strike: @prev.inner_strike - idx*@stock.options_price_increment,
|
194
258
|
outer_strike: @prev.outer_strike - idx*@stock.options_price_increment,
|
@@ -196,6 +260,7 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
196
260
|
purse: @position.purse,
|
197
261
|
strategy: @position.strategy,
|
198
262
|
quantity: @position.quantity,
|
263
|
+
prev_id: @prev.id,
|
199
264
|
})
|
200
265
|
next_.sync
|
201
266
|
next_.begin_inner_price = next_.end_inner_price
|
@@ -205,6 +270,7 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
205
270
|
next_.begin_outer_delta = next_.end_outer_delta
|
206
271
|
next_.next_gain_loss_amount = @prev.end_outer_price - @prev.end_inner_price
|
207
272
|
next_.next_gain_loss_amount += next_.begin_inner_price - next_.begin_outer_price
|
273
|
+
next_.save
|
208
274
|
puts! next_, 'next_'
|
209
275
|
puts! next_.next_gain_loss_amount, 'next_gain_loss_amount'
|
210
276
|
@positions.push next_
|
data/app/models/iro/option.rb
CHANGED
@@ -30,6 +30,11 @@ class Iro::Option
|
|
30
30
|
|
31
31
|
belongs_to :stock, class_name: 'Iro::Stock', inverse_of: :strategies
|
32
32
|
|
33
|
+
has_one :outer, class_name: 'Iro::Position', invese_of: :outer
|
34
|
+
has_one :inner, class_name: 'Iro::Position', invese_of: :inner
|
35
|
+
|
36
|
+
field :last, type: :float
|
37
|
+
|
33
38
|
def symbol
|
34
39
|
if !self[:symbol]
|
35
40
|
p_c_ = put_call == 'PUT' ? 'P' : 'C'
|
data/app/models/iro/position.rb
CHANGED
@@ -17,6 +17,9 @@ class Iro::Position
|
|
17
17
|
belongs_to :purse, class_name: 'Iro::Purse', inverse_of: :positions
|
18
18
|
index({ purse_id: 1, ticker: 1 })
|
19
19
|
|
20
|
+
belongs_to :prev, class_name: 'Iro::Position', inverse_of: :nxt
|
21
|
+
has_one :nxt, class_name: 'Iro::Position', inverse_of: :prev
|
22
|
+
|
20
23
|
belongs_to :stock, class_name: 'Iro::Stock', inverse_of: :positions
|
21
24
|
def ticker
|
22
25
|
stock&.ticker || '-'
|
@@ -27,6 +30,9 @@ class Iro::Position
|
|
27
30
|
# field :ticker
|
28
31
|
# validates :ticker, presence: true
|
29
32
|
|
33
|
+
belongs_to :outer, class_name: 'Iro::Option', inverse_of: :outer
|
34
|
+
belongs_to :inner, class_name: 'Iro::Option', inverse_of: :inner
|
35
|
+
|
30
36
|
field :outer_strike, type: :float
|
31
37
|
# validates :outer_strike, presence: true
|
32
38
|
|
@@ -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,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" }
|
@@ -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
|
|
@@ -17,7 +17,9 @@
|
|
17
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{ style: "width: #{width}; left: #{left}; " }
|
21
|
+
.Position{ style: " border-right: #{border}; " }
|
22
|
+
.MaxGain{ style: "width: #{pos.max_gain * u}px" }
|
23
|
+
|
24
|
+
.select= button_to 'select', prepare2_position_path(pos.id)
|
23
25
|
.c
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
%label height
|
9
9
|
= f.number_field :height
|
10
|
-
px
|
10
|
+
px/q
|
11
11
|
|
12
12
|
|
13
13
|
%label mark_every_n_usd
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
%label summary_scale
|
22
|
-
= f.number_field :summary_scale, step: 0.
|
22
|
+
= f.number_field :summary_scale, step: 0.000001, style: "width: 120px"
|
23
23
|
|
24
24
|
|
25
25
|
|
data/config/routes.rb
CHANGED
@@ -9,11 +9,12 @@ Iro::Engine.routes.draw do
|
|
9
9
|
|
10
10
|
resources :option_watches
|
11
11
|
|
12
|
-
get 'positions/duplicate/:id', to: 'positions#new',
|
13
|
-
post 'positions/propose', to: 'positions#propose',
|
14
|
-
get 'positions/:id/prepare', to: 'positions#prepare',
|
15
|
-
|
16
|
-
|
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
|
+
match 'positions/:id/prepare2', to: 'positions#prepare2', as: :prepare2_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
|
16
|
+
post 'positions/:id/roll', to: 'positions#do_roll', as: :roll_position
|
17
|
+
get 'positions/:id/refresh', to: 'positions#refresh', as: :refresh_position
|
17
18
|
resources :positions
|
18
19
|
resources :profiles
|
19
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_warbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.7.
|
4
|
+
version: 2.0.7.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- app/views/iro/positions/edit.haml
|
275
275
|
- app/views/iro/positions/new.haml
|
276
276
|
- app/views/iro/positions/prepare.haml
|
277
|
+
- app/views/iro/positions/prepare2.haml
|
277
278
|
- app/views/iro/positions/roll-cc.haml-bk
|
278
279
|
- app/views/iro/positions/roll.haml-trash
|
279
280
|
- app/views/iro/purses/_form.haml
|