iron_warbler 2.0.7.33 → 2.0.7.34

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: 3aec6ab45a677eba7e1467fd0088a5e46b87eb91dad52002df219bad56c26429
4
+ data.tar.gz: adf78ae8f2550592040dda80481438a9a6e60504097e572485d9f2aa5fbd7537
5
5
  SHA512:
6
- metadata.gz: a494cbf2307b6ab42f76d7db61bb9ca3e729363d015ed3be4456b53f65e2bb4d690a225bdcd16d5c341394ed24b8e4cc098ab243a04302ab544965da125697de
7
- data.tar.gz: 67e3fb70e47cabd54f59bb9a592d60ba3b9e549795287b396607e777d04a172ca55838929b8550da6eee85e84ce5b8580bdd87fc6332e85c44d3179ebd72f29f
6
+ metadata.gz: a2347d585dfd6e7b425c6592e8a8c6d56ec241101489942e00bcac026dad091770003bbb9e03d28d80d0ed8ce7f6f06227efaf8233fb4953ac92c67e3354aaca
7
+ data.tar.gz: df2ba85e9ad79a6ecb16adb1da5d2b548750dfd7d403f3bafc4718a47cdf0f5c80b5d4af6ac829e18071da0a9a3987afa26a2a0b1ab83b36a511d1aeee755653
@@ -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'],
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.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev