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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4baf29056fb5eea6a152c68d259e00dc77c1b8933038ffa57f7cf26ea57a6c1
4
- data.tar.gz: 5cc60160b9be49f2e3521c14de595307d3f4352168c56be8c75be13ee5012af0
3
+ metadata.gz: cd6aac35369c50f31620e5789277576c5583fe794a1426306cee25fc3fc05d88
4
+ data.tar.gz: c17dbf154ed517eb8f12a9381f4f95b3eda24790d5551028434ecaf8b9c9df80
5
5
  SHA512:
6
- metadata.gz: a494cbf2307b6ab42f76d7db61bb9ca3e729363d015ed3be4456b53f65e2bb4d690a225bdcd16d5c341394ed24b8e4cc098ab243a04302ab544965da125697de
7
- data.tar.gz: 67e3fb70e47cabd54f59bb9a592d60ba3b9e549795287b396607e777d04a172ca55838929b8550da6eee85e84ce5b8580bdd87fc6332e85c44d3179ebd72f29f
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
- # from = '2023-12-20'
21
- # to = '2023-12-01'
22
- # points = Iro::Datapoint.where( k: params[:k] ).joins( :dates )
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
@@ -5,9 +5,13 @@ class Iro::Datapoint
5
5
  include Mongoid::Timestamps
6
6
  store_in collection: 'iro_datapoints'
7
7
 
8
- field :kind ## PUT, CALL, STOCK, CURRENCY, CRYPTO
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: 'STOCK',
143
+ kind: KIND_STOCK,
140
144
  symbol: symbol,
141
145
  date: row['Date'],
142
146
  quote_at: row['Date'],
@@ -37,5 +37,11 @@
37
37
  %li
38
38
  = link_to s, strategy_path(s)
39
39
  = link_to '[~]', edit_strategy_path(s)
40
+ .a
41
+ %ul
42
+ %li
43
+ Datapoints
44
+ = form_tag datapoints_by_symbol_path, method: :get do
45
+ = text_field_tag :q
40
46
 
41
47
 
@@ -0,0 +1,14 @@
1
+
2
+ .datapoints-index.maxwidth
3
+ .header
4
+ %h3.title= @symbol
5
+
6
+ %table.bordered.padded
7
+ %thead
8
+ %th quote_at
9
+ %th value
10
+ %tbody
11
+ - @datapoints.each do |point|
12
+ %tr
13
+ %td= pp_datetime point.quote_at
14
+ %td= point.value
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
@@ -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.33
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