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
@@ -4,30 +4,46 @@
4
4
  .actions
5
5
  = f.submit
6
6
 
7
-
8
- .field
9
- %label Kind
10
- = f.select :kind, options_for_select( Iro::Strategy::KINDS, selected: strategy.kind )
11
- .field
12
- %label stock
13
- = f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
7
+ .row
8
+ .col-md-6
9
+ .field
10
+ %label Kind
11
+ = f.select :kind, options_for_select( Iro::Strategy::KINDS, selected: strategy.kind )
12
+ .field
13
+ %label long or short?
14
+ = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
15
+ .field
16
+ %label stock
17
+ = f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
18
+
19
+ .col-md-6
20
+ .field
21
+ %label slug
22
+ = f.text_field :slug
23
+ %hr
24
+
25
+
26
+ .field
27
+ %label Threshold Buffer dollars above water
28
+ = f.number_field :threshold_buffer_above_water, placeholder: "0.49", step: 0.01
29
+ .field
30
+ = f.label :threshold_dte
31
+ = f.number_field :threshold_dte, placeholder: "1"
32
+ -# .field
33
+ -# = f.label :next_max_outer_delta
34
+ -# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
14
35
  .field
15
- %label slug
16
- = f.text_field :slug
36
+ = f.label :threshold_delta
37
+ = f.number_field :threshold_delta, placeholder: "0.14", step: 0.001
17
38
  .field
18
- %label long or short?
19
- = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
39
+ = f.label :threshold_netp
40
+ = f.number_field :threshold_netp, placeholder: "0.69", step: 0.001
20
41
 
42
+ %hr
21
43
 
22
- .field
23
- = f.label :buffer_above_water
24
- = f.number_field :buffer_above_water, placeholder: "0.49", step: 0.01
25
- -# .field
26
- -# = f.label :next_max_outer_delta
27
- -# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
28
44
  .field
29
45
  = f.label :next_inner_delta
30
- = f.number_field :next_inner_delta, placeholder: "0.25", step: 0.01
46
+ = f.number_field :next_inner_delta, placeholder: "0.25", step: 0.001
31
47
  .field
32
48
  = f.label :next_inner_strike
33
49
  = f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
@@ -35,14 +51,8 @@
35
51
  = f.label :next_spread_amount
36
52
  = f.number_field :next_spread_amount, placeholder: "20", step: 0.1
37
53
  .field
38
- = f.label :threshold_delta
39
- = f.number_field :threshold_delta, placeholder: "0.14", step: 0.01
40
- .field
41
- = f.label :threshold_netp
42
- = f.number_field :threshold_netp, placeholder: "0.69", step: 0.01
43
- -# .field
44
- -# = f.label :current_underlying_strike
45
- -# = f.number_field :current_underlying_strike, placeholder: "16.66", step: 0.01
54
+ %label next buffer dollars above water
55
+ = f.number_field :next_buffer_above_water, placeholder: "80", step: 0.01
46
56
 
47
57
  .actions
48
58
  = f.submit
@@ -6,14 +6,16 @@
6
6
  = strategy
7
7
  %ul
8
8
  -# %li <b>ticker:</b> #{strategy.ticker}
9
- %li <b>slug:</b> #{strategy.slug}
9
+ -# %li <b>slug:</b> #{strategy.slug}
10
10
 
11
- %li <b>buffer_above_water:</b> #{strategy.buffer_above_water}
11
+ %li <b>threshold_buffer_above_water:</b> #{strategy.threshold_buffer_above_water}
12
+ %li <b>threshold_delta:</b> #{strategy.threshold_delta}
13
+ %li <b>threshold_netp:</b> #{strategy.threshold_netp}
14
+
15
+ %hr
12
16
 
13
17
  %li <b>next_inner_delta:</b> #{strategy.next_inner_delta}
14
18
  -# %li <b>next_outer_delta:</b> #{strategy.next_max_outer_delta}
15
19
  %li <b>next_inner_strike:</b> #{strategy.next_inner_strike}
