iron_warbler 2.0.7.43 → 2.0.7.46

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/iron_warbler/utils.scss +9 -9
  3. data/app/controllers/iro/api_controller.rb +9 -4
  4. data/app/controllers/iro/positions_controller.rb +68 -11
  5. data/app/controllers/iro/purses_controller.rb +7 -2
  6. data/app/controllers/iro/stocks_controller.rb +5 -1
  7. data/app/controllers/iro/strategies_controller.rb +9 -3
  8. data/app/models/tda/option.rb +4 -4
  9. data/app/views/iro/positions/_form.haml +21 -12
  10. data/app/views/iro/positions/_gameui_long_credit_put_spread.haml +1 -40
  11. data/app/views/iro/positions/{_gameui_short_debit_put_spread.haml-trash → _gameui_spread.haml} +9 -6
  12. data/app/views/iro/positions/_header_spread.haml +12 -0
  13. data/app/views/iro/positions/_new.haml +5 -0
  14. data/app/views/iro/positions/_table.haml +4 -5
  15. data/app/views/iro/positions/{_gameui_long_debit_call_spread.haml-trash → done/_gameui_long_credit_put_spread.haml} +8 -8
  16. data/app/views/iro/positions/done/_gameui_short_debit_put_spread.haml +1 -0
  17. data/app/views/iro/positions/done/_header_short_debit_put_spread.haml +1 -0
  18. data/app/views/iro/purses/_form.haml +3 -3
  19. data/app/views/iro/purses/_header.haml +10 -2
  20. data/app/views/iro/purses/index.haml +3 -2
  21. data/app/views/iro/stocks/_show_card.haml +4 -0
  22. data/app/views/iro/strategies/_form.haml +25 -13
  23. data/app/views/iro/strategies/_form_spread.haml +74 -0
  24. data/app/views/iro/strategies/_form_wheel.haml +60 -0
  25. data/app/views/iro/strategies/_header.haml +3 -1
  26. data/app/views/iro/strategies/_show.haml +2 -2
  27. data/app/views/iro/strategies/_table.haml +7 -7
  28. data/app/views/iro/strategies/edit.haml +9 -1
  29. data/app/views/iro/strategies/index.haml +4 -2
  30. data/app/views/iro/strategies/new.haml +5 -1
  31. data/app/views/iro/strategies/show.haml +3 -1
  32. data/app/views/layouts/iro/application.haml +1 -1
  33. data/config/routes.rb +3 -1
  34. data/lib/iron_warbler.rb +2 -1
  35. data/lib/tasks/iro_tasks.rake +6 -0
  36. metadata +21 -28
  37. data/app/models/iro/alert.rb +0 -63
  38. data/app/models/iro/datapoint.rb +0 -187
  39. data/app/models/iro/date.rb +0 -10
  40. data/app/models/iro/option.rb +0 -151
  41. data/app/models/iro/option_black_scholes.rb +0 -149
  42. data/app/models/iro/position.rb +0 -299
  43. data/app/models/iro/priceitem.rb +0 -93
  44. data/app/models/iro/purse.rb +0 -72
  45. data/app/models/iro/stock.rb +0 -134
  46. data/app/models/iro/strategy.rb +0 -264
  47. data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +0 -1
  48. data/app/views/iro/positions/_header_short_debit_put_spread.haml +0 -1
  49. data/app/views/iro/positions/roll.haml-trash +0 -42
  50. /data/app/views/iro/positions/{_gameui_covered_call.haml-bk → done/_gameui_covered_call.haml-bk} +0 -0
  51. /data/app/views/iro/positions/{_gameui_long_debit_call_spread.haml → done/_gameui_long_debit_call_spread.haml} +0 -0
  52. /data/app/views/iro/positions/{_gameui_short_credit_call_spread.haml → done/_gameui_short_credit_call_spread.haml} +0 -0
  53. /data/app/views/iro/positions/{_header_long_credit_put_spread.haml → done/_header_long_credit_put_spread.haml} +0 -0
  54. /data/app/views/iro/positions/{_header_long_debit_call_spread.haml → done/_header_long_debit_call_spread.haml} +0 -0
  55. /data/app/views/iro/positions/{_header_short_credit_call_spread.haml → done/_header_short_credit_call_spread.haml} +0 -0
  56. /data/app/views/iro/positions/{roll-cc.haml-bk → done/roll-cc.haml-bk} +0 -0
  57. /data/app/views/iro/purses/{gameui.haml-bk → done/gameui.haml-bk} +0 -0
  58. /data/app/views/iro/purses/{gameui.haml-bk2 → done/gameui.haml-bk2} +0 -0
  59. /data/app/views/iro/stocks/{_grid_is_long.haml → _grid_long.haml} +0 -0
  60. /data/app/views/iro/stocks/{_grid_is_short.haml → _grid_short.haml} +0 -0
