ish_models 0.0.33.109 → 0.0.33.110

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: e7b4296819e6aa79c292a1ecc7d1fe4aaae221e00071404dd3df07e8e46ca4e6
4
- data.tar.gz: 89718fbbe1b9bf03e645ce2fd275f50b7908dbb3c90a021f0cd4bca29b6f4041
3
+ metadata.gz: 01a095922836ca0bbbc32da6e369557cdd07e8e88411d1f0b9bef9950e647553
4
+ data.tar.gz: d67e1dff8e0eda5b473fa0561322ff37195eb747946f1ea4b54c8c70e9c4cb9d
5
5
  SHA512:
6
- metadata.gz: 1175f0f6d0f20be7097bbe3f1e9c290c41f9af6a742ef95b4d49aab1dd61f89f70b45f5900ca6566a938fc9f4c679bee9f6b69ea0a5d9e287573044fac1ac933
7
- data.tar.gz: 84bbb47a571d8d2cfa0016b77e7cfcaa4b5d1b1686477988316e29ce8a8e04341c8dbd357bf52a6931d5b04f44eb0f6b611d7f7978e83c466da36b8da48f79f0
6
+ metadata.gz: a8a82124f8ea77344658dbeccdad2349b31608ed316766914b5d0c6cb16e6ee60fbe4d2c702aba8e8eb14bb39399909620878b21536d9d38e93e3a97725344f8
7
+ data.tar.gz: 447a2b4ce3d8f19003ecddbbe30b8b709e19c6b1f9b54d355e935e156d72d4b5d10f3ea654cbfb3646e784fa6898cc32161a2d6593221a5a01056a8aa2101bea
data/lib/city.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  class City
2
2
  include ::Mongoid::Document
3
3
  include ::Mongoid::Timestamps
4
-
4
+ include AuxModel
5
+
5
6
  field :name, :type => String
6
7
  field :description, :type => String, :default => 'The description of this city'
7
8
 
data/lib/gallery.rb CHANGED
@@ -112,5 +112,9 @@ class Gallery
112
112
 
113
113
  belongs_to :newsparent, polymorphic: true, optional: true
114
114
 
115
+ set_callback :update, :after do |doc|
116
+ Site.update_all updated_at: Time.now
117
+ end
118
+
115
119
  end
116
120
 
@@ -0,0 +1,20 @@
1
+
2
+ class Ish::CoveredCall
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ store_in collection: 'ish_covered_call'
7
+
8
+ field :expires_on, type: Date
9
+ validates :expires_on, presence: true
10
+ field :n_contracts, type: Integer
11
+ validates :n_contracts, presence: true
12
+ field :ticker
13
+ validates :ticker, uniqueness: { scope: :expires_on }
14
+ validates :ticker, presence: true
15
+
16
+ #
17
+ # Internal, below
18
+ #
19
+
20
+ end
@@ -0,0 +1,78 @@
1
+
2
+ class ::Ish::CoveredCallWatcher
3
+
4
+ def initialize
5
+ @consumer = OAuth::Consumer.new ALLY_CREDS[:consumer_key], ALLY_CREDS[:consumer_secret], { :site => 'https://api.tradeking.com' }
6
+ @access_token = OAuth::AccessToken.new(@consumer, ALLY_CREDS[:access_token], ALLY_CREDS[:access_token_secret])
7
+ end
8
+
9
+ def new_order
10
+ ccall = ::Ish::CoveredCall.all.first
11
+ xml = ccall.new_multileg_order_example
12
+ print! xml, 'xml'
13
+ path = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders.xml"
14
+ # path = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders/preview.xml"
15
+ response = @access_token.post(path, xml)
16
+ print! response.body, 'response'
17
+ end
18
+
19
+ def watch_once
20
+ ccalls = ::Ish::CoveredCall.all
21
+ ccalls.each do |ccall|
22
+ puts! ccall.ticker, 'Watching this ccall'
23
+
24
+ path = "/v1/market/ext/quotes.json?symbols=#{ccall.ticker}"
25
+ response = @access_token.get(path, {'Accept' => 'application/json'})
26
+ json = JSON.parse( response.body ).deep_symbolize_keys
27
+ bid = json[:response][:quotes][:quote][:bid].to_f
28
+ ask = json[:response][:quotes][:quote][:ask].to_f
29
+ natural = ( bid + ask ) / 2
30
+
31
+ # puts! [ bid, ask ], 'bid, ask'
32
+ # puts! [ ccall.upper_panic_threshold, ccall.lower_panic_threshold ], 'upper/lower panic'
33
+
34
+ ## upper panic
35
+ if bid > ccall.upper_panic_threshold
36
+ xml = ccall.rollup_xml access_token=@access_token, natural=natural
37
+ print! xml, 'xml'
38
+
39
+ IshManager::ApplicationMailer.ccall_followup_alert( ccall, { action: :rollup } ).deliver_later
40
+
41
+ ## place order
42
+ path_preview = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders/preview.xml"
43
+ response = @access_token.post( path_preview, xml )
44
+ print! response.body
45
+ # path_order = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders.xml"
46
+ # response = @access_token.post( path_order, xml )
47
+ # print! response.body
48
+ end
49
+
50
+ ## lower panic
51
+ if ask < ccall.lower_panic_threshold
52
+ xml = ccall.rolldown_xml access_token=@access_token, natural=natural
53
+ print! xml, 'xml'
54
+
55
+ IshManager::ApplicationMailer.ccall_followup_alert( ccall, { action: :rolldown } ).deliver_later
56
+
57
+ ## place order
58
+ path_preview = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders/preview.xml"
59
+ response = @access_token.post( path_preview, xml )
60
+ print! response.body
61
+ # path_order = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders.xml"
62
+ # response = @access_token.post( path_order, xml )
63
+ # print! response.body
64
+ end
65
+
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
@@ -147,15 +147,13 @@ class Ish::IronCondor
147
147
  json_sell = JSON.parse( response.body ).deep_symbolize_keys
