ish_manager 0.1.8.460 → 0.1.8.461

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0498ed69f95e0d6288430dd6ced049a417cd722797088e1ce0617607f499519
4
- data.tar.gz: 5872bfac3ad36bc95f39444c0e68c11ca3ad8cc1cac61d8efff39698b5d7db35
3
+ metadata.gz: a936861bb4879bb1d16f7e04dadf42d0932dd47bb73dfaa89b63c72267655dae
4
+ data.tar.gz: 5ebcfead1814dfe078ef49a41e1c0b21af6f87c952e493838e89ef4450e8fd58
5
5
  SHA512:
6
- metadata.gz: e609d728478fee75c7e3bb4f79f4be0c45164a5cde5388d6b493baeb7a491ba7af295221a40d091294e9f7463cfaf5647e83ba44323e1b8ea588571e29c70f2c
7
- data.tar.gz: effb1d3a11fdf9b3e7dd93595433e2fea6cdd0fde18f17240fdfd3bddbb8ae3e35b6b3fef368ea18bf8c164e63de972c9525f92d6ffe7f8899a489af5e10b1e6
6
+ metadata.gz: 13c83e9dd12495f4fa9d3e71464a693c9949fe4b7e5b2f34b580f4b24c55d9093741a63221b6b45af96427e7b3e1a9c755596b6b812e7244d7f4feabb1d1994d
7
+ data.tar.gz: 7d7ac4f8fbe39793720d1bed308dd138731533b23601a2745935883e22e4e63be65baa58ecbf3b4463a8cdb56a5117a44cbb51eb565d4e2c20cb53fae5164fb4
@@ -22,8 +22,7 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
22
22
  })
23
23
  end
24
24
 
25
- ## #create_stripe()
26
- def create
25
+ def create_stripe
27
26
  @invoice = Ish::Invoice.new params[:invoice].permit!
28
27
  authorize! :create, @invoice
29
28
 
@@ -35,11 +34,12 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
35
34
  pending_invoice_items_behavior: 'exclude',
36
35
  })
37
36
  params[:invoice][:items].each do |item|
38
- stripe_price = Wco::Product.find( item ).price_id
37
+ stripe_price = Wco::Product.find( item[:product_id] ).price_id
39
38
  invoice_item = Stripe::InvoiceItem.create({
40
39
  customer: @invoice.leadset.customer_id,
41
40
  price: stripe_price,
42
41
  invoice: stripe_invoice.id,
42
+ quantity: item[:quantity],
43
43
  })
44
44
  end
45
45
  Stripe::Invoice.send_invoice(stripe_invoice[:id])
@@ -71,7 +71,7 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
71
71
 
72
72
  def new_stripe
73
73
  authorize! :new, @invoice
74
- @leadset = Leadset.find params[:leadset_id]
74
+ @leadset = Leadset.find params[:leadset_id]
75
75
  @products_list = Wco::Product.list
76
76
  end
77
77
 
@@ -16,57 +16,49 @@ class ::IshManager::IroOptionGetsController < IshManager::ApplicationController
16
16
  redirect_to action: 'index', controller: 'ish_manager/iro_watches'
17
17
  end
18
18
 
19
+
20
+ =begin
21
+
22
+ select t1.putCall, t1.symbol, t1.strikePrice, t1.openInterest, t1.created_at
23
+ from iro_option_price_items t1
24
+ join (
25
+ select symbol, max(created_at) as c1
26
+ from iro_option_price_items
27
+ where expirationDate = 1694808000000 and ticker = 'GME'
28
+ group by symbol ) as t2
29
+ on t1.symbol = t2.symbol and t1.created_at = t2.c1
30
+ order by t1.strikePrice, t1.created_at desc;
31
+
32
+ =end
33
+
34
+
35
+ ##
36
+ ## Tda::Option.get_chain({ ticker: 'GME' })
37
+ ##
38
+ ## SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
39
+ ## SET sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));
40
+ ##
19
41
  def max_pain
20
42
  authorize! :max_pain, Iro::Iro
