iron_warbler 2.0.7.24 → 2.0.7.25

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b73ac7c5b7ca0d29fe20cd0db0dcdca4713a710790bff2cffe8c30c3a18d2d2
4
- data.tar.gz: daef47e2b8841f0253e55d19a8c8703c7aff086c53711b52db3dfdb470a97a78
3
+ metadata.gz: 8184e7abf0df5faad6e8d99504be22235e0fa846801be7bd2869e7f81631349b
4
+ data.tar.gz: ac0dab40337f109eadccd06b943203e19c507abc9a05cc3e66f0f453b8275d82
5
5
  SHA512:
6
- metadata.gz: e59a49397b934c8537abe40eb23eba846aa770956e02168722b2eb5fd6a1e19581388dc43d3ecb6e211e90cffec5cf8b02ef5eaa6efdcb1f40b4599c4125c8e8
7
- data.tar.gz: 8f10a4503e57e02d17ca0dd7a310fc73489dfd22fb23e23f16a79de72f3a589790c09e9facbfb2441daf3fcef2b93456bcac12ce7a767c35ce7e29c2ccffc48f
6
+ metadata.gz: e892adf76bb1fecaf319f614bb4249689bd5b761e46b234f5e27b89d3640b0f6fcfb7f9cfba5ecd25873b8c9af40ab7d9e8e706293d09879447c7188ae47303d
7
+ data.tar.gz: e037e728a1a2beb3f4f07ec46f5c40c188514960bd961570fb603e5a73842377a01268c9e1ff8538e8c7bc1afc213dc4df5a73fd826be9209838318f2aaee65b
@@ -9,3 +9,11 @@
9
9
  }
10
10
  }
11
11
 
12
+ .select {
13
+ position: absolute;
14
+ z-index: 5;
15
+
16
+ right: -100px;
17
+ text-align: left;
18
+ width: calc(100px - 1em);
19
+ }
@@ -52,7 +52,7 @@
52
52
  .Position {
53
53
  position: absolute;
54
54
  width: 100%;
55
- height: 90%;
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: -10%;
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.new({
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_
@@ -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'
@@ -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() * u}px " }
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() *u}px " }
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}; border-right: #{border};" }
21
- .Position
22
- .MaxGain{ style: "width: #{pos.max_gain * u}px" }
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
@@ -0,0 +1,11 @@
1
+
2
+ - pos = @position
3
+
4
+ -## long call spread
5
+ %ul
6
+ %li
7
+ buy to close
8
+ = pos.prev.outer
9
+ %li sell to close
10
+ %li buy to open
11
+ %li sell to open
@@ -7,7 +7,7 @@
7
7
 
8
8
  %label height
9
9
  = f.number_field :height
10
- px
10
+ px/q
11
11
  &nbsp;&nbsp;
12
12
 
13
13
  %label mark_every_n_usd
@@ -19,7 +19,7 @@
19
19
  &nbsp;&nbsp;
20
20
 
21
21
  %label summary_scale
22
- = f.number_field :summary_scale, step: 0.0001, style: "width: 120px"
22
+ = f.number_field :summary_scale, step: 0.000001, style: "width: 120px"
23
23
 
24
24
  &nbsp;&nbsp;
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', 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
16
- get 'positions/:id/refresh', to: 'positions#refresh', as: :refresh_position
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.24
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