iron_warbler 2.0.7.35 → 2.0.7.36

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: e02502f06973a985d527d3680e497c074e092c5fe65ec30b0bf83343b3678234
4
+ data.tar.gz: d0007bb285275c621e4d07ce2628a3aa7ecc5d1965bdc532c9a27ea2efbaabb0
5
5
  SHA512:
6
- metadata.gz: 11aeb5d8617e158e6a4e592dd401b59650f226e60100c31a8a2b48fe8cf3d7ba101ea7c404ad24ada2933bf8abbc38c8fac5bea075d3694e0e7bf15712c8dc32
7
- data.tar.gz: d250b26d4f5be51875ec567c4a50da88eef68609bec3936a50fcec52a519ebc21131c3c427a4f42564f8d921009c868c5268bc564566891a55799c0263ce7b9c
6
+ metadata.gz: a2f370d2954d01f2aea2cefd07d87b8d298fca8216d2f4b4f7ceb1de6de03d4af453ed0c0eb3fe10451360f9691f76e25a152e12a1314de2b77064b40ad5e4e3
7
+ data.tar.gz: e00471b9403ad26c509d4eb6e761f6967e121892269514b89aa147e81ab1c9dbdc46661cd28b1b5108e001cba7db602bcda7b168dca8d47a3d0efc9242d92f73
@@ -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,16 @@ namespace :iro do
32
32
  print '^'
33
33
  end
34
34
 
35
+ desc 'import historic treasuries'
36
+ task :import_1990_2023_treasuries => :environment do
37
+ ::Iro::Iro.import_1990_2023_treasuries
38
+ end
39
+
40
+ desc 'import 2024 treasuries'
41
+ task :import_2024_treasuries => :environment do
42
+ ::Iro::Iro.import_2024_treasuries
43
+ end
44
+
35
45
  desc 'recommend position actions'
36
46
  task recommend_position_actions: :environment do
37
47
  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.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev