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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32db48446b16fb6975df439972db23bf881aaeb51607edba9fff5edebbf5f973
4
- data.tar.gz: 69875e7393058b48614041c89f3091c5a2d13165f3527ec90460035538570597
3
+ metadata.gz: 053b7c7fb5c830b9b7dffa3c846c036c42cbbfec10f61ec1d7fd2088342fbdea
4
+ data.tar.gz: 27597011d6f5cdeeb364d3209aed2cfd95202c17c49ad93c6c752db7b67c9068
5
5
  SHA512:
6
- metadata.gz: 3064ea9aa3c850aaa6c178a4ba7b3c3f29a7d42be9f7560866336448b216f4e76b56e59e68395f2456646aee623c4087445bf1f96c71763009271aeb382df89f
7
- data.tar.gz: 99dcedd55264c971d141a6cddef3c4d7c6e43c407dfb13af5c9a0a244aa4382daafb85dab5af1d56fccbc22df41c993a57ce3007137f9c8fc9788a2b4b7e6cd2
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
@@ -9,5 +9,6 @@ module EodModels
9
9
  define :OPTION, 'OPTION'
10
10
  define :STOCK, 'STOCK'
11
11
  define :ETF, 'ETF'
12
+ define :BOND, 'BOND'
12
13
  end
13
14
  end
@@ -4,34 +4,29 @@ module EodServices
4
4
  class InstrumentType
5
5
  class <<self
6
6
  def etf?(symbol)
7
- call(symbol) == EodModels::InstrumentType::ETF
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) == EodModels::InstrumentType::STOCK
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
- private
22
-
23
- def call(symbol)
24
- fundamentals = EodFacade::Fundamentals.call(symbol)
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
@@ -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'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sensei_eod_utils'
5
- s.version = '0.0.52'
5
+ s.version = '0.0.53'
6
6
  s.date = '2019-12-20'
7
7
  s.summary = 'Sensei trader utility functions and Eod api facade'
8
8
  s.authors = ['Nishant Shah']
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.52
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