sensei_eod_utils 0.0.12 → 0.0.13

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: ea68aad49e0c216b7e25b0996e5fe39d40f5ac3824e096f9c249a89ac365a643
4
- data.tar.gz: 9befcf4e1050eac2105b60baa2db648f0f830792fa50cb4d63ac157ad15b2d15
3
+ metadata.gz: 31b4df0411151b1c2bbe964037c80443442c313d8141478d6d07d9eeaa74e4c5
4
+ data.tar.gz: 6615717d0526935bbba3508c54e8a66d8411a45310e18aeaf16195cbbf2cf563
5
5
  SHA512:
6
- metadata.gz: ab592931197ff29e90d20c5f0b65e8f6aac992fc106e610bb679ca492a6767d577f20ff4424b70b0d255d25c9c0cfeacb681a1a4373589aa25b7ed3c95b852a1
7
- data.tar.gz: b150a5a7453f51ecd5ca57e168b39a2064702f5274eb1794c4660acb2c03adb55a58bc41e21abe7f83f4949d3d16d575b7f4b3ac1230f38be379163c06d70932
6
+ metadata.gz: a8a32b7623f2068db9070ab6c05b4f5c68df56ba4fc635e377c20b359732b7b04ce89ede98cac481a812345732ee1133006aa9d920c4eefe1f855b3d65bb76af
7
+ data.tar.gz: a9bab0a3b5ec415146d26f1a109a49b1e8e113261a0cbf6f7e9e5616b411c5e6291b30e4bb2e28f9f379745cef9b614cc6b1ee130fee98409e31a45984cea3f9
@@ -19,11 +19,11 @@ module EodFacade
19
19
  raise ArgumentError, "Error fetching options data for #{symbol}"
20
20
  end
21
21
 
22
- unless response.parsed_response[symbol]
23
- raise ArgumentError, "Option contract #{symbol} not found"
24
- end
25
-
26
- response.parsed_response[symbol]
22
+ contract_hash(
23
+ symbol: symbol,
24
+ contracts: contracts,
25
+ option_type: option_type
26
+ )
27
27
  end
28
28
 
29
29
  private
@@ -38,6 +38,20 @@ module EodFacade
38
38
  def url_path(underlying)
39
39
  "/options/#{underlying}"
40
40
  end
41
+
42
+ def contract_hash(symbol:, contracts:, option_type:)
43
+ by_expiration = contracts['data'].first
44
+ expiration_date = by_expiration && by_expiration['expirationDate']
45
+
46
+ by_option_type = by_expiration && by_expiration['options'][option_type]
47
+ contract = by_option_type&.find do |c|
48
+ c['contractName'] == symbol
49
+ end
50
+
51
+ raise ArgumentError, "Contract #{symbol} not found" unless contract
52
+
53
+ contract.merge('expirationDate' => expiration_date)
54
+ end
41
55
  end
42
56
  end
43
57
  end
@@ -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.12'
5
+ s.version = '0.0.13'
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.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nishant Shah