148
148
  json_sell_bid = json_sell[:response][:quotes][:quote][:bid].to_f
149
149
  json_sell_ask = json_sell[:response][:quotes][:quote][:ask].to_f
150
- puts! json_sell, 'json_sell'
151
-
150
+
152
151
  price8 = (new_call_buy_strike*1000).to_s.rjust(8, '0')
153
152
  path = "/v1/market/ext/quotes.json?symbols=#{ticker}#{ymd}C#{price8}"
154
153
  response = @access_token.post(path, {'Accept' => 'application/json'})
155
154
  json_buy = JSON.parse( response.body ).deep_symbolize_keys
156
155
  json_buy_bid = json_buy[:response][:quotes][:quote][:bid].to_f
157
156
  json_buy_ask = json_buy[:response][:quotes][:quote][:ask].to_f
158
- puts! json_buy, 'json_buy'
159
157
 
160
158
  px_sell = ( json_sell_bid.to_f + json_sell_ask ) / 2
161
159
  px_sell = px_sell # .round 2
@@ -163,11 +161,16 @@ class Ish::IronCondor
163
161
  px_buy = px_buy # .round 2
164
162
  px = px_sell - px_buy
165
163
  px = ( px * 20 ).round.to_f / 20 # down to nearest 0.05
166
- puts! px, 'px'
164
+
165
+ json_puts! json_sell, 'json_sell'
166
+ json_puts! json_buy, 'json_buy'
167
+ puts! px, '^00 - px'
167
168
 
169
+ =begin
168
170
  update( status: :rolling_up,
169
171
  new_call_sell_strike: new_call_sell_strike,
170
172
  new_call_buy_strike: new_call_buy_strike )
173
+ =end
171
174
 
172
175
  rollup_tmpl =<<~AOL
173
176
  <?xml version="1.0" encoding="UTF-8"?>
@@ -239,15 +242,16 @@ class Ish::IronCondor
239
242
  json_sell = JSON.parse( response.body ).deep_symbolize_keys
240
243
  json_sell_bid = json_sell[:response][:quotes][:quote][:bid].to_f
241
244
  json_sell_ask = json_sell[:response][:quotes][:quote][:ask].to_f
242
- puts! json_sell, 'json_sell'
245
+ json_puts! json_sell, 'json_sell'
243
246
 
244
247
  price8 = (new_put_buy_strike*1000).to_s.rjust(8, '0')
245
248
  path = "/v1/market/ext/quotes.json?symbols=#{ticker}#{ymd}C#{price8}"
249
+ puts! path, 'path buy'
246
250
  response = @access_token.post(path, {'Accept' => 'application/json'})
247
251
  json_buy = JSON.parse( response.body ).deep_symbolize_keys
248
252
  json_buy_bid = json_buy[:response][:quotes][:quote][:bid].to_f
249
253
  json_buy_ask = json_buy[:response][:quotes][:quote][:ask].to_f
250
- puts! json_buy, 'json_buy'
254
+ json_puts! json_buy, 'json_buy'
251
255
 
252
256
  px_sell = ( json_sell_bid.to_f + json_sell_ask ) / 2
253
257
  px_sell = px_sell # .round 2
@@ -257,9 +261,11 @@ class Ish::IronCondor
257
261
  px = ( px * 20 ).round.to_f / 20 # down to nearest 0.05
258
262
  puts! px, 'px'
259
263
 
264
+ =begin
260
265
  update( status: :rolling_down,
261
266
  new_put_sell_strike: new_put_sell_strike,
262
267
  new_put_buy_strike: new_put_buy_strike )
268
+ =end
263
269
 
264
270
  rollup_tmpl =<<~AOL
265
271
  <?xml version="1.0" encoding="UTF-8"?>
@@ -2,7 +2,6 @@
2
2
  # result = @access_token.get('/v1/accounts.json', {'Accept' => 'application/json'})
3
3
  # json = JSON.parse result.body
4
4
 
5
-
6
5
  class ::Ish::IronCondorWatcher
7
6
 
8
7
  def initialize
@@ -10,7 +9,19 @@ class ::Ish::IronCondorWatcher
10
9
  @access_token = OAuth::AccessToken.new(@consumer, ALLY_CREDS[:access_token], ALLY_CREDS[:access_token_secret])
11
10
  end
12
11
 
12
+ def ally_status_update
13
+ path = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders.xml"
14
+ response = @access_token.get( path, {'Accept' => 'application/json'})
15
+ print! response.body, 'body'
16
+
17
+ # have model AllyOrder ?
18
+ # Then, if the order is filled, adjust the condor (suppose rolled down):
19
+ # update field :put_sell_strike
20
+ # update field :put_buy_strike
21
+ # update field :status => :filled
22
+ end
13
23
 
24
+ =begin
14
25
  def new_order
15
26
  condor = ::Ish::IronCondor.all.first
16
27
  xml = condor.new_multileg_order_example
@@ -20,6 +31,7 @@ class ::Ish::IronCondorWatcher
20
31
  response = @access_token.post(path, xml)
21
32
  print! response.body, 'response'
22
33
  end
34
+ =end
23
35
 
24
36
  def watch_once
25
37
  condors = ::Ish::IronCondor.all_filled
@@ -57,7 +69,7 @@ class ::Ish::IronCondorWatcher
57
69
  xml = condor.rolldown_xml access_token=@access_token, natural=natural
58
70
  print! xml, 'xml'
59
71
 
60
- IshManager::ApplicationMailer.condor_followup_alert( condor, { action: :rolldown } ).deliver_later
72
+ IshManager::ApplicationMailer.condor_followup_alert( { action: 'rolldown', condor_id: condor.id } ).deliver_later
61
73
 
62
74
  ## place order
63
75
  path_preview = "/v1/accounts/#{ALLY_CREDS[:account_id]}/orders/preview.xml"
data/lib/ish_models.rb CHANGED
@@ -4,6 +4,8 @@ require 'ish_models/configuration'
4
4
 
5
5
  ::S3_CREDENTIALS ||= {}
6
6
 
7
+ module Ish; end
8
+
7
9
  module IshModels
8
10
 
9
11
  class << self
@@ -31,6 +33,7 @@ require 'gameui/map.rb'
31
33
  require 'gameui/marker.rb'
32
34
  require 'gameui/premium_purchase.rb'
33
35
 
36
+ require 'ish/covered_call'
34
37
  require 'ish/crawler.rb'
35
38
  require 'ish/gallery_name.rb'
36
39
  require 'ish/iron_condor.rb'
data/lib/photo.rb CHANGED
@@ -38,9 +38,12 @@ class Photo
38
38
  :styles => {
39
39
  :mini => '20x20#',
40
40
  :thumb => "100x100#",
41
- :small => "400x400>",
42
- :w330 => "330x330>",
43
- :large => '950x650>'
41
+ :thumb2 => "200x200#",
42
+ :s169 => "640x360>",
43
+ # :s43 => "640x480>",
44
+ # :small => "400x400>",
45
+ # :w330 => "330x330>",
46
+ :large => '950x650>',
44
47
  },
45
48
  :storage => :s3,
46
49
  :s3_credentials => ::S3_CREDENTIALS,
data/lib/report.rb CHANGED
@@ -97,6 +97,10 @@ class Report
97
97
  self.name_seo ||= self.name.gsub(' ', '-').gsub('.', '')
98
98
  end
99
99
 
100
+ set_callback :update, :after do |doc|
101
+ Site.update_all updated_at: Time.now
102
+ end
103
+
100
104
  set_callback :create, :after do |doc|
101
105
  if doc.is_public
102
106
 
data/lib/video.rb CHANGED
@@ -69,4 +69,8 @@ class Video
69
69
  :validate_media_type => false
70
70
  validates_attachment_content_type :thumb, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
71
71
 
72
+ set_callback :update, :after do |doc|
73
+ Site.update_all updated_at: Time.now
74
+ end
75
+
72
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.109
4
+ version: 0.0.33.110
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -121,6 +121,8 @@ files:
121
121
  - lib/gameui/premium_purchase.rb
122
122
  - lib/ish/alphavantage_stockwatcher.rb
123
123
  - lib/ish/campaign.rb
124
+ - lib/ish/covered_call.rb
125
+ - lib/ish/covered_call_watcher.rb
124
126
  - lib/ish/crawler.rb
125
127
  - lib/ish/gallery_name.rb
126
128
  - lib/ish/invoice.rb