21
- @ticker = params[:ticker]
22
-
23
- @expirationDate = ( params[:date].to_date + 15.hours ).to_time.to_i * 1000 # '1689364800000'
24
- # expirationDate = '1689969600000'
25
- # expirationDate = '1690574400000'
26
- @all_items = {}
27
-
28
- calls_sql = " select distinct putCall, symbol, strikePrice, openInterest, max(created_at)
29
- from iro_option_price_items
30
- where expirationDate = #{@expirationDate} and putCall = 'CALL' and ticker = '#{@ticker}'
31
- group by putCall, symbol, strikePrice, openInterest
32
- order by strikePrice, max(created_at) desc; "
33
- @calls_items = []
34
- @calls_array = ActiveRecord::Base.connection.execute(calls_sql)
35
- calls_subtotal = 0
36
- @calls_array.each do |_item|
37
- # puts! _item, 'item'
38
- item = {
39
- putCall: _item[0],
40
- symbol: _item[1],
41
- strikePrice: _item[2],
42
- oi: _item[3],
43
- created_at: _item[4],
44
- }
45
- # puts! item, 'item'
46
- item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
47
- calls_subtotal = calls_subtotal + item[:subtotal]
48
- item[:total] = calls_subtotal
49
- puts! item, 'item'
50
- @calls_items.push( item )
43
+ @ticker = params[:ticker]
44
+ @expirationDate = ( params[:date].to_date + 15.hours ).to_time.to_i * 1000
45
+ # puts! @expirationDate, '@expirationDate'
46
+ @all_items = {}
51
47
 
52
- @all_items[item[:strikePrice]] ||= {
53
- subtotal: 0,
54
- strikePrice: item[:strikePrice],
55
- }
56
- @all_items[item[:strikePrice]][:calls_subtotal] = calls_subtotal
57
- @all_items[item[:strikePrice]][:calls_oi] = item[:oi]
58
- @all_items[item[:strikePrice]][:subtotal] = @all_items[item[:strikePrice]][:subtotal] + calls_subtotal
59
- end
48
+ sql = " select t1.putCall, t1.symbol, t1.strikePrice, t1.openInterest, t1.created_at
49
+ from iro_option_price_items t1
50
+ join (
51
+ select symbol, max(created_at) as c1
52
+ from iro_option_price_items
53
+ where expirationDate = #{@expirationDate} and ticker = '#{@ticker}'
54
+ group by symbol ) as t2
55
+ on t1.symbol = t2.symbol and t1.created_at = t2.c1
56
+ order by t1.strikePrice, t1.created_at desc;
57
+ "
60
58
 
61
- puts_sql = "select putCall, symbol, strikePrice, openInterest, created_at
62
- from iro_option_price_items
63
- where expirationDate = #{@expirationDate} and putCall = 'PUT' and ticker = '#{@ticker}'
64
- group by putCall, symbol, strikePrice, openInterest, created_at
65
- order by putCall, strikePrice, created_at desc;"
66
- @puts_items = []
67
- @puts_array = ActiveRecord::Base.connection.execute(puts_sql)
68
- puts_subtotal = 0
69
- @puts_array.each do |_item|
59
+ results_array = ActiveRecord::Base.connection.execute(sql)
60
+ results_array.each do |_item|
61
+ # puts! _item, '_item'
70
62
  item = {
71
63
  putCall: _item[0],
72
64
  symbol: _item[1],
@@ -74,20 +66,71 @@ class ::IshManager::IroOptionGetsController < IshManager::ApplicationController
74
66
  oi: _item[3],
75
67
  created_at: _item[4],
76
68
  }
77
- item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
78
- puts_subtotal = puts_subtotal + item[:subtotal]
79
- item[:total] = puts_subtotal
80
- puts! item, 'item'
81
- @puts_items.push( item )
82
69
  @all_items[item[:strikePrice]] ||= {
83
- subtotal: 0,
84
- strikePrice: item[:strikePrice],
70
+ strike_price: item[:strikePrice],
71
+ call_max_pain: 0,
72
+ put_max_pain: 0,
85
73
  }
86
- @all_items[item[:strikePrice]][:puts_subtotal] = puts_subtotal
87
- @all_items[item[:strikePrice]][:puts_oi] = item[:oi]
88
- @all_items[item[:strikePrice]][:subtotal] = @all_items[item[:strikePrice]][:subtotal] + puts_subtotal
74
+ if 'CALL' == item[:putCall]
75
+ @all_items[item[:strikePrice]][:call_oi] = item[:oi]
76
+ else
77
+ @all_items[item[:strikePrice]][:put_oi] = item[:oi]
78
+ end
79
+ end
80
+
81
+ @all_items.each_with_index do |_item, idx|
82
+ strike_price = _item[0]
83
+ item = _item[1]
84
+ # break if idx > 3
85
+ # puts! item, 'item'
86
+
87
+ @all_items.each do |next_strike_price, next_item|
88
+ if next_strike_price < strike_price
89
+ if next_item[:call_oi] > 0
90
+ @all_items[strike_price][:call_max_pain] += 100 * next_item[:call_oi] * (strike_price - next_strike_price)
91
+ end
92
+ end
93
+
94
+ if next_strike_price > strike_price
95
+ if next_item[:put_oi] > 0
96
+ @all_items[strike_price][:put_max_pain] += 100 * next_item[:put_oi] * (next_strike_price - strike_price)
97
+ end
98
+ end
99
+ end
100
+
101
+
89
102
  end