@@ -1,5 +1,8 @@
1
+ -##
2
+ -## 2025-10-11 old, obsolete.
3
+ -##
1
4
 
2
- .strategies--form
5
+ .Card.strategies--form
3
6
  = form_for strategy do |f|
4
7
  .actions
5
8
  = f.submit
@@ -7,25 +10,33 @@
7
10
  .row
8
11
  .col-md-6
9
12
  .field
10
- %label Kind
11
- = f.select :kind, options_for_select( Iro::Strategy::KINDS, selected: strategy.kind )
13
+ %label Kind:
14
+ = strategy.kind
15
+ = hidden_field_tag 'strategy[kind]', params[:kind] if params[:kind]
16
+ .field
17
+ %label stock
18
+ = f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
12
19
  .field
13
20
  %label long or short?
14
21
  = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
15
22
  .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
23
+ %label credit or debit?
24
+ = f.select :credit_or_debit, options_for_select([nil, Iro::Strategy::CREDIT, Iro::Strategy::DEBIT], selected: strategy.credit_or_debit)
20
25
  .field
21
- %label slug
22
- = f.text_field :slug
26
+ %label call or put?
27
+ .comment This is selected automatically
28
+ -# = f.select :call_or_put, options_for_select([nil, 'CALL', 'PUT'], selected: strategy.credit_or_debit)
29
+
30
+ -# .col-md-6
31
+ -# .field
32
+ -# %label slug
33
+ -# = f.text_field :slug
23
34
  %hr
24
35
 
25
36
 
26
37
  .field
27
- %label Threshold Buffer dollars above water
28
- = f.number_field :threshold_buffer_above_water, placeholder: "0.49", step: 0.01
38
+ %label Buffer above water
39
+ = f.number_field :buffer_above_water, placeholder: "0.49", step: 0.01
29
40
  .field
30
41
  = f.label :threshold_dte
31
42
  = f.number_field :threshold_dte, placeholder: "1"
@@ -33,8 +44,8 @@
33
44
  -# = f.label :next_max_outer_delta
34
45
  -# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
35
46
  .field
36
- = f.label :threshold_delta
37
- = f.number_field :threshold_delta, placeholder: "0.14", step: 0.001
47
+ = f.label :threshold_pos_delta
48
+ = f.number_field :threshold_pos_delta, placeholder: "0.14", step: 0.001
38
49
  .field
39
50
  = f.label :threshold_netp
40
51
  = f.number_field :threshold_netp, placeholder: "0.69", step: 0.001
@@ -47,6 +58,7 @@
47
58
  .field
48
59
  = f.label :next_inner_strike
49
60
  = f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
61
+ .comment Literally the min (max) dollar amount of next strike
50
62
  .field
51
63
  = f.label :next_spread_amount
52
64
  = f.number_field :next_spread_amount, placeholder: "20", step: 0.1
