ish_models 0.0.33.127 → 0.0.33.131

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: d025168334524e77a95ebd65c77aca9f238357650a60e1ac34d96a98fab70393
4
- data.tar.gz: 880e8151b3f6c11dc6dd43e1b39a1b856ddf18a0f69b8029830a6b224007dd5f
3
+ metadata.gz: 6af77beacdc645fcf83ca862c625d2f689279acfe94cc40cc83527f4836578ed
4
+ data.tar.gz: 5860e90c3029f55d92ab8ff703e21fb5fe2d9bc1d355c68fe1e06be3cc8788c3
5
5
  SHA512:
6
- metadata.gz: 9b5c590ad879d8841b94f9f6c293a24b6ded2a00f085b10704bc55c855954ef89ef324c010e117feaefcfa9da8d9691b0ecafe1220d665406bb748c82cda4ccc
7
- data.tar.gz: fe93fcd905f544f3d584055b6e07ea826e42d451be19e446433ff8db05ff504340a3348087c72a0a2412f60f80c2da662f3efd0a771ad97bcc9f06689bc09142
6
+ metadata.gz: e88f2506f075b91fd496ce353358123486f9c968abb9e8837e89ef864846b2f054615732222ed4156578c012ab612df31b42d80219c14957f8167c48ad40d386
7
+ data.tar.gz: f0482b89daa1a5c15569a780ab80f74f07a7504b08cdd13b8844ef4a9a03b0a3927b7e4b5c300e6f19468b6c2f1006e961f041b8eb174a798850faf59593eedf
data/lib/gameui/map.rb CHANGED
@@ -4,10 +4,16 @@ class ::Gameui::Map
4
4
  include Mongoid::Timestamps
5
5
 
6
6
  has_many :markers, :class_name => '::Gameui::Marker', inverse_of: :map
7
+ has_many :newsitems, inverse_of: :map
7
8
 
8
9
  field :slug
9
10
  validates :slug, uniqueness: true, presence: true
11
+
10
12
  field :parent_slug
13
+ belongs_to :parent, class_name: '::Gameui::Map', inverse_of: :childs, optional: true
14
+ has_many :childs, class_name: '::Gameui::Map', inverse_of: :parent
15
+
16
+ field :name
11
17
 
12
18
  field :w, type: Integer
13
19
  validates :w, presence: true
@@ -26,5 +32,19 @@ class ::Gameui::Map
26
32
  field :ordering_type, type: String, default: 'custom' # timestamp, alphabetic, custom
27
33
  validates :ordering_type, presence: true
28
34
 
29
-
35
+ def self.list conditions = { is_trash: false }
36
+ out = self.order_by( created_at: :desc )
37
+ [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
38
+ end
39
+
40
+ def breadcrumbs
41
+ out = [{ name: self.name, slug: self.slug, link: false }]
42
+ p = self.parent
43
+ while p
44
+ out.push({ name: p.name, slug: p.slug })
45
+ p = p.parent
46
+ end
47
+ out.reverse
48
+ end
49
+
30
50
  end
@@ -6,38 +6,78 @@
6
6
 
7
7
  # cron job or service? Well, I've historically done service. Cron is easier tho. The wiring should be for both.
8
8
 
9
- module Ish::Ameritrade; end
9
+ # https://developer.tdameritrade.com/option-chains/apis/get/marketdata/chains
10
+ # FVRR_082021P200
10
11
 
11
- class Ish::Ameritrade::Api
12
- include HTTParty
13
- base_uri 'api.tdameritrade.com'
12
+ require 'httparty'
14
13
 
15
- def self.get_option_chain opts
14
+ module Ish::Ameritrade
15
+
16
+ CONFIG = {
17
+ underlying_downprice_tolerance: 0.14,
18
+ }
19
+
20
+ # def self.main_fvrr_1
21
+ # query_hash = {
22
+ # apikey: ::TD_AME[:apiKey],
23
+ # symbol: 'FVRR',
24
+ # contractType: 'PUT',
25
+ # strike: 200,
26
+ # fromDate: '2021-08-20',
27
+ # toDate: '2021-08-20',
28
+ # }
29
+ # response = ::Ish::Ameritrade::Api.get_option_chain(query_hash)
30
+ # puts! response, 'ze repsonse'
31
+ # end
32
+
33
+ ## AKA stop loss
34
+ def self.main_fvrr_2
35
+ # response = ::Ish::Ameritrade::Api.get_quote({ symbol: 'FVRR_082021P200' })
36
+
37
+ # @TODO: pass the info on the position in here.
38
+ strike_price = 200
39
+
40
+ # What is my risk tolerance here? 14% down movement of the underlying
41
+ response = ::Ish::Ameritrade::Api.get_quote({ symbol: 'FVRR' })
42
+ last_price = response[:lastPrice]
43
+ tolerable_price = ( strike_price * (1-CONFIG[:underlying_downprice_tolerance]) )
44
+
45
+ if last_price < tolerable_price
46
+ puts! 'LIMIT TRIGGERED, LETS EXIT' # @TODO: send an email
47
+ end
48
+ end
49
+
50
+ end
16
51
 
52
+ class Ish::Ameritrade::Api
53
+ include ::HTTParty
54
+ base_uri 'https://api.tdameritrade.com'
55
+
56
+ def self.get_quote opts
17
57
  # validate input
18
- %i| apiKey symbol contrtactType strike fromDate toDate |.each do |s|
58
+ %i| symbol |.each do |s|
19
59
  if !opts[s]
20
- raise "invalid input, missing #{s}"
60
+ raise Ish::InputError.new("invalid input, missing #{s}")
21
61
  end
22
62
  end
23
63
 
24
- path = '/v1/marketdata/chains'
25
- out = self.class.get path, opts
64
+ path = "/v1/marketdata/#{opts[:symbol]}/quotes"
65
+ out = self.get path, { query: { apikey: ::TD_AME[:apiKey] } }
66
+ out = out.parsed_response[out.parsed_response.keys[0]].symbolize_keys
26
67
  out
27
68
  end
28
69
 
29
- def self.main_fvrr_1
30
- query_hash = {
31
- apiKey: '',
32
- symbol: 'FVRR',
33
- contractType: 'PUT',
34
- stike: 200,
35
- fromDate: '2021-08-20',
36
- toDate: '2021-08-20',
37
- }
38
- response = Ameritrade::Api.get_option_chain(query_hash)
39
-
40
- puts! response, 'ze repsonse'
70
+ def self.get_option_chain opts
71
+ # validate input
72
+ %i| apikey symbol contractType strike fromDate toDate |.each do |s|
73
+ if !opts[s]
74
+ raise Ish::InputError.new("invalid input, missing #{s}")
75
+ end
76
+ end
77
+
78
+ path = '/v1/marketdata/chains'
79
+ out = self.get path, { query: opts }
80
+ out
41
81
  end
42
82
 
43
83
  end
@@ -0,0 +1,3 @@
1
+
2
+ class Ish::InputError < RuntimeError
3
+ end
@@ -39,6 +39,9 @@ class IshModels::UserProfile
39
39
  has_and_belongs_to_many :friendeds, :class_name => 'IshModels::UserProfile', :inverse_of => :friends
40
40
 
41
41
  field :n_unlocks, type: Integer, default: 0
42
+ def n_coins
43
+ n_unlocks
44
+ end
42
45
 
43
46
  #
44
47
  # preferences
@@ -72,7 +75,10 @@ class IshModels::UserProfile
72
75
  field :n_stars, type: Integer, default: 0
73
76
  has_many :premium_purchases, :class_name => '::Gameui::PremiumPurchase'
74
77
  def has_premium_purchase item
75
- item.premium_purchases.where( user_profile: self ).exists?
78
+ item.premium_purchases.where( user_profile_id: self.id ).exists?
79
+ end
80
+ def premium_purchases
81
+ ::Gameui::PremiumPurchase.where( user_profile_id: self.id )
76
82
  end
77
83
 
78
84
  end
data/lib/ish_models.rb CHANGED
@@ -37,6 +37,7 @@ require 'ish/ameritrade'
37
37
  require 'ish/covered_call'
38
38
  require 'ish/crawler.rb'
39
39
  require 'ish/gallery_name.rb'
40
+ require 'ish/input_error.rb'
40
41
  require 'ish/iron_condor.rb'
41
42
  require 'ish/iron_condor_watcher.rb'
42
43
  require 'ish/payment.rb'
data/lib/newsitem.rb CHANGED
@@ -7,7 +7,8 @@ class Newsitem
7
7
  belongs_to :city, :optional => true
8
8
  belongs_to :report, :optional => true
9
9
  belongs_to :user_profile, class_name: 'IshModels::UserProfile', optional: true
10
-
10
+ belongs_to :map, class_name: '::Gameui::Map', optional: true
11
+
11
12
  belongs_to :gallery, :optional => true
12
13
  def gallery
13
14
  self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
@@ -43,7 +44,7 @@ class Newsitem
43
44
  unless item[:report_id].blank?
44
45
  n.report = Report.find item[:report_id]
45
46
  end
46
-
47
+
47
48
  unless item[:gallery_id].blank?
48
49
  n.gallery = Gallery.find item[:gallery_id]
49
50
  end
@@ -52,5 +53,5 @@ class Newsitem
52
53
 
53
54
  return n
54
55
  end
55
-
56
+
56
57
  end
data/lib/photo.rb CHANGED
@@ -10,37 +10,36 @@ class Photo
10
10
  # field :username, :type => String
11
11
 
12
12
  has_and_belongs_to_many :viewers, :class_name => 'User', :inverse_of => :viewable_photos
13
-
13
+
14
14
  belongs_to :user_profile, :class_name => 'IshModels::UserProfile', :optional => true
15
15
  def user; user_profile; end
16
16
  belongs_to :profile_city, :class_name => 'City', :inverse_of => :profile_photo, :optional => true
17
17
  belongs_to :profile_venue, :class_name => 'Venue', :inverse_of => :profile_photo, :optional => true
18
18
  belongs_to :profile_event, :class_name => 'Event', :inverse_of => :profile_photo, :optional => true
19
-
19
+
20
20
  belongs_to :report, :optional => true
21
21
  belongs_to :venue, :optional => true
22
22
  belongs_to :event, :optional => true
23
23
  belongs_to :feature, :optional => true
24
24
  belongs_to :gallery, :optional => true
25
25
  belongs_to :newsitem, :optional => true
26
-
26
+
27
27
  field :name, :type => String
28
28
  field :descr, :type => String
29
29
  field :weight, :type => Integer, :default => 10
30
-
30
+
31
31
  field :is_public, :type => Boolean, :default => true
32
32
 
33
33
  # @TODO: nuke this boolean _vp_ 20170515
34
34
  field :is_trash, :type => Boolean, :default => false
35
35
  default_scope ->{ where({ :is_trash => false }) }
36
36
 
37
- has_mongoid_attached_file :photo,
37
+ has_mongoid_attached_file :photo,
38
38
  :styles => {
39
39
  :mini => '20x20#',
40
40
  :thumb => "100x100#",
41
41
  :thumb2 => "200x200#",
42
42
  :s169 => "640x360#",
43
- # :s43 => "640x480#",
44
43
  :small => "400x400>",
45
44
  :large => '950x650>',
46
45
  },
@@ -48,14 +47,15 @@ class Photo
48
47
  :s3_credentials => ::S3_CREDENTIALS,
49
48
  :path => "photos/:style/:id/:filename",
50
49
  :s3_protocol => 'https',
51
- :validate_media_type => false
52
-
50
+ :validate_media_type => false,
51
+ s3_region: ::S3_CREDENTIALS[:region]
52
+
53
53
  def self.n_per_manager_gallery
54
54
  25
55
55
  end
56
56
 
57
57
  validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
58
-
58
+
59
59
  end
60
60
 
61
61
 
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.127
4
+ version: 0.0.33.131
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -125,6 +125,7 @@ files:
125
125
  - lib/ish/covered_call_watcher.rb
126
126
  - lib/ish/crawler.rb
127
127
  - lib/ish/gallery_name.rb
128
+ - lib/ish/input_error.rb
128
129
  - lib/ish/invoice.rb
129
130
  - lib/ish/iron_condor.rb
130
131
  - lib/ish/iron_condor_watcher.rb