ish_models 0.0.33.147 → 0.0.33.151

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: 2af4a30d5895c96dfa6e0b57604155431d3bad1e63545983525a6703f8def2b5
4
- data.tar.gz: e6d1ab4d19a4eae08bb34da2855a7fe08f582af676933fb0c856ed57e77796e0
3
+ metadata.gz: 6c1a8feb3d93c76b4cc923c63ec58f7c07b6ef717b5fb1e6ab3887e0b1afa79a
4
+ data.tar.gz: a37d65e4328947be9d323288ca68d526c17099eefd22b8a9660963b153ea6f68
5
5
  SHA512:
6
- metadata.gz: 2be04cc815e921d2807dffe0ad15feadeeec327b72cacbef49b96b505d85c4870f0d45d5293749db8c05dad2163e1874fc1e2d70c2b33ba12deee38cd8c96f84
7
- data.tar.gz: c8611fdae51db950f7b218e52cbafebaeada3416d535392c91a628ce7aaa8adc6b17fb793af20f1496887dc23ca7cda83beb483665de797cbf1eaae6d14056f2
6
+ metadata.gz: ad692619a0b561c876c23c2dd541bf93f894885a8c3f3a8aee9718dfb8c6e1c5f5de68acebc61955f5e2765320fe7ca12042b80b69700fb9db3f65a4e97239ca
7
+ data.tar.gz: c5cee4bb7423bbe1dfde9faea1eb1ec48f7ab9cf570c1c5377c29237ff4667416d42db1e15f3a186cdcb12f875e6b24ea55f0d8bb3a6a9a2647c4df03b9d832a
@@ -38,6 +38,7 @@ class Ish::UserProfile
38
38
  has_many :photos
39
39
  has_many :reports, inverse_of: :user_profile
40
40
  has_many :stocks, :class_name => '::Warbler::StockWatch'
41
+ has_many :option_watches, class_name: '::Warbler::OptionWatch'
41
42
  has_many :videos, inverse_of: :user_profile
42
43
  has_many :newsitems, inverse_of: :user_profile
43
44
 
data/lib/ish_models.rb CHANGED
@@ -61,18 +61,14 @@ require 'tag'
61
61
  require 'venue'
62
62
  require 'video'
63
63
 
64
+ require 'warbler/option_watch'
64
65
  require 'warbler/stock_watch'
65
66
  require 'warbler/ameritrade'
66
67
 
67
68
  ## warbler
68
- # require 'warbler/alphavantage_stockwatcher'
69
- # require 'warbler/ameritrade'
70
69
  # require 'warbler/covered_call'
71
70
  # require 'warbler/iron_condor'
72
- # require 'warbler/iron_condor_watcher'
73
71
  # require 'warbler/stock_action'
74
- # require 'warbler/stock_option'
75
- # require 'warbler/yahoo_stockwatcher'
76
72
 
77
73
 
78
74
 
data/lib/video.rb CHANGED
@@ -2,16 +2,25 @@ class Video
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
4
  include Mongoid::Paperclip
5
+ include Mongoid::Paranoia
5
6
 
6
7
  PER_PAGE = 6
7
8
 
8
9
  field :name, :type => String
9
10
  field :descr, :type => String, :as => :description
10
11
 
11
- default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
12
+ # default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
12
13
 
13
14
  field :is_trash, :type => Boolean, :default => false
14
- field :is_public, :type => Boolean, :default => true
15
+ def is_trash
16
+ if deleted_at
17
+ true
18
+ else
19
+ self[:is_trash]
20
+ end
21
+ end
22
+
23
+ field :is_public, :type => Boolean, :default => false
15
24
  field :is_feature, :type => Boolean, :default => false
16
25
 
17
26
  field :x, :type => Float
@@ -39,6 +39,8 @@ end
39
39
  class ::Warbler::Ameritrade::Api
40
40
  include ::HTTParty
41
41
  base_uri 'https://api.tdameritrade.com'
42
+ PUT = 'PUT'
43
+ CALL = 'CALL'
42
44
 
43
45
  def self.get_quote opts
44
46
  # validate input
@@ -54,17 +56,30 @@ class ::Warbler::Ameritrade::Api
54
56
  out
55
57
  end
56
58
 
57
- def self.get_option_chain opts
59
+ def self.get_option _opts
60
+ opts = {}
61
+
58
62
  # validate input
59
- %i| apikey symbol contractType strike fromDate toDate |.each do |s|
60
- if !opts[s]
63
+ validOpts = %i| contractType strike symbol|
64
+ validOpts.each do |s|
65
+ if _opts[s]
66
+ opts[s] = _opts[s]
67
+ else
61
68
  raise Ish::InputError.new("invalid input, missing #{s}")
62
69
  end
63
70
  end
71
+ if _opts[:date]
72
+ opts[:fromDate] = opts[:toDate] = _opts[:date]
73
+ else
74
+ raise Ish::InputError.new("invalid input, missing 'date'")
75
+ end
64
76
 
65
- path = '/v1/marketdata/chains'
66
- out = self.get path, { query: opts }
67
- out
77
+ query = { apikey: ::TD_AME[:apiKey], strikeCount: 1 }.merge opts
78
+ path = "/v1/marketdata/chains"
79
+ out = self.get path, { query: query }
80
+ out = out.parsed_response.deep_symbolize_keys
81
+ tmp_sym = "#{opts[:contractType].to_s.downcase}ExpDateMap".to_sym
82
+ out[tmp_sym].first[1].first[1][0]
68
83
  end
69
84
 
70
85
  end
@@ -0,0 +1,41 @@
1
+
2
+ class Warbler::OptionWatch
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ store_in collection: 'ish_option_watches'
6
+
7
+ SLEEP_TIME_SECONDS = 60
8
+
9
+ field :ticker # like NVDA
10
+ validates :ticker, presence: true
11
+ # field :symbol # like NVDA_021822C230
12
+
13
+ ## Strike isn't the same as price!
14
+ field :strike, :type => Float
15
+ validates :strike, presence: true
16
+
17
+ ## What is the price of the option at some strike?
18
+ field :price, type: Float
19
+ validates :price, presence: true
20
+
21
+ field :contractType
22
+ validates :contractType, presence: true
23
+
24
+ field :date
25
+ validates :date, presence: true
26
+
27
+ NOTIFICATION_TYPES = [ :NONE, :EMAIL, :SMS ]
28
+ ACTIONS = NOTIFICATION_TYPES
29
+ NOTIFICATION_NONE = :NONE
30
+ NOTIFICATION_EMAIL = :EMAIL
31
+ NOTIFICATION_SMS = :SMS
32
+ field :notification_type, :type => Symbol, :as => :action
33
+
34
+ DIRECTIONS = [ :ABOVE, :BELOW ]
35
+ DIRECTION_ABOVE = :ABOVE
36
+ DIRECTION_BELOW = :BELOW
37
+ field :direction, :type => Symbol
38
+
39
+ belongs_to :profile, :class_name => 'Ish::UserProfile'
40
+
41
+ end
@@ -4,13 +4,15 @@ class Warbler::StockWatch
4
4
  include Mongoid::Timestamps
5
5
  store_in collection: 'ish_stock_watches'
6
6
 
7
+ SLEEP_TIME_SECONDS = 60
8
+
7
9
  field :ticker
8
10
 
9
11
  NOTIFICATION_TYPES = [ :NONE, :EMAIL, :SMS ]
12
+ ACTIONS = NOTIFICATION_TYPES
10
13
  NOTIFICATION_NONE = :NONE
11
14
  NOTIFICATION_EMAIL = :EMAIL
12
15
  NOTIFICATION_SMS = :SMS
13
- ACTIONS = NOTIFICATION_TYPES
14
16
  field :notification_type, :type => Symbol, :as => :action
15
17
 
16
18
  field :price, :type => Float
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.147
4
+ version: 0.0.33.151
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: mongoid_paranoia
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: mongoid-autoinc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -148,13 +162,14 @@ files:
148
162
  - lib/warbler/covered_call_watcher.rb
149
163
  - lib/warbler/iron_condor.rb
150
164
  - lib/warbler/iron_condor_watcher.rb
165
+ - lib/warbler/option_watch.rb
151
166
  - lib/warbler/stock_action.rb
152
167
  - lib/warbler/stock_option.rb
153
168
  - lib/warbler/stock_watch.rb
154
169
  - lib/warbler/yahoo_stockwatcher.rb
155
- homepage: http://wasya.co
170
+ homepage: https://wasya.co
156
171
  licenses:
157
- - MIT
172
+ - Proprietary
158
173
  metadata: {}
159
174
  post_install_message:
160
175
  rdoc_options: []