@@ -0,0 +1,74 @@
1
+
2
+ .strategies--form
3
+ = form_for strategy do |f|
4
+ .actions
5
+ = f.submit
6
+
7
+ .row
8
+ .col-md-6
9
+ .field
10
+ %label Kind:
11
+ = f.select :kind, options_for_select(Iro::Strategy::KINDS, selected: strategy.kind || params[:kind] )
12
+ .field
13
+ %label stock
14
+ = f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
15
+ .field
16
+ %label long or short?
17
+ = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: strategy.long_or_short)
18
+ -## 2025-10-11 unnecessary: always credit.
19
+ -# .field
20
+ -# %label credit or debit?
21
+ -# = f.select :credit_or_debit, options_for_select([nil, Iro::Strategy::CREDIT, Iro::Strategy::DEBIT], selected: strategy.credit_or_debit)
22
+
23
+ -# selected automatically
24
+ .field
25
+ %label call or put?
26
+ .a
27
+ %b= strategy.put_call
28
+ .comment   This is selected automatically
29
+ -# = f.select :call_or_put, options_for_select([nil, 'CALL', 'PUT'], selected: strategy.credit_or_debit)
30
+
31
+ -# .col-md-6
32
+ -# .field
33
+ -# %label slug
34
+ -# = f.text_field :slug
35
+ %hr
36
+
37
+
38
+ .field
39
+ %label Buffer dollars above water
40
+ = f.number_field :buffer_above_water, placeholder: "0.49", step: 0.01
41
+ .field
42
+ = f.label :threshold_dte
43
+ = f.number_field :threshold_dte, placeholder: "1"
44
+ -# .field
45
+ -# = f.label :next_max_outer_delta
46
+ -# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
47
+ .field
48
+ = f.label :threshold_delta
49
+ .comment that's a best-case scenario roll
50
+ = f.number_field :threshold_pos_delta, placeholder: "0.14", step: 0.001
51
+ .field
52
+ = f.label :threshold_netp
53
+ = f.number_field :threshold_netp, placeholder: "0.69", step: 0.001
54
+
55
+ %hr
56
+
57
+ .field
58
+ = f.label :next_inner_delta
59
+ = f.number_field :next_inner_delta, placeholder: "0.25", step: 0.001
60
+ .field
61
+ = f.label :next_inner_strike
62
+ = f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
63
+ .comment Literally the min (max) dollar amount of next strike
64
+ .field
65
+ = f.label :next_spread_amount
66
+ = f.number_field :next_spread_amount, placeholder: "20", step: 0.1
67
+ .field
68
+ %label next buffer dollars above water
69
+ = f.number_field :next_buffer_above_water, placeholder: "80", step: 0.01
70
+
71
+ .actions
72
+ = f.submit
73
+
74
+
@@ -0,0 +1,60 @@
1
+
2
+ .strategies--form
3
+ = form_for strategy do |f|
4
+ .actions
5
+ = f.submit
6
+
7
+ .row
8
+ .col-md-6
9
+ .field
10
+ %label Kind:
11
+ = strategy.kind
12
+ = hidden_field_tag 'strategy[kind]', params[:kind]
13
+ .field
14
+ %label stock
15
+ = f.select :stock_id, options_for_select(@stocks_list, selected: strategy.stock_id), class: 'select2'
16
+ .field
17
+ %label long or short?
18
+ Automatically long
19
+ .field
20
+ %label credit or debit?
21
+ Debit
22
+ .field
23
+ %label call or put?
24
+ Covered call
25
+ %hr
26
+
27
+
28
+ .field
29
+ %label Threshold Buffer dollars above water
30
+ = f.number_field :threshold_buffer_above_water, placeholder: "0.49", step: 0.01
31
+ .field
32
+ = f.label :threshold_dte
33
+ = f.number_field :threshold_dte, placeholder: "1"
34
+ -# .field
35
+ -# = f.label :next_max_outer_delta
36
+ -# = f.number_field :next_max_outer_delta, placeholder: "0.25", step: 0.01
37
+ .field
38
+ = f.label :threshold_delta
39
+ = f.number_field :threshold_delta, placeholder: "0.14", step: 0.001
40
+ .field
41
+ = f.label :threshold_netp
42
+ = f.number_field :threshold_netp, placeholder: "0.69", step: 0.001
43
+
44
+ %hr
45
+
46
+ .field
47
+ = f.label :next_inner_delta
48
+ = f.number_field :next_inner_delta, placeholder: "0.25", step: 0.001
49
+ .field
50
+ = f.label :next_inner_strike
51
+ = f.number_field :next_inner_strike, placeholder: "20.0", step: 0.01
52
+ .comment Literally the min (max) dollar amount of next strike
53
+ .field
54
+ %label next buffer dollars above water
55
+ = f.number_field :next_buffer_above_water, placeholder: "80", step: 0.01
56
+
57
+ .actions
58
+ = f.submit
59
+
60
+
@@ -3,6 +3,8 @@
3
3
  .inline-search
4
4
  = form_tag strategies_path, method: :get do
5
5
  = text_field_tag :q
6
- = link_to '[+]', new_strategy_path
6
+ -# = link_to '[+spread]', new_spread_strategy_path
7
+ -# = link_to '[+wheel]', new_wheel_strategy_path
8
+
7
9
 
8
10
 
@@ -8,8 +8,8 @@
8
8
  -# %li <b>ticker:</b> #{strategy.ticker}
9
9
  -# %li <b>slug:</b> #{strategy.slug}
10
10
 
11
- %li <b>threshold_buffer_above_water:</b> #{strategy.threshold_buffer_above_water}
12
- %li <b>threshold_delta:</b> #{strategy.threshold_delta}
11
+ %li <b>buffer_above_water:</b> #{strategy.buffer_above_water}
12
+ %li <b>threshold_pos_delta:</b> #{strategy.threshold_pos_delta}
13
13
  %li <b>threshold_netp:</b> #{strategy.threshold_netp}
14
14
 
15
15
  %hr
@@ -7,11 +7,12 @@
7
7
  %thead
8
8
  %tr
9
9
  %th.actions &nbsp;
10
- %th kind
11
- %th slug
12
10
  %th stock
11
+ %th kind
13
12
  %th long or short
13
+ %th put_call
14
14
  %th next_inner_delta
15
+ %th slug
15
16
  %th.actions &nbsp;
16
17
  %tbody
17
18
  - strategies.each do |sss|
@@ -20,13 +21,12 @@
20
21
  .d-flex
21
22
  = link_to '[~]', edit_strategy_path(sss)
22
23
  = button_to 'x', strategy_path(sss), method: :delete, data: { confirm: 'Are you sure?' }
24
+ %td.stock= sss.stock
23
25
  %td= sss.kind
24
- %td= link_to sss.slug, strategy_path(sss)
25
- %td.stock
26
- = sss.stock
27
- %td.long-or-short
28
- = sss.long_or_short
26
+ %td.long-or-short= sss.long_or_short
27
+ %td.put-call= sss.put_call
29
28
  %td= sss.next_inner_delta
29
+ %td= link_to sss.slug, strategy_path(sss)
30
30
  %td
31
31
  = form_tag propose_position_path do
32
32
  = hidden_field_tag :strategy_id, sss.id
@@ -1,3 +1,11 @@
1
1
 
2
2
  .strategies-edit.maxwidth
3
- = render 'form', strategy: @strategy
3
+ .row
4
+ .col-md-9
5
+ - if @strategy.kind == Iro::Strategy::KIND_LONG_CREDIT_PUT_SPREAD
6
+ .Card= render "form_spread", strategy: @strategy
7
+ - else
8
+ %b _TODO: review strategies/edit, incorporate strategies other than KIND_LONG_CREDIT_PUT_SPREAD
9
+
10
+ .col-md-3= render 'iro/stocks/show_card', stock: @strategy.stock
11
+
@@ -2,7 +2,9 @@
2
2
  .maxwidth