90
103
 
104
+ # puts_sql = "select putCall, symbol, strikePrice, openInterest, created_at
105
+ # from iro_option_price_items
106
+ # where expirationDate = #{@expirationDate} and putCall = 'PUT' and ticker = '#{@ticker}'
107
+ # group by putCall, symbol, strikePrice, openInterest, created_at
108
+ # order by putCall, strikePrice, created_at desc;"
109
+ # @puts_items = []
110
+ # @puts_array = ActiveRecord::Base.connection.execute(puts_sql)
111
+ # puts_subtotal = 0
112
+ # @puts_array.each do |_item|
113
+ # item = {
114
+ # putCall: _item[0],
115
+ # symbol: _item[1],
116
+ # strikePrice: _item[2],
117
+ # oi: _item[3],
118
+ # created_at: _item[4],
119
+ # }
120
+ # item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
121
+ # puts_subtotal = puts_subtotal + item[:subtotal]
122
+ # item[:total] = puts_subtotal
123
+ # puts! item, 'item'
124
+ # @puts_items.push( item )
125
+ # @all_items[item[:strikePrice]] ||= {
126
+ # subtotal: 0,
127
+ # strikePrice: item[:strikePrice],
128
+ # }
129
+ # @all_items[item[:strikePrice]][:puts_subtotal] = puts_subtotal
130
+ # @all_items[item[:strikePrice]][:puts_oi] = item[:oi]
131
+ # @all_items[item[:strikePrice]][:subtotal] = @all_items[item[:strikePrice]][:subtotal] + puts_subtotal
132
+ # end
133
+
91
134
 
92
135
  render 'ish_manager/iro_watches/max_pain'
93
136
  end
@@ -15,6 +15,14 @@
15
15
  = text_field_tag "search_query"
16
16
  = submit_tag 'search'
17
17
 
18
+ .bordered-card
19
+ = form_tag "https://wiki.wasya.co/index.php", method: :get, target: :_blank do
20
+ %p Search wiki.wasya.co:
21
+ = text_field_tag "search"
22
+ = submit_tag 'search'
23
+
24
+
25
+
18
26
  .bordered-card
19
27
  %h5.center.text-center USD to COP
20
28
  #root{ width: 500, height: 300 }
@@ -1,7 +1,7 @@
1
1
 
2
-
3
- - url = invoice.persisted? ? invoice_path( invoice.id ) : invoices_path
4
2
  - invoice = @new_invoice
3
+ - url = invoice.persisted? ? invoice_path( invoice.id ) : create_invoice_stripe_path
4
+
5
5
 
6
6
  .invoices-new.max-width
7
7
 
@@ -9,30 +9,33 @@
9
9
  .col.s12.col.m6.col-md-offset-3
10
10
  %h5 New Stripe Invoice for `#{link_to @leadset&.name, leadset_path(@leadset)}`:
11
11
 
12
- = form_for invoice, :as => :invoice, :url => url do |f|
13
- = hidden_field_tag 'invoice[leadset_id]', @leadset.id
14
-
15
- .input-field
16
- %label Email
17
- = @leadset.email
18
- -# - if @leadset.email
19
- -# = f.text_field :email, value: @leadset.email
20
- -# - elsif @leadset.employees.length == 1
21
- -# = f.text_field :email, value: @leadset.employees[0].email
22
- -# - else
23
- -# = f.select :email, options_for_select([[nil,nil]] + @leadset.employees.map { |i| [ i.email, i.email ] } )
24
-
25
- .input-field
26
- %label item
27
- = select_tag 'invoice[items][]', options_for_select( @products_list )
28
-
29
- -# .input-field
30
- -# %label number
31
- -# = f.number_field :number
32
-
33
- -# .input-field
34
- -# %label Description
35
- -# = f.text_area :description
36
-
37
- = f.submit 'Save'
12
+ = form_for invoice, :as => :invoice, :url => url do |f|
13
+ = hidden_field_tag 'invoice[leadset_id]', @leadset.id
14
+
15
+ .input-field
16
+ %label Email
17
+ = @leadset.email
18
+ -# - if @leadset.email
19
+ -# = f.text_field :email, value: @leadset.email
20
+ -# - elsif @leadset.employees.length == 1
21
+ -# = f.text_field :email, value: @leadset.employees[0].email
22
+ -# - else
23
+ -# = f.select :email, options_for_select([[nil,nil]] + @leadset.employees.map { |i| [ i.email, i.email ] } )
24
+
25
+ .input-field
26
+ %label item
27
+ = select_tag 'invoice[items][][product_id]', options_for_select( @products_list )
28
+ .input-field
29
+ %label quantity
30
+ = number_field_tag 'invoice[items][][quantity]'
31
+
32
+ -# .input-field
33
+ -# %label number
34
+ -# = f.number_field :number
35
+
36
+ -# .input-field
37
+ -# %label Description
38
+ -# = f.text_area :description
39
+
40
+ = f.submit 'Save'
38
41
 
