ish_manager 0.1.8.404 → 0.1.8.405

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: 7b0e695973583101608da564e5460f74838147a078b52a29cab8c1aab34e9534
4
- data.tar.gz: 16a23aa8e36df3e4ecee24a754516026017e40b9cc3f45e7a6b5cc81862d02e4
3
+ metadata.gz: 70242298b4fbef9e7055284f6e8a603aa20e5ce5782c82cd2461bd69717e7a4f
4
+ data.tar.gz: 8f9d6291f35c98cafc912b3f331421d74ab8048f699ddc52b198b2f2fffc00d0
5
5
  SHA512:
6
- metadata.gz: 1cca17f65defbd1073a29f7fc5a6269864651083aaf6fdf1b5b2aeb63b432cb08e347d4e60c6b374405d25a4fae98414434fafc3490ca242e18e1b22740dd4e5
7
- data.tar.gz: 2ca8c6173c2317cd453fef7b4c6057db8f0858d1b2b9ffa315e3aa5b86a00eea6c5ce5f0714ca05bc414b618a5483874e95386aaadfb7b5e19c528b4424edaff
6
+ metadata.gz: 66421a7174df41ff783faafc109ef30f61ccbe0035cfdb91ad9ac8c16f0f3c7dfaf59af82b74854cf849b881762a88cb2a93e5a4df4d56299f180476127778cd
7
+ data.tar.gz: 488f4c3488c0e389c070a12979083e39c026579773c164dc6134fa3f0a48b472a1ec1f14dc8c906ec95a8127694cbec58cb90db999fc82f75c8641711e6d0638
@@ -1,19 +1,59 @@
1
1
 