3
3
  .header
4
4
  %h5.title
5
- Strategies
6
- = link_to '[+]', iro.new_strategy_path
5
+ Strategies &nbsp;
6
+ -# = link_to '[+spread]', iro.new_spread_strategy_path
7
+ -# = link_to '[+wheel]', iro.new_wheel_strategy_path
8
+ = link_to '[+put-spread]', iro.new_strategy_path( kind: Iro::Strategy::KIND_LONG_CREDIT_PUT_SPREAD )
7
9
 
8
10
  = render '/iro/strategies/table', strategies: @strategies
@@ -1,3 +1,7 @@
1
1
 
2
2
  .maxwidth
3
- = render 'form', strategy: @strategy
3
+ - if params[:kind] == Iro::Strategy::KIND_LONG_CREDIT_PUT_SPREAD
4
+ = render "form_spread", strategy: @strategy
5
+ - else
6
+ %b review strategies/new, incorporate strategies other than KIND_LONG_CREDIT_PUT_SPREAD
7
+
@@ -1,7 +1,9 @@
1
1
 
2
2
  .strategies-show.maxwidth
3
3
  .header
4
- %h5.title Strategy #{@strategy}
4
+ %h5.title
5
+ Strategy `#{@strategy}`
6
+ = link_to '[~]', edit_strategy_path(@strategy)
5
7
  %ul
6
8
  -# %li Purse #{@strategy.purses}
7
9
  -# %li= link_to 'Next position', strategy_next_position_path(@strategy)
@@ -43,7 +43,7 @@
43
43
 
44
44
  = render "/wco/main_header"
45
45
  = render "/iro/main_header"
46
- = render '/wco/alerts_notices' if notice || alert
46
+ = render '/wco/application/alerts_notices' if notice || alert
47
47
  .spacer-small
48
48
 
49
49
  %span.absolute.collapse-expand#mainW
data/config/routes.rb CHANGED
@@ -23,7 +23,7 @@ Iro::Engine.routes.draw do
23
23
  resources :profiles
24
24
 
25
25
  get 'purses/:id/gameui', to: 'purses#show', as: :purse_gameui, defaults: { template: 'gameui' }
26
- get 'purses/:id', to: 'purses#show', as: :purse, defaults: { template: 'show' }
26
+ get 'purses/:id', to: 'purses#show', as: :purse # , defaults: { template: 'show' }
27
27
  resources :purses
28
28
 
29
29
  get 'schwab/sync', to: 'application#schwab_sync', as: :schwab_sync
@@ -31,6 +31,8 @@ Iro::Engine.routes.draw do
31
31
  get 'stocks/sync', to: 'stocks#sync', as: :sync_stocks
32
32
  resources :stocks
33
33
 
34
+ # get 'strategies/new-spread', to: 'strategies#new', as: :new_spread_strategy, defaults: { kind: 'spread' }
35
+ # get 'strategies/new-wheel', to: 'strategies#new', as: :new_wheel_strategy, defaults: { kind: 'wheel' }
34
36
  resources :strategies
35
37
 
36
38
  get 'api/oauth2-redirect.html', to: 'api#oauth2_redirect'
data/lib/iron_warbler.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'business_time'
3
3
  require 'haml'
4
4
  require 'mongoid'
5
+ require 'httparty'
5
6
 
6
7
  require "iro/engine"
7
8
 
@@ -178,7 +179,7 @@ class Iro::Iro
178
179
  },
179
180
  })
180
181
  out = out.parsed_response
181
- puts! out, 'out'
182
+ puts! out, '#schwab_sync'
182
183
 
183
184
  attrs = {
184
185
  schwab_access_token: out['access_token'],
@@ -73,6 +73,12 @@ namespace :iro do
73
73
  Iro::Position.active.where({ kind: 'covered_call' }).map &:refresh
74
74
  end
75
75
 
76
+ desc 'sync schwab'
77
+ task sync_schwab: :environment do
78
+ Iro::Iro.schwab_sync
79
+ puts '.'
80
+ end
81
+
76
82
  desc 'watch positions'
77
83
  task watch_positions: :environment do
78
84
  while true
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.43
4
+ version: 2.0.7.46
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-08-22 00:00:00.000000000 Z
11
+ date: 2026-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: business_time
@@ -242,16 +242,6 @@ files:
242
242
  - app/jobs/tda_job.rb-bk
243
243
  - app/mailers/iro/alert_mailer.rb
244
244
  - app/mailers/iro/application_mailer.rb
245
- - app/models/iro/alert.rb
246
- - app/models/iro/datapoint.rb
247
- - app/models/iro/date.rb
248
- - app/models/iro/option.rb
249
- - app/models/iro/option_black_scholes.rb
250
- - app/models/iro/position.rb
251
- - app/models/iro/priceitem.rb
252
- - app/models/iro/purse.rb
253
- - app/models/iro/stock.rb
254
- - app/models/iro/strategy.rb
255
245
  - app/models/tda/option.rb
256
246
  - app/models/tda/stock.rb
257
247
  - app/views/iro/_analytics.erb
@@ -269,19 +259,11 @@ files:
269
259
  - app/views/iro/positions/_form.haml
270
260
  - app/views/iro/positions/_formpart_4data.haml
271
261
  - app/views/iro/positions/_gameui_covered_call.haml
272
- - app/views/iro/positions/_gameui_covered_call.haml-bk
273
262
  - app/views/iro/positions/_gameui_long_credit_put_spread.haml
274
- - app/views/iro/positions/_gameui_long_debit_call_spread.haml
275
- - app/views/iro/positions/_gameui_long_debit_call_spread.haml-trash
276
- - app/views/iro/positions/_gameui_short_credit_call_spread.haml
277
- - app/views/iro/positions/_gameui_short_debit_put_spread.haml
278
- - app/views/iro/positions/_gameui_short_debit_put_spread.haml-trash
263
+ - app/views/iro/positions/_gameui_spread.haml
279
264
  - app/views/iro/positions/_header.haml
280
265
  - app/views/iro/positions/_header_covered_call.haml
281
- - app/views/iro/positions/_header_long_credit_put_spread.haml
282
- - app/views/iro/positions/_header_long_debit_call_spread.haml
283
- - app/views/iro/positions/_header_short_credit_call_spread.haml
284
- - app/views/iro/positions/_header_short_debit_put_spread.haml
266
+ - app/views/iro/positions/_header_spread.haml
285
267
  - app/views/iro/positions/_new.haml
286
268
  - app/views/iro/positions/_prepare_covered_call.haml
287
269
  - app/views/iro/positions/_prepare_long_debit_call_spread.haml
@@ -289,29 +271,40 @@ files:
289
271
  - app/views/iro/positions/_prepare_short_debit_put_spread.haml
290
272
  - app/views/iro/positions/_reasons.haml
291
273
  - app/views/iro/positions/_table.haml
274
+ - app/views/iro/positions/done/_gameui_covered_call.haml-bk
275
+ - app/views/iro/positions/done/_gameui_long_credit_put_spread.haml
276
+ - app/views/iro/positions/done/_gameui_long_debit_call_spread.haml
277
+ - app/views/iro/positions/done/_gameui_short_credit_call_spread.haml
278
+ - app/views/iro/positions/done/_gameui_short_debit_put_spread.haml
279
+ - app/views/iro/positions/done/_header_long_credit_put_spread.haml
280
+ - app/views/iro/positions/done/_header_long_debit_call_spread.haml
281
+ - app/views/iro/positions/done/_header_short_credit_call_spread.haml
282
+ - app/views/iro/positions/done/_header_short_debit_put_spread.haml
283
+ - app/views/iro/positions/done/roll-cc.haml-bk
292
284
  - app/views/iro/positions/edit.haml
293
285
  - app/views/iro/positions/new.haml
294
286
  - app/views/iro/positions/prepare.haml
295
287
  - app/views/iro/positions/prepare2.haml
296
- - app/views/iro/positions/roll-cc.haml-bk
297
- - app/views/iro/positions/roll.haml-trash
298
288
  - app/views/iro/purses/_form.haml
299
289
  - app/views/iro/purses/_form_extra_fields.haml
300
290
  - app/views/iro/purses/_header.haml
301
291
  - app/views/iro/purses/_summary.haml
292
+ - app/views/iro/purses/done/gameui.haml-bk
293
+ - app/views/iro/purses/done/gameui.haml-bk2
302
294
  - app/views/iro/purses/edit.haml
303
295
  - app/views/iro/purses/gameui.haml
304
- - app/views/iro/purses/gameui.haml-bk
305
- - app/views/iro/purses/gameui.haml-bk2
306
296
  - app/views/iro/purses/index.haml
307
297
  - app/views/iro/purses/show.haml
308
298
  - app/views/iro/stocks/_form.haml
309
- - app/views/iro/stocks/_grid_is_long.haml
310
- - app/views/iro/stocks/_grid_is_short.haml
299
+ - app/views/iro/stocks/_grid_long.haml
300
+ - app/views/iro/stocks/_grid_short.haml
301
+ - app/views/iro/stocks/_show_card.haml
311
302
  - app/views/iro/stocks/edit.haml
312
303
  - app/views/iro/stocks/index.haml
313
304
  - app/views/iro/stocks/show.haml
314
305
  - app/views/iro/strategies/_form.haml
306
+ - app/views/iro/strategies/_form_spread.haml
307
+ - app/views/iro/strategies/_form_wheel.haml
315
308
  - app/views/iro/strategies/_header.haml
316
309
  - app/views/iro/strategies/_show.haml
317
310
  - app/views/iro/strategies/_table.haml
@@ -1,63 +0,0 @@
1
-
2
- class Iro::Alert
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
- include Mongoid::Paranoia
6
- store_in collection: 'iro_alerts'
7
-
8
- # SLEEP_TIME_SECONDS = Rails.env.production? ? 60 : 15
9
-
10
- DIRECTION_ABOVE = 'ABOVE'
11
- DIRECTION_BELOW = 'BELOW'
12
- def self.directions_list
13
- [ nil, DIRECTION_ABOVE, DIRECTION_BELOW ]
14
- end
15
-
16
- STATUS_ACTIVE = 'active'
17
- STATUS_INACTIVE = 'inactive'
18
- STATUSES = [ nil, 'active', 'inactive' ]
19
- field :status, default: STATUS_ACTIVE
20
- def self.active
21
- where( status: STATUS_ACTIVE )
22
- end
23
-
24
- field :class_name, default: 'Iro::Stock'
25
- validates :class_name, presence: true
26
-
27
- field :symbol, type: String
28
- validates :symbol, presence: true
29
-
30
- field :direction, type: String
31
- validates :direction, presence: true
32
-
33
- field :strike, type: Float
34
- validates :strike, presence: true
35
-
36
- def do_run
37
- alert = self
38
- begin
39
- price = Tda::Stock.get_quote( alert.symbol )&.last
40
- return if !price
41
-
42
- if ( alert.direction == alert.class::DIRECTION_ABOVE && price >= alert.strike ) ||
43
- ( alert.direction == alert.class::DIRECTION_BELOW && price <= alert.strike )
44
-
45
- if Rails.env.production?
46
- Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_later
47
- else
48
- Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_now
49
- end
50
- alert.update({ status: alert.class::STATUS_INACTIVE })
51
- print '^'
52
-
53
- end
54
- rescue => err
55
- puts! err, 'err'
56
- ::ExceptionNotifier.notify_exception(
57
- err,
58
- data: { alert: alert }
59
- )
60
- end
61
- end
62
-
63
- end