16
-
17
- %li <b>threshold_delta:</b> #{strategy.threshold_delta}
18
- %li <b>threshold_netp:</b> #{strategy.threshold_netp}
20
+ %li <b>next_spread_amount:</b> #{strategy.next_spread_amount}
19
21
 
data/config/routes.rb CHANGED
@@ -9,26 +9,29 @@ Iro::Engine.routes.draw do
9
9
 
10
10
  resources :option_watches
11
11
 
12
+ match 'positions/:id/close', to: 'positions#close', as: :close_position, via: [ :get, :post ]
12
13
  get 'positions/duplicate/:id', to: 'positions#new', as: :duplicate_position
13
14
  post 'positions/propose', to: 'positions#propose', as: :propose_position
14
15
  get 'positions/:id/prepare', to: 'positions#prepare', as: :prepare_to_roll_position, defaults: { template: 'gameui' }
15
16
  match 'positions/:id/prepare2', to: 'positions#prepare2', as: :prepare2_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
17
+ match 'positions/:id/prepare3', to: 'positions#prepare3', as: :prepare3_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
16
18
  post 'positions/:id/roll', to: 'positions#do_roll', as: :roll_position
17
- get 'positions/:id/refresh', to: 'positions#refresh', as: :refresh_position
19
+ get 'positions/:id/sync', to: 'positions#sync', as: :sync_position
18
20
  resources :positions
19
21
  resources :profiles
20
22
 
21
- get 'purses/:id/gameui', to: 'purses#show', as: :gameui_purse, defaults: { template: 'gameui' }
23
+ get 'purses/:id/gameui', to: 'purses#show', as: :purse_gameui, defaults: { template: 'gameui' }
22
24
  get 'purses/:id', to: 'purses#show', as: :purse, defaults: { template: 'show' }
23
25
  resources :purses
24
26
 
25
- get 'stocks/refresh', to: 'stocks#refresh', as: :refresh_stocks
27
+ get 'stocks/sync', to: 'stocks#sync', as: :sync_stocks
26
28
  resources :stocks
27
29
 
28
30
  resources :strategies
29
31
 
30
32
  namespace :api do
31
- # resources :stocks
33
+ get 'stocks', to: 'stocks#index'
34
+ get 'stocks/:ticker', to: 'stocks#show'
32
35
  get 'stocks/:ticker/period/:period', to: 'stocks#show'
33
36
  get 'stocks/:ticker/from/:begin_on', to: 'stocks#show'
34
37
  get 'stocks/:ticker/begin_on/:begin_on', to: 'stocks#show'
data/lib/iro/engine.rb CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  module Iro; end
3
+ module Tda; end
3
4
 
4
5
  class Iro::Engine < ::Rails::Engine
5
6
  isolate_namespace Iro
data/lib/iron_warbler.rb CHANGED
@@ -1,8 +1,6 @@
1
1
 
2
2
  require 'business_time'
3
-
4
3
  require 'haml'
5
-
6
4
  require 'mongoid'
7
5
 
8
6
  require "iro/engine"
@@ -55,14 +55,14 @@ namespace :iro do
55
55
 
56
56
  begin
57
57
  Timeout::timeout( 10 ) do
58
- TDA::Api.get_quotes Iro::Stock.active.map(&:ticker).join(",")
58
+ outs = Tda::Stock.get_quotes Iro::Stock.active.map(&:ticker).join(",")
59
59
  end
60
60
  rescue Exception => e
61
61
  puts! e, 'Error in iro:watch_stocks'
62
62
  # Wco::Exceptionist.notify(e, 'Error in iro:watch_stocks')
63
63
  end
64
64
 
65
- sleep Iro::Stock::SLEEP_TIME_SECONDS
65
+ sleep 15*60 # 15 min
66
66
  end
67
67
  end
68
68
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7.25
4
+ version: 2.0.7.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-19 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: business_time
@@ -217,9 +217,11 @@ files:
217
217
  - app/assets/config/iron_warbler_manifest.js
218
218
  - app/assets/javascript/iron_warbler/application.js
219
219
  - app/assets/javascript/iron_warbler/gameui.js
220
+ - app/assets/stylesheets/iron_warbler/Card.scss
220
221
  - app/assets/stylesheets/iron_warbler/application.css
221
222
  - app/assets/stylesheets/iron_warbler/positions.scss
222
223
  - app/assets/stylesheets/iron_warbler/positions_gameui.scss
224
+ - app/assets/stylesheets/iron_warbler/purses.scss
223
225
  - app/assets/stylesheets/iron_warbler/purses_gameui.scss
224
226
  - app/assets/stylesheets/iron_warbler/purses_gameui.scss-bk
225
227
  - app/assets/stylesheets/iron_warbler/purses_summary.scss
@@ -242,8 +244,9 @@ files:
242
244
  - app/models/iro/datapoint.rb
243
245
  - app/models/iro/date.rb
244
246
  - app/models/iro/option.rb
247
+ - app/models/iro/option_black_scholes.rb
245
248
  - app/models/iro/position.rb
246
- - app/models/iro/price_item.rb
249
+ - app/models/iro/priceitem.rb
247
250
  - app/models/iro/purse.rb
248
251
  - app/models/iro/stock.rb
249
252
  - app/models/iro/strategy.rb
@@ -254,20 +257,29 @@ files:
254
257
  - app/views/iro/alert_mailer/stock_alert.haml
255
258
  - app/views/iro/alerts/_form.haml
256
259
  - app/views/iro/alerts/index.haml
257
- - app/views/iro/api/stocks/show.jbuilder
260
+ - app/views/iro/api/stocks/index.json.jbuilder
261
+ - app/views/iro/api/stocks/show.json.jbuilder
262
+ - app/views/iro/api/stocks/show.json.jbuilder-bk
258
263
  - app/views/iro/application/home.haml
264
+ - app/views/iro/options/_show_mini.haml
259
265
  - app/views/iro/positions/_form.haml
260
266
  - app/views/iro/positions/_formpart_4data.haml
261
267
  - app/views/iro/positions/_gameui_covered_call.haml
262
268
  - app/views/iro/positions/_gameui_covered_call.haml-bk
263
269
  - app/views/iro/positions/_gameui_long_debit_call_spread.haml
270
+ - app/views/iro/positions/_gameui_long_debit_call_spread.haml-trash
271
+ - app/views/iro/positions/_gameui_short_credit_call_spread.haml
264
272
  - app/views/iro/positions/_gameui_short_debit_put_spread.haml
273
+ - app/views/iro/positions/_gameui_short_debit_put_spread.haml-trash
265
274
  - app/views/iro/positions/_header.haml
266
275
  - app/views/iro/positions/_header_covered_call.haml
267
276
  - app/views/iro/positions/_header_long_debit_call_spread.haml
277
+ - app/views/iro/positions/_header_short_credit_call_spread.haml
268
278
  - app/views/iro/positions/_header_short_debit_put_spread.haml
279
+ - app/views/iro/positions/_new.haml
269
280
  - app/views/iro/positions/_prepare_covered_call.haml
270
281
  - app/views/iro/positions/_prepare_long_debit_call_spread.haml
282
+ - app/views/iro/positions/_prepare_short_credit_call_spread.haml
271
283
  - app/views/iro/positions/_prepare_short_debit_put_spread.haml
272
284
  - app/views/iro/positions/_reasons.haml
273
285
  - app/views/iro/positions/_table.haml
@@ -290,6 +302,7 @@ files:
290
302
  - app/views/iro/stocks/_form.haml
291
303
  - app/views/iro/stocks/_grid_is_long.haml
292
304
  - app/views/iro/stocks/_grid_is_short.haml
305
+ - app/views/iro/stocks/edit.haml
293
306
  - app/views/iro/stocks/index.haml
294
307
  - app/views/iro/strategies/_form.haml
295
308
  - app/views/iro/strategies/_header.haml
@@ -1,11 +0,0 @@
1
-
2
- json.array! @datapoints do |p|
3
- json.date p[:quote_at].in_time_zone('UTC').to_date
4
- json.quote_at p[:quote_at]
5
- json.open p[:open]
6
- json.high p[:high]
7
- json.low p[:low]
8
- json.close p[:value]
9
- json.volume p[:volume]
10
- end
11
-
@@ -1,40 +0,0 @@
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
-