ish_manager 0.1.8.450 → 0.1.8.452

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ish_manager/iro.js +54 -39
  3. data/app/assets/javascripts/ish_manager/iro0.js +68 -0
  4. data/app/assets/stylesheets/ish_manager/application.scss +3 -1
  5. data/app/assets/stylesheets/ish_manager/iro.scss +39 -9
  6. data/app/assets/stylesheets/ish_manager/iro1.scss +117 -0
  7. data/app/controllers/ish_manager/iro_option_gets_controller.rb +127 -0
  8. data/app/controllers/ish_manager/iro_positions_controller.rb +0 -9
  9. data/app/controllers/ish_manager/iro_purses_controller.rb +49 -8
  10. data/app/controllers/ish_manager/iro_watches_controller.rb +1 -0
  11. data/app/controllers/ish_manager/products_controller.rb +15 -0
  12. data/app/controllers/ish_manager/subscriptions_controller.rb +19 -0
  13. data/app/helpers/ish_manager/application_helper.rb +9 -0
  14. data/app/views/ish_manager/application/_main_header_admin.haml +17 -5
  15. data/app/views/ish_manager/application/home.haml +17 -1
  16. data/app/views/ish_manager/email_templates/_acknowledgement_of_document_receipt.html.erb +23 -0
  17. data/app/views/ish_manager/email_templates/_marketing_ror_3.html.erb +25 -0
  18. data/app/views/ish_manager/email_templates/_marketing_ror_4.html.erb +25 -0
  19. data/app/views/ish_manager/email_templates/_marketing_ror_5.html.erb +17 -0
  20. data/app/views/ish_manager/email_templates/_rec_resume_shared_with_you.html.erb +39 -0
  21. data/app/views/ish_manager/email_templates/_support_ticket_created.html.erb +26 -0
  22. data/app/views/ish_manager/iro_option_gets/_form.haml +10 -0
  23. data/app/views/ish_manager/iro_positions/_form.haml +73 -37
  24. data/app/views/ish_manager/iro_purses/_form.haml +3 -0
  25. data/app/views/ish_manager/iro_purses/_header.haml +29 -0
  26. data/app/views/ish_manager/iro_purses/_show.haml +118 -0
  27. data/app/views/ish_manager/iro_purses/_show_gameui_0.haml +62 -0
  28. data/app/views/ish_manager/iro_purses/_show_gameui_1.haml +78 -0
  29. data/app/views/ish_manager/iro_purses/show.haml +3 -114
  30. data/app/views/ish_manager/iro_purses/show_gameui.haml +4 -163
  31. data/app/views/ish_manager/iro_watches/index.haml +10 -1
  32. data/app/views/ish_manager/iro_watches/max_pain.haml +21 -0
  33. data/app/views/ish_manager/products/index.haml +7 -0
  34. data/app/views/ish_manager/subscriptions/index.haml +46 -0
  35. data/app/views/layouts/ish_manager/application.haml +5 -0
  36. data/config/routes.rb +10 -3
  37. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aae4da7ba3885ffd17336f35ea137c76c3175c1e22fad1d80692347238c6450e
4
- data.tar.gz: ff00d90a46a00ee7f778a0f7bbf7b8f3dd808f531a41405ae8a0fe4a8a1d1a62
3
+ metadata.gz: 07f21609640dbe8208ee3874d6b249430abcdded538d3885a99a79ca8e7c6e53
4
+ data.tar.gz: 5e0a1d0c3b190ad641e71aae2f1fac1fda1d55e880d560dc7e7038754ec96a04
5
5
  SHA512:
6
- metadata.gz: 8c2a0d24958ffce7046fedf256a1ca8af7664ecc3f2613c99a8b8ee54bceb3d429870e7225e237028600ea9534b5f2fe6406756e48971c9e255147839d51252f
7
- data.tar.gz: 84b403938f9da24ff7ad223bc22c7fecfbf9293e73dda2b34f5887a5c78021f064459dd9134ab4bf1d38edc93c5d8961ff06ad3bb02aebec9c413058a1c73ac1
6
+ metadata.gz: 277b32101ba85d7efd36bd68a0841e8eae8711a777573de6082eac2ec9733d0ce0c391bbdb9ec45c7a0adf4c0b9dffb8ea7f230bb8fd46ac72e31ed1ab7fe3c7
7
+ data.tar.gz: 4d7d19ca7e698415d7a32b5c2ea6ffa5590a647012691f1bfd877b8c8aa65412651e91e17d68abe3782299cd82a9713019c8b97a8d3ef97274e02429fc46ad0e
@@ -1,59 +1,51 @@
1
1
 
2
2
  $(document).ready(function () {
3
3
 
4
- const origin = 23
5
- scale = 200 // pixels per dollar
4
+ const dollarWidth = $('.gameui-positions').data('ccDollarwidth')
5
+ const origin = $('.gameui-positions').data('ccOrigin')
6
+ const cUS = $(".gameui-positions").data('ccCus')
6
7
 
8
+ $(".step").css('height', `${dollarWidth * .75}px`)
9
+ $(".gameui").css('height', `${dollarWidth}px`)
10
+ $('.windW').css('left', `${dollarWidth * (origin - cUS)}px`)
11
+ $('.gameuiCUS').css('left', `${dollarWidth * (origin - cUS)}px`)
7
12
 
8
-
9
- $(".gameuiW").each( function (idx, w) {
13
+ $(".elephantW").each( function (idx, w) {
10
14
  // logg($(w).data(), 'data')
11
15
 
12
- let ans
13
-
14
16
  let ccStrike = $(w).data('ccStrike')
15
17
  let ccStartPrice = $(w).data('ccStartprice') // e.g. 0.88
16
18
  let ccCurrentPrice = $(w).data('ccCurrentprice')
17
- let cUS = $(w).data('ccCus')
18
-
19
- $(".c-u-s").each(function (idx, elem) {
20
- $(elem).html(cUS)
21
- })
22
-
23
- $(".windW").each(function (idx, elem) {
24
- ans = ( origin - cUS ) * scale
25
- $(elem).css('left', ans)
26
- })
27
-
28
- $($(w).find('.elephantW')).css('left', (origin - ccStrike)* scale )
29
- $(w).find('.elephantC > .amount').html( " $" + ccStrike )
30
- $(w).find('.riderStart > .amount').html( " $" + ccStartPrice )
31
- $(w).find('.riderStart').css('width', scale * ccStartPrice )
32
- $(w).find('.riderStart').css('left', -1 * scale * ccStartPrice )
33
- $(w).find('.riderStart2').css('width', scale * ccStartPrice )
34
-
35
- let currentAmount = ((ccStartPrice - ccCurrentPrice)*100).toPrecision(2)/100
36
- let ccCurrentGain = ccStartPrice - ccCurrentPrice
37
- $(w).find('.riderCurrent > .amount').html( " $" + currentAmount )
38
- ans = `${-1*ccCurrentGain*scale}px`
39
- $(w).find('.riderW').css('left', ans)
40
-
41
- if (ccCurrentGain > 0) {
42
- $(w).find('.riderCurrent').css('width', scale * ccCurrentGain )
19
+
20
+ let loss = ccCurrentPrice - ccStartPrice;
21
+
22
+ $(w).css('left', `${dollarWidth * (origin-ccStrike)}px` );
23
+ // $(w).find('.elephantW').css('width', `${dollarWidth * ccStartPrice}px` );
24
+ $(w).css('height', `${dollarWidth * ccStartPrice}px` );
25
+ $(w).find('.elephant ').css('left', `-${dollarWidth * (ccStartPrice)}px` );
26
+ $(w).find('.elephant ').css('width', `${dollarWidth * (ccStartPrice)}px` );
27
+ $(w).find('.elephant ').css('height', `${dollarWidth * (ccStartPrice)}px` );
28
+ $(w).find('.elephant ').css('border-radius', `${dollarWidth * (ccStartPrice)}px ${dollarWidth * (ccStartPrice)}px 0 0` );
29
+ $(w).find('.elephantC > .amount').html( " $" + ccStartPrice )
30
+ if (loss > 0) {
31
+ $(w).find('.elephantC ').css('left', `-${dollarWidth * (ccStartPrice - loss)}px` );
32
+ $(w).find('.elephantC ').css('width', `${dollarWidth * (ccStartPrice - loss)}px` );
33
+ $(w).find('.elephantC ').css('height', `${dollarWidth * (ccStartPrice - loss)}px` );
34
+ $(w).find('.elephantC ').css('border-radius', `${dollarWidth * (ccStartPrice - loss)}px ${dollarWidth * (ccStartPrice - loss)}px 0 0` );
35
+ $(w).find('.elephant').css('border-color', 'red');
36
+ $(w).find('.elephantC ').css('border-color', 'red');
43
37
  } else {
44
- $(w).find('.riderCurrent').css('display', 'none')
45
- $(w).find('.riderCurrent2').css('display', 'block')
46
- $(w).find('.riderCurrent2').css('width', -1 * scale * ccCurrentGain )
47
- $(w).find('.rider').addClass('riderF')
38
+ $(w).find('.elephantC ').css('left', `-${dollarWidth * (ccCurrentPrice)}px` );
39
+ $(w).find('.elephantC ').css('width', `${dollarWidth * (ccCurrentPrice)}px` );
40
+ $(w).find('.elephantC ').css('height', `${dollarWidth * (ccCurrentPrice)}px` );
41
+ $(w).find('.elephantC ').css('border-radius', `${dollarWidth * (ccCurrentPrice)}px ${dollarWidth * (ccCurrentPrice)}px 0 0` );
48
42
  }
49
43
  })
50
44
 
51
45
 
52
46
 
53
47
  $(".gameuiW.next-position").each( function (idx, w) {
54
- logg($(w).data(), 'next-position')
55
-
56
- let ans
48
+ // logg($(w).data(), 'next-position')
57
49
 
58
50
  let gainp = $(w).data('ccGainp')
59
51
  if (gainp > 0) {
@@ -65,4 +57,27 @@ $(document).ready(function () {
65
57
  }
66
58
  })
67
59
 
60
+ $(".recklessDefenseW").each( function(idx, w) {
61
+ let longStrike = $(w).data('ccLongstrike')
62
+ // logg(longStrike, 'longStrike')
63
+ let shortStrike = $(w).data('ccShortstrike')
64
+ let shortOpenedPrice = $(w).data('ccShortopenedprice')
65
+ let shortCurrentPrice = $(w).data('ccShortcurrentprice')
66
+ let longOpenedPrice = $(w).data('ccLongopenedprice')
67
+ let longCurrentPrice = $(w).data('ccLongcurrentprice')
68
+
69
+ $(w).css('left', `-${dollarWidth * ( origin - longStrike )}px` )
70
+ $(w).css('width', `${dollarWidth * (shortStrike - longStrike - shortOpenedPrice + longOpenedPrice )}px`)
71
+
72
+ let gainLoss = longCurrentPrice - longOpenedPrice + shortOpenedPrice - shortCurrentPrice
73
+ if (gainLoss > 0) {
74
+ $(w).find('.recklessDefenseC').css('left', `${dollarWidth * gainLoss}px`)
75
+ } else {
76
+ $(w).find('.recklessDefenseC').css('left', `${dollarWidth * gainLoss}px`)
77
+ $(w).css('border-color', 'red')
78
+ $(w).find('.recklessDefenseC').css('border-color', 'red')
79
+ }
80
+ })
81
+
82
+
68
83
  })
@@ -0,0 +1,68 @@
1
+
2
+ $(document).ready(function () {
3
+
4
+ const origin = 23
5
+ scale = 200 // pixels per dollar
6
+
7
+
8
+
9
+ $(".gameuiW").each( function (idx, w) {
10
+ // logg($(w).data(), 'data')
11
+
12
+ let ans
13
+
14
+ let ccStrike = $(w).data('ccStrike')
15
+ let ccStartPrice = $(w).data('ccStartprice') // e.g. 0.88
16
+ let ccCurrentPrice = $(w).data('ccCurrentprice')
17
+ let cUS = $(w).data('ccCus')
18
+
19
+ $(".c-u-s").each(function (idx, elem) {
20
+ $(elem).html(cUS)
21
+ })
22
+
23
+ $(".windW").each(function (idx, elem) {
24
+ ans = ( origin - cUS ) * scale
25
+ $(elem).css('left', ans)
26
+ })
27
+
28
+ $($(w).find('.elephantW')).css('left', (origin - ccStrike)* scale )
29
+ $(w).find('.elephantC > .amount').html( " $" + ccStrike )
30
+ $(w).find('.riderStart > .amount').html( " $" + ccStartPrice )
31
+ $(w).find('.riderStart').css('width', scale * ccStartPrice )
32
+ $(w).find('.riderStart').css('left', -1 * scale * ccStartPrice )
33
+ $(w).find('.riderStart2').css('width', scale * ccStartPrice )
34
+
35
+ let currentAmount = ((ccStartPrice - ccCurrentPrice)*100).toPrecision(2)/100
36
+ let ccCurrentGain = ccStartPrice - ccCurrentPrice
37
+ $(w).find('.riderCurrent > .amount').html( " $" + currentAmount )
38
+ ans = `${-1*ccCurrentGain*scale}px`
39
+ $(w).find('.riderW').css('left', ans)
40
+
41
+ if (ccCurrentGain > 0) {
42
+ $(w).find('.riderCurrent').css('width', scale * ccCurrentGain )
43
+ } else {
44
+ $(w).find('.riderCurrent').css('display', 'none')
45
+ $(w).find('.riderCurrent2').css('display', 'block')
46
+ $(w).find('.riderCurrent2').css('width', -1 * scale * ccCurrentGain )
47
+ $(w).find('.rider').addClass('riderF')
48
+ }
49
+ })
50
+
51
+
52
+
53
+ $(".gameuiW.next-position").each( function (idx, w) {
54
+ logg($(w).data(), 'next-position')
55
+
56
+ let ans
57
+
58
+ let gainp = $(w).data('ccGainp')
59
+ if (gainp > 0) {
60
+ $(w).find('.elephant').css('border-width', `${gainp*200 + 1}px` )
61
+ $(w).find('.elephantLoss').css('display', 'none')
62
+ } else {
63
+ gainp = -1 * gainp
64
+ $(w).find('.elephantLoss').css('border-width', `${gainp*200 + 1}px` )
65
+ }
66
+ })
67
+
68
+ })
@@ -13,6 +13,7 @@
13
13
  *
14
14
  *= require ish_manager/galleries
15
15
  *= require ish_manager/iro
16
+ *= require ish_manager/iro1
16
17
  *= require ish_manager/leads_leadsets
17
18
  *= require ish_manager/maps
18
19
  *= require ish_manager/markers
@@ -91,7 +92,8 @@ ul:not(.browser-default).bullets, {
91
92
  }
92
93
  .application-home {
93
94
  .bordered-card {
94
- max-width: 400px;
95
+ display: inline-block;
96
+ // max-width: 400px;
95
97
  }
96
98
  }
97
99
 
@@ -1,4 +1,14 @@
1
1
 
2
+ .iro-positions--form {
3
+ border: 1px dashed blue;
4
+ border-radius: 0.5em;
5
+ padding: 0.5em;
6
+
7
+ .field {
8
+ display: flex;
9
+ }
10
+ }
11
+
2
12
  .iro-purses--form {
3
13
  textarea {
4
14
  min-width: 500px;
@@ -8,6 +18,7 @@
8
18
 
9
19
  .iro-purses-show,
10
20
  .iro-purses-show-gameui,
21
+ .iro-purses-show-gameui-1,
11
22
  ._ {
12
23
  font-size: 14px;
13
24
 
@@ -31,6 +42,10 @@
31
42
  .price {
32
43
  background: cyan;
33
44
  }
45
+ .to-close {
46
+ background: #333;
47
+ color: white;
48
+ }
34
49
 
35
50
  td {
36
51
  // border: 1px solid red;
@@ -90,11 +105,10 @@
90
105
  font-weight: bold;
91
106
  }
92
107
 
93
- .strategies {
94
- display: flex;
95
- flex-wrap: wrap;
96
- }
97
-
108
+ }
109
+ .iro-strategies {
110
+ display: flex;
111
+ flex-wrap: wrap;
98
112
  }
99
113
  .iro-strategies-edit,
100
114
  .iro-strategies-new {
@@ -114,6 +128,21 @@
114
128
  }
115
129
  }
116
130
 
131
+ .iro-position-statuses-selector form {
132
+ display: flex;
133
+ margin: 1em 0 0 0;
134
+
135
+ .field {
136
+ border: 1px solid gray;
137
+ border-radius: .5em;
138
+ padding: 0 1em;
139
+ margin-right: 1em;
140
+
141
+ display: flex;
142
+ flex-direction: row-reverse;
143
+ }
144
+ }
145
+
117
146
 
118
147
 
119
148
 
@@ -124,7 +153,7 @@
124
153
  * GameUI in Purse
125
154
  * 2023-04-06 _vp_ Continue
126
155
  **/
127
- .gameuiW {
156
+ .iro-purses-show-gameui .gameuiW {
128
157
  border: 1px solid #ff9966;
129
158
  border-radius: 1em;
130
159
 
@@ -216,11 +245,12 @@
216
245
  .elephantC {
217
246
  // border: 10px solid black;
218
247
 
219
- z-index: 1;
248
+
220
249
  position: absolute;
221
250
  color: #333;
222
251
  background: #ddd;
223
252
  display: inline-block;
253
+ z-index: 2;
224
254
 
225
255
  .q {
226
256
  border: 2px solid #eee;
@@ -404,8 +434,8 @@
404
434
  position: relative;
405
435
  z-index: 2;
406
436
 
407
- background: #333;
408
- color: white;
437
+ background: yellow;
438
+ // color: white;
409
439
  display: inline-block
410
440
  }
411
441
 
@@ -0,0 +1,117 @@
1
+
2
+ .show-gameui-1 {
3
+ // background: red;
4
+ position: relative;
5
+
6
+ .gameuiCUSW {
7
+ position: absolute;
8
+ left: 50%;
9
+ top: 0;
10
+ .gameuiCUS {
11
+ position: absolute;
12
+ border-left: 2px dashed blue;
13
+ padding: 0 10px;
14
+ width: 100px;
15
+ }
16
+ }
17
+ .gameuiW {
18
+ // border: 1px solid red;
19
+
20
+ .gameui {
21
+ // border: 1px solid black;
22
+ position: relative;
23
+ border-bottom: 10px solid gray;
24
+
25
+ background: url('https://d15g8hc4183yn4.cloudfront.net/wp-content/uploads/2023/07/13184511/200x200-grid2.png');
26
+ background-position: 50% center;
27
+ width: 100%;
28
+
29
+ .gameuiC {
30
+ // border: 1px solid green;
31
+ border-bottom: 10px solid green;
32
+
33
+ width: 50%;
34
+ height: 100%;
35
+
36
+ position: absolute;
37
+ left: 50%;
38
+ bottom: -10px;
39
+
40
+ .elephantW {
41
+ border: 0px solid cyan;
42
+ width: 1px;
43
+ height: 100%;
44
+
45
+ position: absolute;
46
+ bottom: 0;
47
+
48
+ > .amount {
49
+ // border: 3px solid black;
50
+
51
+ position: absolute;
52
+ left: 0;
53
+ bottom: 0;
54
+ }
55
+ > .strike {
56
+ position: absolute;
57
+ height: 1.4 em;
58
+ bottom: 0;
59
+ background: yellow;
60
+
61
+ right: 0;
62
+ width: 69px;
63
+ border-right: 2px solid black;
64
+
65
+ padding: 0 5px;
66
+ }
67
+ .elephant {
68
+ border: 2px dashed green;
69
+ position: absolute;
70
+ bottom: 0;
71
+ }
72
+
73
+
74
+ .elephantC {
75
+ position: absolute;
76
+ bottom: 0;
77
+
78
+ border: 2px dashed green;
79
+
80
+ // color: white;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+
85
+ }
86
+ }
87
+
88
+ .windW {
89
+ border: 2px dashed blue;
90
+ width: 1px;
91
+ height: 100%;
92
+ position: absolute;
93
+ // left: calc( 200px * ( 23.5 - 23.46 ) );
94
+
95
+ }
96
+
97
+ .recklessDefenseW {
98
+ height: 20px;
99
+ border: 2px dashed green;
100
+
101
+ position: absolute;
102
+ bottom: 5px;
103
+
104
+ .recklessDefense {
105
+ .recklessDefenseC {
106
+ height: 20px;
107
+ border-left: 2px dashed green;
108
+ position: absolute;
109
+ right: 0;
110
+ }
111
+ }
112
+ }
113
+
114
+ }
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,127 @@
1
+
2
+ class ::IshManager::IroOptionGetsController < IshManager::ApplicationController
3
+
4
+ # before_action :set_lists
5
+
6
+ def create
7
+ @item = Iro::OptionGet.new params[:iro_option_get].permit!
8
+ @item.kind = Iro::OptionGet::KIND_GET_CHAINS
9
+ authorize! :create, @item
10
+ flag = @item.save
11
+ if flag
12
+ flash[:notice] = 'Created option_get.'
13
+ else
14
+ flash[:alert] = "Cannot create option_get: #{@item.errors.full_messages.join(', ')}."
15
+ end
16
+ redirect_to action: 'index', controller: 'ish_manager/iro_watches'
17
+ end
18
+
19
+ def max_pain
20
+ @ticker = params[:ticker]
21
+ @date = params[:date].to_time.to_i
22
+
23
+ ## 1689364800000
24
+ ## Fri, 14 Jul 2023 15:00:00.000000000 CDT -05:00
25
+
26
+ authorize! :max_pain, Iro::Iro
27
+
28
+ @expirationDate = ( params[:date].to_date + 15.hours ).to_time.to_i * 1000 # '1689364800000'
29
+ # expirationDate = '1689969600000'
30
+ # expirationDate = '1690574400000'
31
+ @all_items = {}
32
+
33
+ calls_sql = "select distinct symbol, strikePrice, putCall, openInterest
34
+ from iro_option_price_items
35
+ where expirationDate = #{@expirationDate} and putCall = 'CALL' and ticker = '#{@ticker}'
36
+ group by symbol, strikePrice, putCall
37
+ order by putCall, strikePrice, created_at desc;"
38
+ @calls_items = []
39
+ @calls_array = ActiveRecord::Base.connection.execute(calls_sql)
40
+ calls_subtotal = 0
41
+ @calls_array.each do |_item|
42
+ item = {
43
+ symbol: _item[0],
44
+ strikePrice: _item[1],
45
+ putCall: _item[2],
46
+ oi: _item[3],
47
+ }
48
+ item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
49
+ calls_subtotal = calls_subtotal + item[:subtotal]
50
+ item[:total] = calls_subtotal
51
+ puts! item, 'item'
52
+ @calls_items.push( item )
53
+
54
+ @all_items[item[:strikePrice]] ||= {
55
+ subtotal: 0,
56
+ strikePrice: item[:strikePrice],
57
+ }
58
+ @all_items[item[:strikePrice]][:calls_subtotal] = calls_subtotal
59
+ @all_items[item[:strikePrice]][:calls_oi] = item[:oi]
60
+ @all_items[item[:strikePrice]][:subtotal] = @all_items[item[:strikePrice]][:subtotal] + calls_subtotal
61
+ end
62
+
63
+ puts_sql = "select distinct symbol, strikePrice, putCall, openInterest
64
+ from iro_option_price_items
65
+ where expirationDate = #{@expirationDate} and putCall = 'PUT' and ticker = '#{@ticker}'
66
+ group by symbol, strikePrice, putCall
67
+ order by putCall, strikePrice, created_at desc;"
68
+ @puts_items = []
69
+ @puts_array = ActiveRecord::Base.connection.execute(puts_sql)
70
+ puts_subtotal = 0
71
+ @puts_array.each do |_item|
72
+ item = {
73
+ symbol: _item[0],
74
+ strikePrice: _item[1],
75
+ putCall: _item[2],
76
+ oi: _item[3],
77
+ }
78
+ item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
79
+ puts_subtotal = puts_subtotal + item[:subtotal]
80
+ item[:total] = puts_subtotal
81
+ puts! item, 'item'
82
+ @puts_items.push( item )
83
+
84
+ @all_items[item[:strikePrice]] ||= {
85
+ subtotal: 0,
86
+ strikePrice: item[:strikePrice],
87
+ }
88
+ @all_items[item[:strikePrice]][:puts_subtotal] = puts_subtotal
89
+ @all_items[item[:strikePrice]][:puts_oi] = item[:oi]
90
+ @all_items[item[:strikePrice]][:subtotal] = @all_items[item[:strikePrice]][:subtotal] + puts_subtotal
91
+ end
92
+
93
+
94
+ render 'ish_manager/iro_watches/max_pain'
95
+ end
96
+
97
+ # def destroy
98
+ # @w = Iro::OptionWatch.find params[:id]
99
+ # authorize! :destroy, @w
100
+ # flag = @w.destroy
101
+ # if flag
102
+ # flash[:notice] = 'Success.'
103
+ # else
104
+ # flash[:alert] = @w.errors.full_messages.join(", ")
105
+ # end
106
+ # redirect_to action: 'index'
107
+ # end
108
+
109
+ # def index
110
+ # authorize! :index, Iro::OptionWatch
111
+ # @watches = Iro::OptionWatch.order_by( ticker: :asc, direction: :asc, price: :desc)
112
+ # @option_get_chains = Iro::OptionGet.all_get_chains
113
+ # end
114
+
115
+ # def update
116
+ # @option_watch = Iro::OptionWatch.find params[:id]
117
+ # authorize! :update, @option_watch
118
+ # flag = @option_watch.update_attributes params[:iro_watch].permit!
119
+ # if flag
120
+ # flash[:notice] = 'Updated option watch.'
121
+ # else
122
+ # flash[:alert] = "Cannot update option watch: #{@option_watch.errors.full_messages.join(', ')}."
123
+ # end
124
+ # redirect_to action: 'index'
125
+ # end
126
+
127
+ end
@@ -28,15 +28,6 @@ class ::IshManager::IroPositionsController < IshManager::ApplicationController
28
28
  authorize! :new, @position
29
29
  end
30
30
 
31
- ## prepare to roll
32
- def roll
33
- @position = Iro::Position.find( params[:id] )
34
- # puts! @position, 'zze'
35
-
36
- authorize! :roll, @position
37
- @next_positions = Iro::Position.find( 13, 14, 15, 16 )
38
- end
39
-
40
31
  def update
41
32
  @position = Iro::Position.find params[:id]
42
33
  authorize! :update, @position
@@ -33,22 +33,63 @@ class ::IshManager::IroPursesController < IshManager::ApplicationController
33
33
  authorize! :new, @iro_purse
34
34
  end
35
35
 
36
+ ## show_gameui too
36
37
  def show
37
38
  @purse = Iro::Purse.find params[:id]
38
39
  authorize! :my, @purse
39
40
 
40
41
  @strategies = Iro::CoveredCallStrategy.all
41
- underlyings = Tda::Stock.get_quotes( @strategies.map(&:ticker).compact.uniq.join(",") )
42
- # json_puts! underlyings, 'out'
43
- underlyings.each do |ticker, v|
44
- # puts! v[:mark], 'ze mark'
45
- Iro::CoveredCallStrategy.where( ticker: ticker ).update( current_underlying_strike: v[:mark] )
42
+
43
+ if params[:statuses]
44
+ @positions = @purse.positions.where( :status.in => params[:statuses].split(',') )
45
+ else
46
+ @positions = @purse.positions
46
47
  end
48
+ @positions = @positions.order({ expires_on: :asc, strike: :asc })
49
+ # @positions.map do |p|
50
+ # if p[:status] == 'active'
51
+ # # p.refresh
52
+ # end
53
+ # end
54
+
55
+ render params[:kind] || @purse.parsed_config[:kind] || 'show'
56
+ end
57
+
58
+ def roll_prep
59
+ @strategies = Iro::CoveredCallStrategy.all
60
+ @position = Iro::Position.find params[:id]
61
+ # puts! @position, '@position'
62
+ @positions = [ @position ]
63
+ @purse = @position.purse
64
+ @strategy = @position.strategy
65
+ authorize! :roll_prep, @position
47
66
 
48
- @positions = @purse.positions.order({ expires_on: :asc, strike: :asc })
49
- @positions.map &:refresh
67
+ @next_positions = []
68
+ next_date = @position.expires_on + 7.days # @TODO: change, watch hout for holidays
69
+
70
+ [ -0.5, 0, 0.5, 1, 1.5 ].each do |price_step|
71
+ next_position = Iro::CoveredCall.new({
72
+ expires_on: next_date,
73
+ strike: @position.strike + price_step,
74
+ ticker: @strategy.ticker,
75
+ opened_price: @position.current_price, # gain or loss upon roll
76
+ # current_price: , # the price (size matters)
77
+ })
78
+ @next_positions.push( next_position )
79
+ end
80
+ @next_positions.map &:refresh
81
+ @next_positions.map do |p|
82
+ current_price = p.current_price
83
+ p.opened_price = p.current_price
84
+ current_price = current_price - @position.current_price # gain/loss diff
85
+ p.current_price = p.opened_price - current_price
86
+ end
87
+
88
+ @next_positions.each do |p|
89
+ puts! p, 'nexxt'
90
+ end
50
91
 
51
- render @purse.parsed_config[:kind] || params[:kind] || 'show'
92
+ render params[:kind] || @purse.parsed_config[:kind] || 'show'
52
93
  end
53
94
 
54
95
  def update
@@ -30,6 +30,7 @@ class ::IshManager::IroWatchesController < IshManager::ApplicationController
30
30
  def index
31
31
  authorize! :index, Iro::OptionWatch
32
32
  @watches = Iro::OptionWatch.order_by( ticker: :asc, direction: :asc, price: :desc)
33
+ @option_get_chains = Iro::OptionGet.all_get_chains
33
34
  end
34
35
 
35
36
  def update
@@ -0,0 +1,15 @@
1
+
2
+ class IshManager::ProductsController < IshManager::ApplicationController
3
+
4
+ before_action :set_lists
5
+
6
+ # alphabetized : )
7
+
8
+ def index
9
+ authorize! :index, Wco::Product
10
+ Stripe.api_key = ::STRIPE_SK
11
+ Stripe.api_version = '2020-08-27'
12
+ @products = Stripe::Product.list().data
13
+ end
14
+
15
+ end