@@ -3,21 +3,17 @@
3
3
  .header
4
4
  %h2.title max pain for #{@ticker} on #{params[:date]}
5
5
 
6
- -# = @all_items.inspect
7
-
6
+ - flag = false
8
7
  %ul
9
- - flag = false
10
- - @calls_items.each do |_t|
11
- - item = @all_items[_t[:strikePrice]]
12
- - if !flag && item[:puts_subtotal] < item[:calls_subtotal]
13
- %hr
14
- - flag = true
8
+ - @all_items.each do |strike_price, item|
9
+ - item.delete( :strike_price )
15
10
  %li
16
- -# = item.inspect
17
- = item[:strikePrice]
18
- %ul
19
- %li calls oi: #{item[:calls_oi]}
20
- %li Call pain: #{number_to_currency item[:calls_subtotal], precision: 0}
21
- %li puts oi: #{item[:puts_oi]}
22
- %li Put pain: #{number_to_currency item[:puts_subtotal], precision: 0}
11
+ - if item[:call_max_pain] > item[:put_max_pain] && !flag
12
+ - flag = true
13
+ %hr
14
+
15
+ <b>#{strike_price}</b>
16
+ = item.inspect
17
+
18
+ -# %li Call pain: #{number_to_currency item[:calls_subtotal], precision: 0}
23
19
 
@@ -62,7 +62,8 @@
62
62
  %hr
63
63
  %h5
64
64
  Invoices (?)
65
- = link_to '[+]', new_invoice_path({ leadset_id: @lead.m3_leadset_id })
65
+ = link_to '[+stripe]', new_invoice_stripe_path({ leadset_id: @lead.m3_leadset_id })
66
+ = link_to '[+pdf]', new_invoice_pdf_path({ leadset_id: @lead.m3_leadset_id })
66
67
  %ul
67
68
  %li None?
68
69
 
data/config/routes.rb CHANGED
@@ -25,9 +25,10 @@ IshManager::Engine.routes.draw do
25
25
 
26
26
  get 'image_assets', to: 'image_assets#index', as: :image_assets
27
27
 
28
- post 'invoices/create-pdf', to: 'invoices#create_pdf', as: :create_invoice_pdf
29
- get 'invoices/new_pdf', to: 'invoices#new_pdf', as: :new_invoice_pdf
30
- get 'invoices/new_stripe', to: 'invoices#new_stripe', as: :new_invoice_stripe
28
+ post 'invoices/create-pdf', to: 'invoices#create_pdf', as: :create_invoice_pdf
29
+ post 'invoices/create-stripe', to: 'invoices#create_stripe', as: :create_invoice_stripe
30
+ get 'invoices/new_pdf', to: 'invoices#new_pdf', as: :new_invoice_pdf
31
+ get 'invoices/new_stripe', to: 'invoices#new_stripe', as: :new_invoice_stripe
31
32
  resources :invoices
32
33
 
33
34
  get 'iro_positins/roll_prep/:id', to: 'iro_purses#roll_prep', as: :iro_roll_prep
@@ -37,8 +38,8 @@ IshManager::Engine.routes.draw do
37
38
  resources :iro_option_gets
38
39
 
39
40
  patch 'iro_purses/:id/show', to: 'iro_purses#update'
40
- get 'iro_purses/:id/edit', to: 'iro_purses#edit', as: :edit_iro_purse
41
- get 'iro_purses/:id/:kind', to: 'iro_purses#show', as: :iro_purse, defaults: { kind: 'show' } # kind: show_gameui
41
+ get 'iro_purses/:id/edit', to: 'iro_purses#edit', as: :edit_iro_purse
42
+ get 'iro_purses/:id/:kind', to: 'iro_purses#show', as: :iro_purse, defaults: { kind: 'show' } # kind: show_gameui
42
43
  resources :iro_purses
43
44
 
44
45
  resources :iro_strategies
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.460
4
+ version: 0.1.8.461
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails