ish_models 0.0.33.146 → 0.0.33.150
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ish/user_profile.rb +27 -0
- data/lib/ish_models.rb +1 -5
- data/lib/video.rb +11 -2
- data/lib/warbler/ameritrade.rb +21 -6
- data/lib/warbler/option_watch.rb +37 -0
- data/lib/warbler/stock_watch.rb +3 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98158831447240516d9eb317044eac6747061dc9ee4573c52eef3bd0b08b1199
|
4
|
+
data.tar.gz: e4329aed6a4e1a2eae21d26bc7e61191490060c3d6d35ed7854e576d3e617f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c2aa703154a0a19a801427a90ad5b5de20b3229eecb062aabca5c40fe83e76e3ce045dfbb1e844dc2442a3c890103b334ecdfddaeab52ef1c9f78427b87e5ff
|
7
|
+
data.tar.gz: 8a2718dccdb593131098e2f93375b4f8668120e567076c60432e143d35542ede6fa1b08a3dbe445cb2e1af564d7f06854843bee5d8d3c2b88325827772f16cee
|
data/lib/ish/user_profile.rb
CHANGED
@@ -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
|
|
@@ -81,4 +82,30 @@ class Ish::UserProfile
|
|
81
82
|
::Gameui::PremiumPurchase.where( user_profile_id: self.id )
|
82
83
|
end
|
83
84
|
|
85
|
+
# used in rake tasks
|
86
|
+
def self.generate delta
|
87
|
+
email = delta[:email]
|
88
|
+
password = delta[:password]
|
89
|
+
role_name = delta[:role_name]
|
90
|
+
|
91
|
+
profile = Ish::UserProfile.where( email: email ).first
|
92
|
+
if profile
|
93
|
+
puts! profile, "UserProfile#generate, already exists"
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
user = User.where( email: email ).first
|
98
|
+
if !user
|
99
|
+
user = User.new({ email: email, password: password })
|
100
|
+
end
|
101
|
+
profile = Ish::UserProfile.new({ email: email, name: email, role_name: role_name, user: user })
|
102
|
+
profile.save
|
103
|
+
|
104
|
+
if profile.persisted?
|
105
|
+
;
|
106
|
+
else
|
107
|
+
puts! profile.errors.full_messages, "Cannot save profile"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
84
111
|
end
|
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
|
-
|
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
|
data/lib/warbler/ameritrade.rb
CHANGED
@@ -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.
|
59
|
+
def self.get_option _opts
|
60
|
+
opts = {}
|
61
|
+
|
58
62
|
# validate input
|
59
|
-
%i|
|
60
|
-
|
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
|
-
|
66
|
-
|
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
|
data/lib/warbler/stock_watch.rb
CHANGED
@@ -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.
|
4
|
+
version: 0.0.33.150
|
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:
|
170
|
+
homepage: https://wasya.co
|
156
171
|
licenses:
|
157
|
-
-
|
172
|
+
- Proprietary
|
158
173
|
metadata: {}
|
159
174
|
post_install_message:
|
160
175
|
rdoc_options: []
|
@@ -171,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
186
|
- !ruby/object:Gem::Version
|
172
187
|
version: '0'
|
173
188
|
requirements: []
|
174
|
-
rubygems_version: 3.
|
189
|
+
rubygems_version: 3.1.6
|
175
190
|
signing_key:
|
176
191
|
specification_version: 4
|
177
192
|
summary: models of ish
|