2
- .iro-purses-my {
3
- font-size: 16px; // @TODO: make uniform _vp_ 2023-03-19
2
+ .iro-purses-show {
3
+ font-size: 14px;
4
4
 
5
5
  table {
6
+ .id {
7
+ width: 20px;
8
+ }
9
+ .strategy {
10
+ width: 30px;
11
+ }
12
+
13
+ thead {
14
+ position: relative;
15
+ height: 50px;
16
+
17
+
18
+ .id,
19
+ .ticker,
20
+ .days-left,
21
+ .to-close,
22
+ .must-roll {
23
+ top: 0;
24
+ }
25
+
26
+ .price {
27
+ background: cyan;
28
+ }
29
+
30
+ td > div {
31
+ // border: 1px solid green;
32
+
33
+ position: absolute;
34
+ }
35
+ }
36
+
6
37
 
7
38
  td {
8
39
  padding: 0 .5em;
9
40
  }
10
41
 
11
42
  tbody {
43
+ .begin-delta {
44
+ min-width: 20px;
45
+ }
12
46
  .must-roll,
13
47
  .next-symbol {
14
48
  text-align: center;
15
49
  }
16
50
 
51
+ .must-roll,
52
+ .should-roll,
53
+ .next-symbol {
54
+ background: #eee;
55
+ }
56
+
17
57
  .net,
18
58
  .netp {
19
59
  font-weight: bold;
@@ -28,22 +68,31 @@
28
68
  }
29
69
 
30
70
 
31
-
32
- .must-roll,
33
- .should-roll,
34
- .next-symbol {
35
- background: #eee;
36
- }
37
-
38
71
  .q {
39
72
  font-weight: bold;
40
73
  }
41
74
 
42
- .strategy {
43
- pre {
44
- font-size: 12px;
45
- background: #eee;
46
- }
75
+ .strategies {
76
+
77
+ display: flex;
78
+ flex-wrap: wrap;
47
79
  }
48
80
 
49
81
  }
82
+ .iro-strategies-edit,
83
+ .iro-strategies-new {
84
+ display: flex;
85
+ flex-direction: column;
86
+ align-items: flex-start;
87
+ }
88
+ .iro-strategies--form {
89
+ border: 1px solid blue;
90
+ border-radius: 0.5em;
91
+ padding: 0.5em;
92
+ margin-right: .5em;
93
+
94
+ .field {
95
+ display: flex;
96
+ justify-content: space-between;
97
+ }
98
+ }
@@ -6,23 +6,20 @@ class ::IshManager::IroPursesController < IshManager::ApplicationController
6
6
  def show
7
7
  @purse = Iro::Purse.find_or_create_by({ user_id: current_user.id })
8
8
  authorize! :my, @purse
9
- @positions = @purse.positions.order({ expires_on: :asc, strike: :asc })
10
- @positions.map &:refresh
9
+
11
10
  @strategies = Iro::CoveredCallStrategy.where({
12
11
  iro_purse_id: Iro::Purse.find_by( user_id: current_user.id ).id,
13
12
  })
13
+
14
+ underlyings = Tda::Stock.get_quotes( @strategies.map(&:ticker).compact.uniq.join(",") )
15
+ # json_puts! underlyings, 'out'
16
+ underlyings.each do |ticker, v|
17
+ Iro::CoveredCallStrategy.where( ticker: ticker ).update( current_underlying_strike: v[:mark] )
18
+ end
19
+
20
+ @positions = @purse.positions.order({ expires_on: :asc, strike: :asc })
21
+ @positions.active.map &:refresh
14
22
  end
15
23
 
16
24
  end
17
25
 
18
- =begin
19
- @strategy = {
20
- buffer_above_water: 0.49, # be this much $ above current price, in next position
21
- next_max_delta: 0.25, # of next position
22
- next_min_price: 16,
23
- threshold_delta: 0.14, # should roll at this delta
24
- threshold_netp: 0.69, # should roll at the net %
25
- target_profilt: 0.19, # unused
26
- current_underlying_strike: 16.6,
27
- }
28
- =end
@@ -3,7 +3,7 @@
3
3
 
4
4
  .iro-positions--form
5
5
  = form_for position, as: :position, url: url do |f|
6
- .flex-row
6
+ .a
7
7
  .field Position ##{position.id}
8
8
  .field
9
9
  = f.label :strategy
@@ -19,9 +19,14 @@
19
19
  .field
20
20
  = f.label :expires_on
21
21
  = f.text_field :expires_on
22
+
23
+ .field
24
+ = f.label :quantity
25
+ = f.number_field :quantity
26
+
22
27
  .field
23
28
  = f.label :status
24
- = f.select :status, options_for_select( Iro::Position.statuses_list, selected: position.status ), {}, class: 'select2'
29
+ = f.select :status, options_for_select( Iro::Position.states_list, selected: position.status ), {}, class: 'select2'
25
30
 
26
31
  .field
27
32
  = f.label :opened_price
@@ -1,3 +1,3 @@
1
1
 
2
- .iro-positions-edit.padded
2
+ .iro-positions-edit.max-width
3
3
  = render 'form', position: @position
@@ -1,41 +1,58 @@
1
1
 
2
- .iro-purses-my.padded
3
- .header
4
- %h2.title Purse value: $#{@purse.current_value}
2
+ .iro-purses-show.padded
3
+ .max-width
4
+ .header
5
+ %h4.title Purse value: $#{@purse.current_value}
5
6
 
6
- .strategies
7
- .title Strategies
7
+
8
+ %h5.collapse-expand#strategies Strategies #{link_to '[+]', new_iro_strategy_path}
9
+ .strategies.items
8
10
  - @strategies.each do |strat|
9
- .strategy
10
- = link_to '[~]', edit_iro_strategy_path( strat )
11
- <pre>#{JSON.pretty_generate( strat.display_attrs )}</pre>
11
+ -# .strategy.item
12
+ -# = link_to '[~]', edit_iro_strategy_path( strat )
13
+ -# <pre>#{JSON.pretty_generate( strat.display_attrs )}</pre>
14
+ .strategy.item= render 'ish_manager/iro_strategies/form', strategy: strat
12
15
 
13
16
 
17
+ %h5.collapse-expand#positions
18
+ Positions (#{@positions.length})
19
+ = link_to '[+]', new_iro_position_path
14
20
  .positions
15
- %h3
16
- Positions (#{@positions.length})
17
- = link_to '[+]', new_iro_position_path
21
+
18
22
 
19
23
  %table.bordered
20
24
  %thead
21
25
  %tr
22
- %td id
23
- %td Strategy
24
- %td Ticker
26
+ %td
27
+ .id id
28
+ %td
29
+ .strategy Strategy
30
+ %td
31
+ .ticker Ticker
25
32
  %td Kind/Type
26
33
  %td Strike
27
34
  %td ExpiresOn
28
- %td Days Left
29
- %td.q Q
30
- %td Begin On
31
- %td Begin $
32
- %td Begin #{"\u0394"}
33
- %td Current $
35
+ %td
36
+ .days-left Days Left
37
+ %td
38
+ .q Q
39
+ %td
40
+ .begin-on Begin On
41
+ %td
42
+ .price Price
43
+ %td
44
+ .to-open To Open
45
+ %td
46
+ .begin-delta #{"\u0394"}
47
+ %td
48
+ .to-close Current $ <br />(To Close)
34
49
  %td.net Net
35
50
  %td.netp % Net
36
- %td Curr #{"\u0394"}
37
- %td Days at Open
38
- %td.must-roll Must roll?
51
+ %td #{"\u0394"}
52
+ %td
53
+ .days-at-open Days@Open
54
+ %td
55
+ .must-roll Must roll?
39
56
  %td.should-roll Should roll?
40
57
  %td.next-symbol Next Symbol
41
58
  %td.next-outcome Next Outcome
@@ -43,19 +60,20 @@
43
60
  %tbody
44
61
  - @positions.each do |p|
45
62
  %tr
46
- %td
63
+ %td.id
47
64
  = p.id
48
65
  = link_to '[~]', edit_iro_position_path(p)
49
- %td= p.strategy
66
+ %td.strategy= link_to p.strategy, edit_iro_strategy_path(p.strategy)
50
67
  %td= p.ticker
51
68
  %td= p.type == "Iro::CoveredCall" ? "CALL" : "other"
52
69
  %td= p.strike
53
70
  %td= p.expires_on.strftime('%b %d')
54
- %td= (p.expires_on.to_date - Time.now.to_date).to_i
71
+ %td.days-left= (p.expires_on.to_date - Time.now.to_date).to_i
55
72
  %td.q= p.quantity
56
- %td= pp_date p.opened_on
57
- %td= p.opened_price
58
- %td= sprintf('%.2f', p.opened_delta ) rescue nil
73
+ %td.begin-on= pp_date p.opened_on
74
+ %td.price= p.opened_price
75
+ %td.to-open= pp_amount( p.opened_price * 100 * p.quantity )
76
+ %td.begin-delta= sprintf('%.2f', p.opened_delta ) rescue nil
59
77
  %td= pp_money p.current_price
60
78
  %td.net= pp_money ( p.opened_price - p.current_price ) * 100 - 1.3
61
79
  %td.netp= pp_percent ( p.opened_price - p.current_price ) / p.opened_price
@@ -2,6 +2,15 @@
2
2
  - url = strategy.new_record? ? iro_strategies_path : iro_strategy_path(strategy)
3
3
  .iro-strategies--form
4
4
  = form_for strategy, url: url, as: :iro_strategy do |f|
5
+ .field
6
+ = "#{strategy.id}." if strategy.id
7
+ = f.label :slug
8
+ = f.text_field :slug
9
+ .actions
10
+ = f.submit 'Submit', :data => { :confirm => 'Are you sure?' }
11
+ .field
12
+ = f.label :ticker
13
+ = f.text_field :ticker
5
14
  .field
6
15
  = f.label :buffer_above_water
7
16
  = f.number_field :buffer_above_water, placeholder: "0.49", step: 0.01
@@ -17,12 +26,7 @@
17
26
  .field
18
27
  = f.label :threshold_netp
19
28
  = f.number_field :threshold_netp, placeholder: "0.69", step: 0.01
20
- .field
21
- = f.label :target_profit
22
- = f.number_field :target_profit, placeholder: "0.19", step: 0.01
23
29
  .field
24
30
  = f.label :current_underlying_strike
25
31
  = f.number_field :current_underlying_strike, placeholder: "16.66", step: 0.01
26
32
 
27
- .actions
28
- = f.submit 'Submit'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.404
4
+ version: 0.1.8.405
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox