ish_models 0.0.33.124 → 0.0.33.130
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gameui/map.rb +9 -1
- data/lib/ish/ameritrade.rb +83 -0
- data/lib/ish/input_error.rb +3 -0
- data/lib/ish_models/user_profile.rb +7 -1
- data/lib/ish_models.rb +2 -0
- data/lib/newsitem.rb +4 -3
- data/lib/photo.rb +9 -9
- metadata +7 -6
- data/lib/gallery2.rb-trash +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c34bbd347229cb392198bb194abc4c7d2902cb478aaac34b43b89c2014ab2d3
|
4
|
+
data.tar.gz: 83c55591061a4ed85905e50f3aaf6fdcae9eed57d25fb4f0f36dd1cbe4d16bbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e9dc8ad1cd2f1236963b23d8c957c586e9b6736c8477001e393d4cff2fe9033c420752a5ce73e0ff3b18fe8881c647aa15ca447a9b899f3e3fd062aacb588b
|
7
|
+
data.tar.gz: e4337aed790fc7190cf0341dc158443d459b4aa0b85580594971362d38bef285fa8a6b9cae97e175a0d5f344964bc01a84778c34a042bb67bc364bde586f886e
|
data/lib/gameui/map.rb
CHANGED
@@ -4,10 +4,14 @@ 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
|
10
11
|
field :parent_slug
|
12
|
+
def name
|
13
|
+
slug
|
14
|
+
end
|
11
15
|
|
12
16
|
field :w, type: Integer
|
13
17
|
validates :w, presence: true
|
@@ -26,5 +30,9 @@ class ::Gameui::Map
|
|
26
30
|
field :ordering_type, type: String, default: 'custom' # timestamp, alphabetic, custom
|
27
31
|
validates :ordering_type, presence: true
|
28
32
|
|
29
|
-
|
33
|
+
def self.list conditions = { is_trash: false }
|
34
|
+
out = self.order_by( created_at: :desc )
|
35
|
+
[['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
|
36
|
+
end
|
37
|
+
|
30
38
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# * make calls every once in a while
|
4
|
+
# * If the option price dips below a threshold, close the position (create the order to buy back the option)
|
5
|
+
#
|
6
|
+
|
7
|
+
# cron job or service? Well, I've historically done service. Cron is easier tho. The wiring should be for both.
|
8
|
+
|
9
|
+
# https://developer.tdameritrade.com/option-chains/apis/get/marketdata/chains
|
10
|
+
# FVRR_082021P200
|
11
|
+
|
12
|
+
require 'httparty'
|
13
|
+
|
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
|
51
|
+
|
52
|
+
class Ish::Ameritrade::Api
|
53
|
+
include ::HTTParty
|
54
|
+
base_uri 'https://api.tdameritrade.com'
|
55
|
+
|
56
|
+
def self.get_quote opts
|
57
|
+
# validate input
|
58
|
+
%i| symbol |.each do |s|
|
59
|
+
if !opts[s]
|
60
|
+
raise Ish::InputError.new("invalid input, missing #{s}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
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
|
67
|
+
out
|
68
|
+
end
|
69
|
+
|
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
|
81
|
+
end
|
82
|
+
|
83
|
+
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(
|
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
@@ -33,9 +33,11 @@ require 'gameui/map.rb'
|
|
33
33
|
require 'gameui/marker.rb'
|
34
34
|
require 'gameui/premium_purchase.rb'
|
35
35
|
|
36
|
+
require 'ish/ameritrade'
|
36
37
|
require 'ish/covered_call'
|
37
38
|
require 'ish/crawler.rb'
|
38
39
|
require 'ish/gallery_name.rb'
|
40
|
+
require 'ish/input_error.rb'
|
39
41
|
require 'ish/iron_condor.rb'
|
40
42
|
require 'ish/iron_condor_watcher.rb'
|
41
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,11 +1,11 @@
|
|
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.130
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-05-10 00:00:00.000000000 Z
|
@@ -114,17 +114,18 @@ files:
|
|
114
114
|
- lib/event.rb
|
115
115
|
- lib/feature.rb
|
116
116
|
- lib/gallery.rb
|
117
|
-
- lib/gallery2.rb-trash
|
118
117
|
- lib/gameui.rb
|
119
118
|
- lib/gameui/map.rb
|
120
119
|
- lib/gameui/marker.rb
|
121
120
|
- lib/gameui/premium_purchase.rb
|
122
121
|
- lib/ish/alphavantage_stockwatcher.rb
|
122
|
+
- lib/ish/ameritrade.rb
|
123
123
|
- lib/ish/campaign.rb
|
124
124
|
- lib/ish/covered_call.rb
|
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
|
@@ -154,7 +155,7 @@ homepage: http://wasya.co
|
|
154
155
|
licenses:
|
155
156
|
- MIT
|
156
157
|
metadata: {}
|
157
|
-
post_install_message:
|
158
|
+
post_install_message:
|
158
159
|
rdoc_options: []
|
159
160
|
require_paths:
|
160
161
|
- lib
|
@@ -169,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
170
|
- !ruby/object:Gem::Version
|
170
171
|
version: '0'
|
171
172
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
173
|
-
signing_key:
|
173
|
+
rubygems_version: 3.2.25
|
174
|
+
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: models of ish
|
176
177
|
test_files: []
|
data/lib/gallery2.rb-trash
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
|
2
|
-
class Gallery2
|
3
|
-
include ::Mongoid::Document
|
4
|
-
include ::Mongoid::Timestamps
|
5
|
-
store_in :collection => 'galleries'
|
6
|
-
|
7
|
-
field :is_feature, :type => Boolean, :default => false
|
8
|
-
field :is_public, :type => Boolean, :default => false
|
9
|
-
field :is_done, :type => Boolean, :default => false
|
10
|
-
field :is_trash, :type => Boolean, :default => false
|
11
|
-
|
12
|
-
default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
|
13
|
-
index({ :is_public => 1, :is_trash => -1, :order_by => 1 })
|
14
|
-
|
15
|
-
field :x, :type => Float
|
16
|
-
field :y, :type => Float
|
17
|
-
|
18
|
-
def self.list conditions = { :is_trash => false }
|
19
|
-
out = self.where( conditions ).order_by( :created_at => :desc )
|
20
|
-
[['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
|
21
|
-
end
|
22
|
-
|
23
|
-
belongs_to :site
|
24
|
-
validates :site, :presence => true
|
25
|
-
|
26
|
-
belongs_to :user_profile, :optional => true, :class_name => 'IshModels::UserProfile'
|
27
|
-
field :username, :type => String
|
28
|
-
|
29
|
-
field :name, :type => String
|
30
|
-
validates :name, :uniqueness => true # , :allow_nil => false
|
31
|
-
|
32
|
-
field :galleryname, :type => String
|
33
|
-
index({ :galleryname => -1 }, { :unique => true })
|
34
|
-
embeds_many :gallery_names, :class_name => 'Ish::GalleryName'
|
35
|
-
|
36
|
-
field :subhead, :type => String
|
37
|
-
field :descr, :type => String, :as => :description
|
38
|
-
field :lang, :type => String, :default => 'en'
|
39
|
-
|
40
|
-
has_many :photos
|
41
|
-
|
42
|
-
belongs_to :tag, :optional => true
|
43
|
-
belongs_to :city, :optional => true
|
44
|
-
belongs_to :venue, :optional => true
|
45
|
-
|
46
|
-
has_many :newsitems
|
47
|
-
|
48
|
-
set_callback(:create, :before) do |doc|
|
49
|
-
if doc.user_profile && doc.user_profile.username
|
50
|
-
doc.username = doc.user_profile.username
|
51
|
-
end
|
52
|
-
doc.galleryname ||= doc.id.to_s
|
53
|
-
|
54
|
-
#
|
55
|
-
# newsitems
|
56
|
-
#
|
57
|
-
if doc.is_public
|
58
|
-
# for the sites
|
59
|
-
if doc.site
|
60
|
-
sites = Site.where( :domain => doc.site.domain )
|
61
|
-
sites.each do |site|
|
62
|
-
n = Newsitem.new {}
|
63
|
-
n.gallery = doc
|
64
|
-
n.username = doc.username
|
65
|
-
site.newsitems << n
|
66
|
-
flag = site.save
|
67
|
-
if !flag
|
68
|
-
puts! site.errors
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
# for the city
|
73
|
-
if doc.city
|
74
|
-
n = Newsitem.new {}
|
75
|
-
n.gallery = doc
|
76
|
-
n.city = doc.city
|
77
|
-
n.username = doc.username
|
78
|
-
n.save
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# cache
|
84
|
-
#
|
85
|
-
if doc.site
|
86
|
-
doc.site.touch
|
87
|
-
end
|
88
|
-
if doc.city
|
89
|
-
doc.city.touch
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
# @deprecated, use Gallery::ACTIONS
|
95
|
-
def self.actions
|
96
|
-
[ 'show_mini', 'show_long', 'show' ]
|
97
|
-
end
|
98
|
-
ACTIONS = [ 'show_mini', 'show_long', 'show' ]
|
99
|
-
|
100
|
-
end
|
101
|
-
|