PolygonClient 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/client.rb +35 -0
- data/lib/polygon_client.rb +5 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0f6f23941618683f40b022c784f134186dba5b44ad3c741882ad3fdeb48c528
|
4
|
+
data.tar.gz: 9a0bee40debe66c1cdd4dd67e6fae02131841eda9b145d529b0c1b983c84be87
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5c88abb281bcb8c4499852cbe4ecd640d272cc29264837334e2866bae660b2e408a7be8a4e629f5f342c98c52b7a169ee4b8c062ccbb16d02ecb975f6899576
|
7
|
+
data.tar.gz: e86c54b33f78e58f6b14c3e24add8fe850bc4033d26085895939086876b25e285a6491f78fc36cb2e1c010b43f4f20f8e1000aac89b91977b1ca6936b8005e3f
|
data/lib/client.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Polygon
|
4
|
+
class Client
|
5
|
+
def initialize(api_key)
|
6
|
+
@api_key = api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def grouped_daily(date)
|
10
|
+
::HTTParty.get("#{grouped_daily_endpoint}/#{formatted_date(date)}#{api_query_string}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def single_daily(ticker, date)
|
14
|
+
::HTTParty.get("#{single_daily_endpoint}/#{ticker}/#{formatted_date(date)}#{api_query_string}")
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def grouped_daily_endpoint
|
20
|
+
'https://api.polygon.io/v2/aggs/grouped/locale/us/market/stocks'
|
21
|
+
end
|
22
|
+
|
23
|
+
def single_daily_endpoint
|
24
|
+
'https://api.polygon.io/v1/open-close'
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_query_string
|
28
|
+
"?apiKey=#{@api_key}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def formatted_date(date)
|
32
|
+
date.strftime('%Y-%m-%d')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: PolygonClient
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Ahale
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple client for accessing the Polygon Finance API
|
14
|
+
email: ahaleben@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/client.rb
|
20
|
+
- lib/polygon_client.rb
|
21
|
+
homepage: https://rubygems.org/gems/hola
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.4.19
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Polygon Finance API
|
44
|
+
test_files: []
|