iron_warbler 2.0.7.35 → 2.0.7.37

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: cd6aac35369c50f31620e5789277576c5583fe794a1426306cee25fc3fc05d88
4
- data.tar.gz: c17dbf154ed517eb8f12a9381f4f95b3eda24790d5551028434ecaf8b9c9df80
3
+ metadata.gz: 7207f71989ba452eb0b9de7db2d9a66a6571112e23057a225519cbdab4fb1f79
4
+ data.tar.gz: 4a2663f019822b6c6fded27cd41dcd23beb7cf12818e10d4f6057e8620449a6e
5
5
  SHA512:
6
- metadata.gz: 11aeb5d8617e158e6a4e592dd401b59650f226e60100c31a8a2b48fe8cf3d7ba101ea7c404ad24ada2933bf8abbc38c8fac5bea075d3694e0e7bf15712c8dc32
7
- data.tar.gz: d250b26d4f5be51875ec567c4a50da88eef68609bec3936a50fcec52a519ebc21131c3c427a4f42564f8d921009c868c5268bc564566891a55799c0263ce7b9c
6
+ metadata.gz: 43c22a4d167d7b7c8095bcee5bc5280826586b2c583e92cb1353a30459ce578bfc6e603fdb008b3582f1dfadbca342dd4c866590f3a6b332f15198cd9a919818
7
+ data.tar.gz: 0d5183d3b41c67afbb4dfdc3a9fade2ec65400483aacb2b71439d88f630b0e9f570755884d7d316d3feba71ad70c9d2cccd6d5c4e2b8676b028d1a0c78fa210d
@@ -12,8 +12,24 @@ class Iro::Datapoint
12
12
  KIND_STOCK = 'STOCK'
13
13
  KIND_OPTION = 'OPTION' ## but not PUT or CALL
14
14
  KIND_CURRENCY = 'CURRENCY'
15
+ KIND_TREASURY = 'TREASURY'
15
16
 
16
17
  field :symbol ## ticker, but use 'symbol' here
18
+ SYMBOL_BTC = 'BTC'
19
+ SYMBOL_ETH = 'ETH'
20
+ SYMBOL_T1MO = 'T1MO'
21
+ SYMBOL_T2MO = 'T2MO'
22
+ SYMBOL_T3MO = 'T3MO'
23
+ SYMBOL_T4MO = 'T4MO'
24
+ SYMBOL_T6MO = 'T6MO'
25
+ SYMBOL_T1YR = 'T1YR'
26
+ SYMBOL_T2YR = 'T2YR'
27
+ SYMBOL_T3YR = 'T3YR'
28
+ SYMBOL_T5YR = 'T5YR'
29
+ SYMBOL_T7YR = 'T7YR'
30
+ SYMBOL_T10YR = 'T10YR'
31
+ SYMBOL_T20YR = 'T20YR'
32
+ SYMBOL_T30YR = 'T30YR'
17
33
 
18
34
  field :date, type: Date ## @obsolete, use quote_at
19
35
  index({ kind: -1, date: -1 })
@@ -5,10 +5,12 @@
5
5
 
6
6
  %table.bordered.padded
7
7
  %thead
8
+ %th date
8
9
  %th quote_at
9
10
  %th value
10
11
  %tbody
11
12
  - @datapoints.each do |point|
12
13
  %tr
14
+ %td= pp_date point.date
13
15
  %td= pp_datetime point.quote_at
14
16
  %td= point.value
data/lib/iron_warbler.rb CHANGED
@@ -14,6 +14,7 @@ class Iro::Iro
14
14
  out = out.parsed_response.deep_symbolize_keys
15
15
  out[:data].each do |k, item|
