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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3aec6ab45a677eba7e1467fd0088a5e46b87eb91dad52002df219bad56c26429
4
- data.tar.gz: adf78ae8f2550592040dda80481438a9a6e60504097e572485d9f2aa5fbd7537
3
+ metadata.gz: e02502f06973a985d527d3680e497c074e092c5fe65ec30b0bf83343b3678234
4
+ data.tar.gz: d0007bb285275c621e4d07ce2628a3aa7ecc5d1965bdc532c9a27ea2efbaabb0
5
5
  SHA512:
6
- metadata.gz: a2347d585dfd6e7b425c6592e8a8c6d56ec241101489942e00bcac026dad091770003bbb9e03d28d80d0ed8ce7f6f06227efaf8233fb4953ac92c67e3354aaca
7
- data.tar.gz: df2ba85e9ad79a6ecb16adb1da5d2b548750dfd7d403f3bafc4718a47cdf0f5c80b5d4af6ac829e18071da0a9a3987afa26a2a0b1ab83b36a511d1aeee755653
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
- # 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
@@ -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 })
@@ -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,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
@@ -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.34
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