ish_models 0.0.33.149 → 0.0.33.153

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: af77cb84fd5fe123e232d66b36e090ed15f5a98c4ce97cfa49d8d1a0717f83d9
4
- data.tar.gz: fd202da5dfb24c5850781b49a8965d4c266f02529917721a20864dea5491c4b9
3
+ metadata.gz: 8b5b1b87e7d98e765f23667d8bcf0fa8668871b6438d8f754c7f188ffbd37136
4
+ data.tar.gz: 77ad787fd7e42f057c177c542c5cfb39b6a55d068b25a335404930739e0c2e07
5
5
  SHA512:
6
- metadata.gz: '098f8e1013de0d59e3ebec5478b98147e5bdc166fc9ad03989c4af64cc4680f26fbda13f408f3dc919ce936654f875a469d91194ae94fef8e9b670feca1d7ec0'
7
- data.tar.gz: b58f6e2a99d512afd89dcf0626cb69b0746a02c087fd7a7f179d7386974b9ee4a0d61be58c985c1df92c1ba0719e4ee1bc5b8beedf4e44d2f8e135199920c070
6
+ metadata.gz: 4c28e4acab55505ec235a2e767268653f6c5447b99b5fbc3718445a495ce190d6c8733d20b3e1ae761ad3199f0ce3d868f79b1f0381565c72194adcea4dc29c7
7
+ data.tar.gz: fcfad8595373f51181c50a003bbb07ee88ae030afa4f374770b04c379f91a225a14ec84ed0ab433d1def5842f0eea0d33fce784b71777d2fa6018b7ecce4c862
@@ -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,37 @@ 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]
61
- raise Ish::InputError.new("invalid input, missing #{s}")
63
+ validOpts = %i| contractType strike |
64
+ validOpts.each do |s|
65
+ if _opts[s]
66
+ opts[s] = _opts[s]
67
+ else
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
76
+ if _opts[:ticker]
77
+ opts[:symbol] = _opts[:ticker].upcase
78
+ else
79
+ raise Ish::InputError.new("Invalid input, missing 'ticker'.")
80
+ end
64
81
 
65
- path = '/v1/marketdata/chains'
66
- out = self.get path, { query: opts }
67
- out
82
+ query = { apikey: ::TD_AME[:apiKey], strikeCount: 1 }.merge opts
83
+ path = "/v1/marketdata/chains"
84
+ out = self.get path, { query: query }
85
+ ## out = HTTParty.get "https://api.tdameritrade.com#{path}", { query: query }
86
+ out = out.parsed_response.deep_symbolize_keys
87
+ tmp_sym = "#{opts[:contractType].to_s.downcase}ExpDateMap".to_sym
88
+ out[tmp_sym].first[1].first[1][0]
68
89
  end
69
90
 
70
91
  end
92
+
@@ -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.149
4
+ version: 0.0.33.153
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