16
16
  opi = Iro::Datapoint.new({
17
+ date: Time.now.to_date,
17
18
  kind: Iro::Datapoint::KIND_CRYPTO,
18
19
  symbol: item[:symbol],
19
20
  quote_at: item[:quote][:USD][:last_updated],
@@ -24,4 +25,112 @@ class Iro::Iro
24
25
  end
25
26
  end
26
27
 
28
+ def self.get_treasuries
29
+ response = HTTParty.get( "https://home.treasury.gov/resource-center/data-chart-center/interest-rates/daily-treasury-rates.csv/all/#{Time.now.strftime('%Y%m')}?type=daily_treasury_yield_curve&field_tdr_date_value_month=#{Time.now.strftime('%Y%m')}&page&_format=csv")
30
+ outs = CSV.parse( response.body, { headers: true })
31
+ out = outs[0]
32
+ date = Date.strptime(out['Date'], '%m/%d/%Y')
33
+ {
34
+ '1 Mo' => Iro::Datapoint::SYMBOL_T1MO,
35
+ '2 Mo' => Iro::Datapoint::SYMBOL_T2MO,
36
+ '3 Mo' => Iro::Datapoint::SYMBOL_T3MO,
37
+ '4 Mo' => Iro::Datapoint::SYMBOL_T4MO,
38
+ '6 Mo' => Iro::Datapoint::SYMBOL_T6MO,
39
+ '1 Yr' => Iro::Datapoint::SYMBOL_T1YR,
40
+ '2 Yr' => Iro::Datapoint::SYMBOL_T2YR,
41
+ '3 Yr' => Iro::Datapoint::SYMBOL_T3YR,
42
+ '5 Yr' => Iro::Datapoint::SYMBOL_T5YR,
43
+ '7 Yr' => Iro::Datapoint::SYMBOL_T7YR,
44
+ '10 Yr' => Iro::Datapoint::SYMBOL_T10YR,
45
+ '20 Yr' => Iro::Datapoint::SYMBOL_T20YR,
46
+ '30 Yr' => Iro::Datapoint::SYMBOL_T30YR,
47
+ }.each do |k, v|
48
+ opi = Iro::Datapoint.new({
49
+ date: date,
50
+ quote_at: date,
51
+ kind: Iro::Datapoint::KIND_TREASURY,
52
+ symbol: v,
53
+ value: out[k],
54
+ })
55
+ opi.save!
56
+ print '^'
57
+ end
58
+ end
59
+
60
+ def self.import_1990_2023_treasuries
61
+ outs = CSV.parse( File.read( Rails.root.join('data', 'treasuries', '1990..23 daily-treasury-rates.csv') ), { headers: true })
62
+ outs.each do |out|
63
+ date = Date.strptime(out['Date'], '%m/%d/%y')
64
+ {
65
+ '1 Mo' => Iro::Datapoint::SYMBOL_T1MO,
66
+ '2 Mo' => Iro::Datapoint::SYMBOL_T2MO,
67
+ '3 Mo' => Iro::Datapoint::SYMBOL_T3MO,
68
+ '4 Mo' => Iro::Datapoint::SYMBOL_T4MO,
69
+ '6 Mo' => Iro::Datapoint::SYMBOL_T6MO,
70
+ '1 Yr' => Iro::Datapoint::SYMBOL_T1YR,
71
+ '2 Yr' => Iro::Datapoint::SYMBOL_T2YR,
72
+ '3 Yr' => Iro::Datapoint::SYMBOL_T3YR,
73
+ '5 Yr' => Iro::Datapoint::SYMBOL_T5YR,
74
+ '7 Yr' => Iro::Datapoint::SYMBOL_T7YR,
75
+ '10 Yr' => Iro::Datapoint::SYMBOL_T10YR,
76
+ '20 Yr' => Iro::Datapoint::SYMBOL_T20YR,
77
+ '30 Yr' => Iro::Datapoint::SYMBOL_T30YR,
78
+ }.each do |k, v|
79
+ if out[k]
80
+ opi = Iro::Datapoint.new({
81
+ date: date,
82
+ quote_at: date,
83
+ kind: Iro::Datapoint::KIND_TREASURY,
84
+ symbol: v,
85
+ value: out[k],
86
+ })
87
+ begin
88
+ opi.save!
89
+ rescue Mongoid::Errors::Validations => err
90
+ puts! err, 'err'
91
+ end
92
+ print '^'
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ def self.import_2024_treasuries
99
+ outs = CSV.parse( File.read( Rails.root.join('data', 'treasuries', '2024 daily-treasury-rates.csv') ), { headers: true })
100
+ outs.each do |out|
101
+ date = Date.strptime(out['Date'], '%m/%d/%Y')
102
+ {
103
+ '1 Mo' => Iro::Datapoint::SYMBOL_T1MO,
104
+ '2 Mo' => Iro::Datapoint::SYMBOL_T2MO,
105
+ '3 Mo' => Iro::Datapoint::SYMBOL_T3MO,
106
+ '4 Mo' => Iro::Datapoint::SYMBOL_T4MO,
107
+ '6 Mo' => Iro::Datapoint::SYMBOL_T6MO,
108
+ '1 Yr' => Iro::Datapoint::SYMBOL_T1YR,
109
+ '2 Yr' => Iro::Datapoint::SYMBOL_T2YR,
110
+ '3 Yr' => Iro::Datapoint::SYMBOL_T3YR,
111
+ '5 Yr' => Iro::Datapoint::SYMBOL_T5YR,
112
+ '7 Yr' => Iro::Datapoint::SYMBOL_T7YR,
113
+ '10 Yr' => Iro::Datapoint::SYMBOL_T10YR,
114
+ '20 Yr' => Iro::Datapoint::SYMBOL_T20YR,
115
+ '30 Yr' => Iro::Datapoint::SYMBOL_T30YR,
116
+ }.each do |k, v|
117
+ if out[k]
118
+ opi = Iro::Datapoint.new({
119
+ date: date,
120
+ quote_at: date,
121
+ kind: Iro::Datapoint::KIND_TREASURY,
122
+ symbol: v,
123
+ value: out[k],
124
+ })
125
+ begin
126
+ opi.save!
127
+ rescue Mongoid::Errors::Validations => err
128
+ puts! err, 'err'
129
+ end
130
+ print '^'
131
+ end
132
+ end
133
+ end
134
+ end
135
+
27
136
  end
@@ -32,6 +32,22 @@ namespace :iro do
32
32
  print '^'
33
33
  end
34
34
 
35
+ desc 'get treasuries'
36
+ task :get_treasuries => :environment do
37
+ ::Iro::Iro.get_treasuries
38
+ print '^'
39
+ end
40
+
41
+ desc 'import historic treasuries'
42
+ task :import_1990_2023_treasuries => :environment do
43
+ ::Iro::Iro.import_1990_2023_treasuries
44
+ end
45
+
46
+ desc 'import 2024 treasuries'
47
+ task :import_2024_treasuries => :environment do
48
+ ::Iro::Iro.import_2024_treasuries
49
+ end
50
+
35
51
  desc 'recommend position actions'
36
52
  task recommend_position_actions: :environment do
37
53
  Iro::Position.active.where({ kind: 'covered_call' }).map &:should_roll?
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.35
4
+ version: 2.0.7.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev