sensei_eod_utils 0.0.52 → 0.0.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eod_facade/bond_fundamentals.rb +37 -0
- data/lib/eod_models/instrument_type.rb +1 -0
- data/lib/eod_services/instrument_type.rb +12 -17
- data/lib/sensei_eod_utils.rb +2 -2
- data/sensei_eod_utils.gemspec +1 -1
- 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: 053b7c7fb5c830b9b7dffa3c846c036c42cbbfec10f61ec1d7fd2088342fbdea
|
4
|
+
data.tar.gz: 27597011d6f5cdeeb364d3209aed2cfd95202c17c49ad93c6c752db7b67c9068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e51d7f7bca80e1eafc8638f3f6fcb6e89bd9c28b1589e77c2dffa3eb102ba5b9e939f3b1e8c8c35eb6bec1de383dfda7f3c67747bf9d298c6d5cba00e263a01
|
7
|
+
data.tar.gz: b1d6ad36100c1e7804ff041ce0917c76d89c383f1069bddd2b6a9ed7792fa57f259c83444a4cfd03c4ede7db31fbb8f2ccabff3abf482c8a2354a04c91837d4d
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'oj'
|
4
|
+
require_relative '../cache/redis_cache.rb'
|
5
|
+
|
6
|
+
module EodFacade
|
7
|
+
class BondFundamentals < ::EodFacade::Base
|
8
|
+
class << self
|
9
|
+
def call(symbol)
|
10
|
+
unless Cache::RedisCache.get(redis_key(symbol))
|
11
|
+
response = make_request(url_path(symbol))
|
12
|
+
|
13
|
+
unless response.success?
|
14
|
+
raise ArgumentError, "Error fetching bond fundamentals data for #{symbol}"
|
15
|
+
end
|
16
|
+
|
17
|
+
Cache::RedisCache.set(
|
18
|
+
redis_key(symbol),
|
19
|
+
response.parsed_response.to_json
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
Oj.load(Cache::RedisCache.get(redis_key(symbol)))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def url_path(symbol)
|
29
|
+
"/bond-fundamentals/#{symbol}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def redis_key(symbol)
|
33
|
+
"#{symbol}_bond_fundamentals"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -4,34 +4,29 @@ module EodServices
|
|
4
4
|
class InstrumentType
|
5
5
|
class <<self
|
6
6
|
def etf?(symbol)
|
7
|
-
call(symbol)
|
7
|
+
fundamentals = EodFacade::Fundamentals.call(symbol)
|
8
|
+
!!(fundamentals.dig('General', 'Type') == 'ETF')
|
9
|
+
rescue ArgumentError
|
10
|
+
false
|
8
11
|
end
|
9
12
|
|
10
13
|
def stock?(symbol)
|
11
|
-
call(symbol)
|
14
|
+
fundamentals = EodFacade::Fundamentals.call(symbol)
|
15
|
+
!!(fundamentals.dig('General', 'Type') == 'Common Stock')
|
16
|
+
rescue ArgumentError
|
17
|
+
false
|
12
18
|
end
|
13
19
|
|
14
20
|
def option?(symbol)
|
15
|
-
# call(symbol) == EodModels::InstrumentType::OPTION
|
16
21
|
!!EodFacade::Options.call(symbol)
|
17
22
|
rescue ArgumentError
|
18
23
|
false
|
19
24
|
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if fundamentals['General']['Type'] == 'ETF'
|
27
|
-
EodModels::InstrumentType::ETF
|
28
|
-
elsif fundamentals['General']['Type'] == 'Common Stock'
|
29
|
-
EodModels::InstrumentType::STOCK
|
30
|
-
elsif EodFacade::Options.call(symbol)
|
31
|
-
EodModels::InstrumentType::OPTION
|
32
|
-
else
|
33
|
-
raise ArgumentError, "Invalid intrument type for #{symbol}"
|
34
|
-
end
|
26
|
+
def bond?(symbol)
|
27
|
+
!!EodFacade::BondFundamentals.call(symbol)
|
28
|
+
rescue ArgumentError
|
29
|
+
false
|
35
30
|
end
|
36
31
|
end
|
37
32
|
end
|
data/lib/sensei_eod_utils.rb
CHANGED
@@ -4,15 +4,15 @@ require 'eod_models/option_type.rb'
|
|
4
4
|
require 'eod_models/instrument_type.rb'
|
5
5
|
require 'eod_models/trade_action.rb'
|
6
6
|
|
7
|
-
require 'eod_services/contract.rb'
|
8
|
-
|
9
7
|
require 'eod_facade/base.rb'
|
10
8
|
require 'eod_facade/constants.rb'
|
11
9
|
require 'eod_facade/fundamentals.rb'
|
12
10
|
require 'eod_facade/options.rb'
|
13
11
|
require 'eod_facade/eod.rb'
|
14
12
|
require 'eod_facade/dividends.rb'
|
13
|
+
require 'eod_facade/bond_fundamentals.rb'
|
15
14
|
|
15
|
+
require 'eod_services/contract.rb'
|
16
16
|
require 'eod_services/instrument_type.rb'
|
17
17
|
|
18
18
|
require 'sensei_api/base'
|
data/sensei_eod_utils.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensei_eod_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nishant Shah
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- README.md
|
80
80
|
- lib/cache/redis_cache.rb
|
81
81
|
- lib/eod_facade/base.rb
|
82
|
+
- lib/eod_facade/bond_fundamentals.rb
|
82
83
|
- lib/eod_facade/constants.rb
|
83
84
|
- lib/eod_facade/dividends.rb
|
84
85
|
- lib/eod_facade/eod.rb
|