iron_warbler 2.0.7.33 → 2.0.7.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/iro/datapoints_controller.rb +3 -17
- data/app/models/iro/datapoint.rb +6 -2
- data/app/views/iro/_main_header.haml +6 -0
- data/app/views/iro/datapoints/index.haml +14 -0
- data/config/routes.rb +2 -0
- data/lib/iron_warbler.rb +19 -0
- data/lib/tasks/iro_tasks.rake +18 -0
- data/lib/tasks/iro_tasks.rake-old +0 -12
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd6aac35369c50f31620e5789277576c5583fe794a1426306cee25fc3fc05d88
|
4
|
+
data.tar.gz: c17dbf154ed517eb8f12a9381f4f95b3eda24790d5551028434ecaf8b9c9df80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11aeb5d8617e158e6a4e592dd401b59650f226e60100c31a8a2b48fe8cf3d7ba101ea7c404ad24ada2933bf8abbc38c8fac5bea075d3694e0e7bf15712c8dc32
|
7
|
+
data.tar.gz: d250b26d4f5be51875ec567c4a50da88eef68609bec3936a50fcec52a519ebc21131c3c427a4f42564f8d921009c868c5268bc564566891a55799c0263ce7b9c
|
@@ -17,23 +17,9 @@ class Iro::DatapointsController < Iro::ApplicationController
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def index
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
sql = "SELECT
|
25
|
-
dps.k, dps.v, d.date
|
26
|
-
FROM
|
27
|
-
iro_datapoints as dps
|
28
|
-
RIGHT JOIN dates d ON d.date = dps.d WHERE d.date BETWEEN '2023-12-01' AND '2023-12-31'
|
29
|
-
ORDER BY
|
30
|
-
d.date;"
|
31
|
-
|
32
|
-
# outs = ActiveRecord::Base.connection.execute(sql)
|
33
|
-
# puts! outs, 'outs'
|
34
|
-
|
35
|
-
render json: outs
|
36
|
-
|
20
|
+
authorize! :datapoints_index, Iro
|
21
|
+
@symbol = params[:symbol] || params[:q]
|
22
|
+
@datapoints = Iro::Datapoint.where( symbol: @symbol ).order_by( quote_at: :desc ).limit(100)
|
37
23
|
end
|
38
24
|
|
39
25
|
end
|
data/app/models/iro/datapoint.rb
CHANGED
@@ -5,9 +5,13 @@ class Iro::Datapoint
|
|
5
5
|
include Mongoid::Timestamps
|
6
6
|
store_in collection: 'iro_datapoints'
|
7
7
|
|
8
|
-
field :kind
|
8
|
+
field :kind
|
9
9
|
validates :kind, presence: true
|
10
10
|
index({ kind: -1 })
|
11
|
+
KIND_CRYPTO = 'CRYPTO'
|
12
|
+
KIND_STOCK = 'STOCK'
|
13
|
+
KIND_OPTION = 'OPTION' ## but not PUT or CALL
|
14
|
+
KIND_CURRENCY = 'CURRENCY'
|
11
15
|
|
12
16
|
field :symbol ## ticker, but use 'symbol' here
|
13
17
|
|
@@ -136,7 +140,7 @@ class Iro::Datapoint
|
|
136
140
|
csv = CSV.read(path, headers: true)
|
137
141
|
csv.each do |row|
|
138
142
|
flag = create({
|
139
|
-
kind:
|
143
|
+
kind: KIND_STOCK,
|
140
144
|
symbol: symbol,
|
141
145
|
date: row['Date'],
|
142
146
|
quote_at: row['Date'],
|
data/config/routes.rb
CHANGED
@@ -6,6 +6,8 @@ Iro::Engine.routes.draw do
|
|
6
6
|
|
7
7
|
post 'datapoints', to: '/iro/datapoints#create'
|
8
8
|
get 'datapoints', to: '/iro/datapoints#index'
|
9
|
+
get 'datapoints/by-symbol', to: '/iro/datapoints#index'
|
10
|
+
get 'datapoints/by-symbol/:symbol', to: '/iro/datapoints#index'
|
9
11
|
|
10
12
|
resources :option_watches
|
11
13
|
|
data/lib/iron_warbler.rb
CHANGED
@@ -5,4 +5,23 @@ require 'mongoid'
|
|
5
5
|
|
6
6
|
require "iro/engine"
|
7
7
|
|
8
|
+
class Iro::Iro
|
8
9
|
|
10
|
+
def self.get_coins
|
11
|
+
out = HTTParty.get( "https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest?slug=bitcoin,ethereum", {
|
12
|
+
headers: { 'X-CMC_PRO_API_KEY' => COINMARKETCAP[:key] },
|
13
|
+
})
|
14
|
+
out = out.parsed_response.deep_symbolize_keys
|
15
|
+
out[:data].each do |k, item|
|
16
|
+
opi = Iro::Datapoint.new({
|
17
|
+
kind: Iro::Datapoint::KIND_CRYPTO,
|
18
|
+
symbol: item[:symbol],
|
19
|
+
quote_at: item[:quote][:USD][:last_updated],
|
20
|
+
value: item[:quote][:USD][:price],
|
21
|
+
volume: item[:quote][:USD][:volume_24h],
|
22
|
+
})
|
23
|
+
opi.save!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/tasks/iro_tasks.rake
CHANGED
@@ -14,6 +14,24 @@ namespace :iro do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
desc 'Get BTC, ETH price from coinmarketcap'
|
18
|
+
task :get_coins => :environment do
|
19
|
+
while true
|
20
|
+
|
21
|
+
::Iro::Iro.get_coins
|
22
|
+
|
23
|
+
print '.'
|
24
|
+
# sleep 5 * 60 ## 5 minutes
|
25
|
+
sleep 55 * 60 ## 1 hr
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'get coins once'
|
30
|
+
task :get_coins_once => :environment do
|
31
|
+
::Iro::Iro.get_coins
|
32
|
+
print '^'
|
33
|
+
end
|
34
|
+
|
17
35
|
desc 'recommend position actions'
|
18
36
|
task recommend_position_actions: :environment do
|
19
37
|
Iro::Position.active.where({ kind: 'covered_call' }).map &:should_roll?
|
@@ -52,18 +52,6 @@ namespace :iro do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
desc 'Get BTC, ETH price from coinmarketcap'
|
56
|
-
task :get_coins => :environment do
|
57
|
-
while true
|
58
|
-
|
59
|
-
::Iro::Iro.get_coins
|
60
|
-
|
61
|
-
print '.'
|
62
|
-
# sleep 5 * 60 # 5 minutes
|
63
|
-
sleep 55 * 60 # 1 hr
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
55
|
desc 'Get COP from currencyfreaks, cron'
|
68
56
|
task :get_currencies => :environment do
|
69
57
|
::Iro::Iro.get_currencies
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_warbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.7.
|
4
|
+
version: 2.0.7.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- app/views/iro/api/stocks/show.json.jbuilder
|
263
263
|
- app/views/iro/api/stocks/show.json.jbuilder-bk
|
264
264
|
- app/views/iro/application/home.haml
|
265
|
+
- app/views/iro/datapoints/index.haml
|
265
266
|
- app/views/iro/options/_show_mini.haml
|
266
267
|
- app/views/iro/positions/_form.haml
|
267
268
|
- app/views/iro/positions/_formpart_4data.haml
|