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 +4 -4
- data/lib/eod_facade/options.rb +19 -5
- data/sensei_eod_utils.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31b4df0411151b1c2bbe964037c80443442c313d8141478d6d07d9eeaa74e4c5
|
4
|
+
data.tar.gz: 6615717d0526935bbba3508c54e8a66d8411a45310e18aeaf16195cbbf2cf563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8a32b7623f2068db9070ab6c05b4f5c68df56ba4fc635e377c20b359732b7b04ce89ede98cac481a812345732ee1133006aa9d920c4eefe1f855b3d65bb76af
|
7
|
+
data.tar.gz: a9bab0a3b5ec415146d26f1a109a49b1e8e113261a0cbf6f7e9e5616b411c5e6291b30e4bb2e28f9f379745cef9b614cc6b1ee130fee98409e31a45984cea3f9
|
data/lib/eod_facade/options.rb
CHANGED
@@ -19,11 +19,11 @@ module EodFacade
|
|
19
19
|
raise ArgumentError, "Error fetching options data for #{symbol}"
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
data/sensei_eod_utils.gemspec
CHANGED