iron_warbler 2.0.7.34 → 2.0.7.36
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 +16 -0
- data/app/views/iro/_main_header.haml +6 -0
- data/app/views/iro/datapoints/index.haml +16 -0
- data/config/routes.rb +2 -0
- data/lib/iron_warbler.rb +109 -0
- data/lib/tasks/iro_tasks.rake +10 -0
- 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: e02502f06973a985d527d3680e497c074e092c5fe65ec30b0bf83343b3678234
|
4
|
+
data.tar.gz: d0007bb285275c621e4d07ce2628a3aa7ecc5d1965bdc532c9a27ea2efbaabb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2f370d2954d01f2aea2cefd07d87b8d298fca8216d2f4b4f7ceb1de6de03d4af453ed0c0eb3fe10451360f9691f76e25a152e12a1314de2b77064b40ad5e4e3
|
7
|
+
data.tar.gz: e00471b9403ad26c509d4eb6e761f6967e121892269514b89aa147e81ab1c9dbdc46661cd28b1b5108e001cba7db602bcda7b168dca8d47a3d0efc9242d92f73
|
@@ -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
@@ -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 })
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
.datapoints-index.maxwidth
|
3
|
+
.header
|
4
|
+
%h3.title= @symbol
|
5
|
+
|
6
|
+
%table.bordered.padded
|
7
|
+
%thead
|
8
|
+
%th date
|
9
|
+
%th quote_at
|
10
|
+
%th value
|
11
|
+
%tbody
|
12
|
+
- @datapoints.each do |point|
|
13
|
+
%tr
|
14
|
+
%td= pp_date point.date
|
15
|
+
%td= pp_datetime point.quote_at
|
16
|
+
%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
@@ -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
|
data/lib/tasks/iro_tasks.rake
CHANGED
@@ -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.
|
4
|
+
version: 2.0.7.36
|
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
|