ish_models 0.0.33.149 → 0.0.33.150

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: af77cb84fd5fe123e232d66b36e090ed15f5a98c4ce97cfa49d8d1a0717f83d9
4
- data.tar.gz: fd202da5dfb24c5850781b49a8965d4c266f02529917721a20864dea5491c4b9
3
+ metadata.gz: 98158831447240516d9eb317044eac6747061dc9ee4573c52eef3bd0b08b1199
4
+ data.tar.gz: e4329aed6a4e1a2eae21d26bc7e61191490060c3d6d35ed7854e576d3e617f21
5
5
  SHA512:
6
- metadata.gz: '098f8e1013de0d59e3ebec5478b98147e5bdc166fc9ad03989c4af64cc4680f26fbda13f408f3dc919ce936654f875a469d91194ae94fef8e9b670feca1d7ec0'
7
- data.tar.gz: b58f6e2a99d512afd89dcf0626cb69b0746a02c087fd7a7f179d7386974b9ee4a0d61be58c985c1df92c1ba0719e4ee1bc5b8beedf4e44d2f8e135199920c070
6
+ metadata.gz: 3c2aa703154a0a19a801427a90ad5b5de20b3229eecb062aabca5c40fe83e76e3ce045dfbb1e844dc2442a3c890103b334ecdfddaeab52ef1c9f78427b87e5ff
7
+ data.tar.gz: 8a2718dccdb593131098e2f93375b4f8668120e567076c60432e143d35542ede6fa1b08a3dbe445cb2e1af564d7f06854843bee5d8d3c2b88325827772f16cee
@@ -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
 
@@ -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,37 @@
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 called price!
14
+ field :strike, :type => Float
15
+ validates :strike, presence: true
16
+
17
+ field :contractType
18
+ validates :contractType, presence: true
19
+
20
+ field :date
21
+ validates :date, presence: true
22
+
23
+ NOTIFICATION_TYPES = [ :NONE, :EMAIL, :SMS ]
24
+ ACTIONS = NOTIFICATION_TYPES
25
+ NOTIFICATION_NONE = :NONE
26
+ NOTIFICATION_EMAIL = :EMAIL
27
+ NOTIFICATION_SMS = :SMS
28
+ field :notification_type, :type => Symbol, :as => :action
29
+
30
+ DIRECTIONS = [ :ABOVE, :BELOW ]
31
+ DIRECTION_ABOVE = :ABOVE
32
+ DIRECTION_BELOW = :BELOW
33
+ field :direction, :type => Symbol
34
+
35
+ belongs_to :profile, :class_name => 'Ish::UserProfile'
36
+
37
+ 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.149
4
+ version: 0.0.33.150
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -162,6 +162,7 @@ files:
162
162
  - lib/warbler/covered_call_watcher.rb
163
163
  - lib/warbler/iron_condor.rb
164
164
  - lib/warbler/iron_condor_watcher.rb
165
+ - lib/warbler/option_watch.rb
165
166
  - lib/warbler/stock_action.rb
166
167
  - lib/warbler/stock_option.rb
167
168
  - lib/warbler/stock_watch.rb