massiveclient 0.3.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c561f94c72e99482269b0e7a6b271185c7f21b739d3b416fca8eaf40967e4aa0
4
+ data.tar.gz: 8a9480b2425053065d8963d6b6e25ce91cc7940690d4b63ed6bb2908b579b67a
5
+ SHA512:
6
+ metadata.gz: c2ed654a9e6c6ba3e16120e978c9ce086250e7ad378ad525739f22cf53bd7bf5e249afd6700062a63a6db84adef44e37731235a787c41a47b090a09e123da7b4
7
+ data.tar.gz: 896cef06a684d87a1871c727fee0ca9a6c5c9ee2fa315e3de93337ccece56c6608c4f62f8d8b7e9aeeae9ef42f05087946ff84af2b8f8b98bb129cad6a9d4db4
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .env
2
+ pkg
data/.rubocop.yml ADDED
@@ -0,0 +1,49 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.6.0
6
+ DisabledByDefault: false
7
+ Exclude:
8
+ - '**/vendor/**/*'
9
+ - 'bin/**/*'
10
+
11
+ Layout/LineLength:
12
+ Max: 120
13
+
14
+ Metrics/AbcSize:
15
+ Max: 24
16
+
17
+ Metrics/CyclomaticComplexity:
18
+ Max: 10
19
+
20
+ Metrics/PerceivedComplexity:
21
+ Max: 10
22
+
23
+ Style/StringLiterals:
24
+ EnforcedStyle: double_quotes
25
+
26
+ Style/Documentation:
27
+ Enabled: false
28
+
29
+ Style/SymbolArray:
30
+ EnforcedStyle: brackets
31
+
32
+ Style/AccessModifierDeclarations:
33
+ EnforcedStyle: group
34
+
35
+ Style/HashEachMethods:
36
+ Enabled: true
37
+
38
+ Style/HashTransformKeys:
39
+ Enabled: true
40
+
41
+ Style/HashTransformValues:
42
+ Enabled: true
43
+
44
+ Layout/MultilineMethodCallIndentation:
45
+ EnforcedStyle: indented_relative_to_receiver
46
+
47
+ Performance:
48
+ Exclude:
49
+ - '**/test/**/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.3.0] - 2025-11-28
6
+
7
+ ### Changed
8
+ - **BREAKING**: Updated to Faraday 2.x (from 0.17.x)
9
+ - Removed `faraday_middleware` and `faraday_middleware-parse_oj` dependencies
10
+ - Now uses built-in Faraday JSON parsing instead of OJ middleware
11
+ - Added `faraday-retry` gem for retry functionality
12
+ - Updated ActiveSupport from ~> 6.0 to ~> 7.0
13
+ - Updated Rubocop from ~> 0.80 to ~> 1.50
14
+ - Removed `rubocop-performance` dependency
15
+ - Removed `bundler-audit` dependency (not compatible with Bundler 4.x)
16
+ - Updated Bundler requirement to >= 2.3
17
+
18
+ ### Added
19
+ - Ruby 3.4+ support
20
+ - Verified compatibility with Massive.com API (formerly Polygon.io)
21
+
22
+ ### Fixed
23
+ - Fixed bundler compatibility issues with Ruby 3.4.6
24
+ - Fixed retry middleware for Faraday 2.x
25
+ - All 38 tests passing with both VCR cassettes and live API
26
+
27
+ ### Notes
28
+ - This release maintains the `polygonio` gem name but will be migrated to `massive` gem in the future
29
+ - API endpoints continue to work with both polygon.io and massive.com domains
30
+ - The `/v2/reference/financials` endpoint is deprecated by Massive.com API
31
+
32
+ ## [0.2.4] - Previous Release
33
+ - Last version before modernization updates
34
+ - Used Faraday 0.17.x and ActiveSupport 6.x
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in gatekeeper_client.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,197 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ massiveclient (0.3.0)
5
+ activesupport (>= 7.0)
6
+ dry-struct (>= 1.2)
7
+ dry-types (>= 1.2)
8
+ eventmachine (>= 1.2)
9
+ faraday (>= 2.0)
10
+ faraday-retry (>= 2.0)
11
+ oj (>= 3.10)
12
+ permessage_deflate (>= 0.1)
13
+ websocket-driver (>= 0.7)
14
+
15
+ GEM
16
+ remote: https://rubygems.org/
17
+ specs:
18
+ activesupport (8.1.1)
19
+ base64
20
+ bigdecimal
21
+ concurrent-ruby (~> 1.0, >= 1.3.1)
22
+ connection_pool (>= 2.2.5)
23
+ drb
24
+ i18n (>= 1.6, < 2)
25
+ json
26
+ logger (>= 1.4.2)
27
+ minitest (>= 5.1)
28
+ securerandom (>= 0.3)
29
+ tzinfo (~> 2.0, >= 2.0.5)
30
+ uri (>= 0.13.1)
31
+ ast (2.4.3)
32
+ base64 (0.3.0)
33
+ bigdecimal (3.3.1)
34
+ concurrent-ruby (1.3.5)
35
+ connection_pool (2.5.5)
36
+ dotenv (3.1.8)
37
+ drb (2.2.3)
38
+ dry-core (1.1.0)
39
+ concurrent-ruby (~> 1.0)
40
+ logger
41
+ zeitwerk (~> 2.6)
42
+ dry-inflector (1.2.0)
43
+ dry-logic (1.6.0)
44
+ bigdecimal
45
+ concurrent-ruby (~> 1.0)
46
+ dry-core (~> 1.1)
47
+ zeitwerk (~> 2.6)
48
+ dry-struct (1.8.0)
49
+ dry-core (~> 1.1)
50
+ dry-types (~> 1.8, >= 1.8.2)
51
+ ice_nine (~> 0.11)
52
+ zeitwerk (~> 2.6)
53
+ dry-types (1.8.3)
54
+ bigdecimal (~> 3.0)
55
+ concurrent-ruby (~> 1.0)
56
+ dry-core (~> 1.0)
57
+ dry-inflector (~> 1.0)
58
+ dry-logic (~> 1.4)
59
+ zeitwerk (~> 2.6)
60
+ eventmachine (1.2.7)
61
+ faker (3.5.2)
62
+ i18n (>= 1.8.11, < 2)
63
+ faraday (2.14.0)
64
+ faraday-net_http (>= 2.0, < 3.5)
65
+ json
66
+ logger
67
+ faraday-net_http (3.4.2)
68
+ net-http (~> 0.5)
69
+ faraday-retry (2.3.2)
70
+ faraday (~> 2.0)
71
+ i18n (1.14.7)
72
+ concurrent-ruby (~> 1.0)
73
+ ice_nine (0.11.2)
74
+ json (2.16.0)
75
+ language_server-protocol (3.17.0.5)
76
+ lint_roller (1.1.0)
77
+ logger (1.7.0)
78
+ minitest (5.26.2)
79
+ net-http (0.8.0)
80
+ uri (>= 0.11.1)
81
+ oj (3.16.12)
82
+ bigdecimal (>= 3.0)
83
+ ostruct (>= 0.2)
84
+ ostruct (0.6.3)
85
+ parallel (1.27.0)
86
+ parser (3.3.10.0)
87
+ ast (~> 2.4.1)
88
+ racc
89
+ permessage_deflate (0.1.4)
90
+ prism (1.6.0)
91
+ racc (1.8.1)
92
+ rainbow (3.1.1)
93
+ rake (13.3.1)
94
+ regexp_parser (2.11.3)
95
+ rubocop (1.81.7)
96
+ json (~> 2.3)
97
+ language_server-protocol (~> 3.17.0.2)
98
+ lint_roller (~> 1.1.0)
99
+ parallel (~> 1.10)
100
+ parser (>= 3.3.0.2)
101
+ rainbow (>= 2.2.2, < 4.0)
102
+ regexp_parser (>= 2.9.3, < 3.0)
103
+ rubocop-ast (>= 1.47.1, < 2.0)
104
+ ruby-progressbar (~> 1.7)
105
+ unicode-display_width (>= 2.4.0, < 4.0)
106
+ rubocop-ast (1.48.0)
107
+ parser (>= 3.3.7.2)
108
+ prism (~> 1.4)
109
+ rubocop-performance (1.26.1)
110
+ lint_roller (~> 1.1)
111
+ rubocop (>= 1.75.0, < 2.0)
112
+ rubocop-ast (>= 1.47.1, < 2.0)
113
+ ruby-progressbar (1.13.0)
114
+ securerandom (0.4.1)
115
+ tzinfo (2.0.6)
116
+ concurrent-ruby (~> 1.0)
117
+ unicode-display_width (3.2.0)
118
+ unicode-emoji (~> 4.1)
119
+ unicode-emoji (4.1.0)
120
+ uri (1.1.1)
121
+ vcr (6.3.1)
122
+ base64
123
+ websocket-driver (0.8.0)
124
+ base64
125
+ websocket-extensions (>= 0.1.0)
126
+ websocket-extensions (0.1.5)
127
+ zeitwerk (2.7.3)
128
+
129
+ PLATFORMS
130
+ arm64-darwin-24
131
+ ruby
132
+
133
+ DEPENDENCIES
134
+ bundler (>= 2.3)
135
+ dotenv (>= 2.7)
136
+ faker (>= 2.11)
137
+ massiveclient!
138
+ minitest (>= 5.0)
139
+ rake (>= 13.0)
140
+ rubocop (>= 1.50)
141
+ rubocop-performance (>= 1.11)
142
+ vcr (>= 5.1)
143
+
144
+ CHECKSUMS
145
+ activesupport (8.1.1) sha256=5e92534e8d0c8b8b5e6b16789c69dbea65c1d7b752269f71a39422e9546cea67
146
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
147
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
148
+ bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218
149
+ concurrent-ruby (1.3.5) sha256=813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6
150
+ connection_pool (2.5.5) sha256=e54ff92855753df1fd7c59fa04a398833355f27dd14c074f8c83a05f72a716ad
151
+ dotenv (3.1.8) sha256=9e1176060ced581f8e6ce4384e91361817763a76e3c625c8bddc18b35bd392c3
152
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
153
+ dry-core (1.1.0) sha256=0903821a9707649a7da545a2cd88e20f3a663ab1c5288abd7f914fa7751ab195
154
+ dry-inflector (1.2.0) sha256=22f5d0b50fd57074ae57e2ca17e3b300e57564c218269dcf82ff3e42d3f38f2e
155
+ dry-logic (1.6.0) sha256=da6fedbc0f90fc41f9b0cc7e6f05f5d529d1efaef6c8dcc8e0733f685745cea2
156
+ dry-struct (1.8.0) sha256=74c38b559924fb6462ac43ec780c4533a082d7b1d238a8d7857b773b3b8e2966
157
+ dry-types (1.8.3) sha256=b5d97a45e0ed273131c0c3d5bc9f5633c2d1242e092ee47401ce7d5eab65c1bc
158
+ eventmachine (1.2.7) sha256=994016e42aa041477ba9cff45cbe50de2047f25dd418eba003e84f0d16560972
159
+ faker (3.5.2) sha256=f9a80291b2e3f259801d1dd552f0732fe04dce5d1f74e798365bc0413789c473
160
+ faraday (2.14.0) sha256=8699cfe5d97e55268f2596f9a9d5a43736808a943714e3d9a53e6110593941cd
161
+ faraday-net_http (3.4.2) sha256=f147758260d3526939bf57ecf911682f94926a3666502e24c69992765875906c
162
+ faraday-retry (2.3.2) sha256=2402d2029032ebd238a2046221e67f6ef0da78c5a8ce8cd4f8b9c62e4d6451d1
163
+ i18n (1.14.7) sha256=ceba573f8138ff2c0915427f1fc5bdf4aa3ab8ae88c8ce255eb3ecf0a11a5d0f
164
+ ice_nine (0.11.2) sha256=5d506a7d2723d5592dc121b9928e4931742730131f22a1a37649df1c1e2e63db
165
+ json (2.16.0) sha256=ca5630320bb5ca23ebfd0bac84532fab56eb357575653b815b9df42c051e1525
166
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
167
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
168
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
169
+ massiveclient (0.3.0)
170
+ minitest (5.26.2) sha256=f021118a6185b9ba9f5af71f2ba103ad770c75afde9f2ab8da512677c550cde3
171
+ net-http (0.8.0) sha256=df42c47ce9f9e95ad32a317c97c12f945bc1af365288837ea4ff259876ecb46d
172
+ oj (3.16.12) sha256=ad9fad6a06dabcf4cfe6a420690a4375377685c16eee0ae88e8d38a43ed7b556
173
+ ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
174
+ parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
175
+ parser (3.3.10.0) sha256=ce3587fa5cc55a88c4ba5b2b37621b3329aadf5728f9eafa36bbd121462aabd6
176
+ permessage_deflate (0.1.4) sha256=c3f05a94f98994aa1a47589b0f33e94d86fc10c944efa0f6ab3666e37e343373
177
+ prism (1.6.0) sha256=bfc0281a81718c4872346bc858dc84abd3a60cae78336c65ad35c8fbff641c6b
178
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
179
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
180
+ rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
181
+ regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
182
+ rubocop (1.81.7) sha256=6fb5cc298c731691e2a414fe0041a13eb1beed7bab23aec131da1bcc527af094
183
+ rubocop-ast (1.48.0) sha256=22df9bbf3f7a6eccde0fad54e68547ae1e2a704bf8719e7c83813a99c05d2e76
184
+ rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
185
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
186
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
187
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
188
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
189
+ unicode-emoji (4.1.0) sha256=4997d2d5df1ed4252f4830a9b6e86f932e2013fbff2182a9ce9ccabda4f325a5
190
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
191
+ vcr (6.3.1) sha256=37b56e157e720446a3f4d2d39919cabef8cb7b6c45936acffd2ef8229fec03ed
192
+ websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962
193
+ websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241
194
+ zeitwerk (2.7.3) sha256=b2e86b4a9b57d26ba68a15230dcc7fe6f040f06831ce64417b0621ad96ba3e85
195
+
196
+ BUNDLED WITH
197
+ 4.0.0.beta2
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Massive (Ruby)
2
+
3
+ Ruby client library for Massive.com (formerly Polygon.io) - Real-time and historical market data for stocks, crypto, and forex.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Background](#background)
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [Ruby Support](#ruby-support)
11
+
12
+ ## Background
13
+
14
+ This is a client library for Massive.com's market data API. Please see [Massive.com](https://massive.com) for full API documentation.
15
+
16
+ ## Ruby Support
17
+
18
+ - Ruby 3.4+ supported
19
+ - Uses Faraday 2.x for HTTP requests
20
+ - ActiveSupport 7.x
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'massiveclient'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle install
33
+
34
+
35
+ ## Usage
36
+
37
+ **Create an instance of the client:**
38
+
39
+ All methods follow the documentation found at [Massive.com API Docs](https://massive.com/docs):
40
+
41
+
42
+
43
+ ```ruby
44
+ client = MassiveClient::Rest::Client.new(api_key)
45
+
46
+ # See tests for a full reference of all of methods
47
+ client.reference.tickers.list
48
+
49
+ client.stocks.list_exchanges
50
+
51
+ client.forex.historic_ticks
52
+
53
+ client.crypto.list # list exchanges
54
+
55
+ MassiveClient::Websocket::Client.new("crypto", api_key).subscribe("XQ.BTC-USD") do |event|
56
+ pp "Incoming message"
57
+ pp event
58
+ end
59
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "polygonio"
5
+ require "dotenv/load"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,199 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MassiveClient
4
+ module Rest
5
+ class Crypto < PolygonRestHandler
6
+ class CryptoExchange < PolygonResponse
7
+ attribute :id, Types::Integer
8
+ attribute :market, Types::String
9
+ attribute :name, Types::String
10
+ attribute :url, Types::String
11
+ attribute? :tier, Types::String
12
+ attribute? :locale, Types::String
13
+ end
14
+
15
+ def list
16
+ res = client.request.get("/v1/meta/crypto-exchanges")
17
+ Types::Array.of(CryptoExchange)[res.body]
18
+ end
19
+
20
+ class LastTradeResponse < PolygonResponse
21
+ attribute :status, Types::String
22
+ attribute :symbol, Types::String
23
+ attribute :last do
24
+ attribute :price, Types::JSON::Decimal
25
+ attribute :size, Types::JSON::Decimal
26
+ attribute :exchange, Types::Integer
27
+ attribute :conditions, Types::Array.of(Types::Integer)
28
+ attribute :timestamp, Types::Integer
29
+ end
30
+ attribute :last_average do
31
+ attribute :avg, Types::JSON::Decimal
32
+ attribute :trades_averaged, Types::Integer
33
+ end
34
+ end
35
+
36
+ def last_trade(from, to)
37
+ from = Types::String[from]
38
+ to = Types::String[to]
39
+
40
+ res = client.request.get("/v1/last/crypto/#{from}/#{to}")
41
+ LastTradeResponse[res.body]
42
+ end
43
+
44
+ class DailyOpenCloseResponse < PolygonResponse
45
+ attribute :symbol, Types::String
46
+ attribute :is_utc, Types::Bool
47
+ attribute :day, Types::JSON::Date
48
+ attribute :open, Types::JSON::Decimal
49
+ attribute :close, Types::JSON::Decimal
50
+ attribute :open_trades, Types::Array do
51
+ attribute? :p, Types::JSON::Decimal
52
+ attribute? :s, Types::JSON::Decimal
53
+ attribute? :x, Types::Integer
54
+ attribute? :c, Types::Array.of(Types::Integer)
55
+ attribute? :t, Types::Integer
56
+ end
57
+ attribute :closing_trades, Types::Array do
58
+ attribute? :p, Types::JSON::Decimal
59
+ attribute? :s, Types::JSON::Decimal
60
+ attribute? :x, Types::Integer
61
+ attribute? :c, Types::Array.of(Types::Integer)
62
+ attribute? :t, Types::Integer
63
+ end
64
+ end
65
+
66
+ def daily_open_close(from, to, date)
67
+ from = Types::String[from]
68
+ to = Types::String[to]
69
+ date = Types::JSON::Date[date]
70
+
71
+ res = client.request.get("/v1/open-close/crypto/#{from}/#{to}/#{date}")
72
+ DailyOpenCloseResponse[res.body]
73
+ end
74
+
75
+ class HistoricTradesResponse < PolygonResponse
76
+ attribute? :day, Types::JSON::Date
77
+ attribute? :map, Types::Hash
78
+ attribute? :ms_latency, Types::Integer
79
+ attribute? :status, Types::String
80
+ attribute? :symbol, Types::String
81
+ attribute? :type, Types::String
82
+ attribute :ticks, Types::Array do
83
+ attribute? :p, Types::JSON::Decimal
84
+ attribute? :s, Types::JSON::Decimal
85
+ attribute? :x, Types::Integer
86
+ attribute? :c, Types::Array.of(Types::Integer)
87
+ attribute? :t, Types::Integer
88
+ end
89
+ end
90
+
91
+ def historic_trades(from, to, date, opts = {})
92
+ from = Types::String[from]
93
+ to = Types::String[to]
94
+ date = Types::JSON::Date[date]
95
+ opts = PagingParameters[opts]
96
+
97
+ res = client.request.get("/v1/historic/crypto/#{from}/#{to}/#{date}", opts.to_h)
98
+ HistoricTradesResponse[res.body]
99
+ end
100
+
101
+ class SnapshotTicker < PolygonResponse
102
+ attribute :ticker, Types::String
103
+ attribute :day do
104
+ attribute :c, Types::JSON::Decimal
105
+ attribute :h, Types::JSON::Decimal
106
+ attribute :l, Types::JSON::Decimal
107
+ attribute :o, Types::JSON::Decimal
108
+ attribute :v, Types::JSON::Decimal
109
+ end
110
+ attribute :last_trade do
111
+ attribute :p, Types::JSON::Decimal
112
+ attribute :s, Types::JSON::Decimal
113
+ attribute :x, Types::Integer
114
+ attribute :c, Types::Array.of(Types::Integer)
115
+ attribute :t, Types::Integer
116
+ end
117
+ attribute :min do
118
+ attribute :c, Types::JSON::Decimal
119
+ attribute :h, Types::JSON::Decimal
120
+ attribute :l, Types::JSON::Decimal
121
+ attribute :o, Types::JSON::Decimal
122
+ attribute :v, Types::JSON::Decimal
123
+ end
124
+ attribute :prev_day do
125
+ attribute :c, Types::JSON::Decimal
126
+ attribute :h, Types::JSON::Decimal
127
+ attribute :l, Types::JSON::Decimal
128
+ attribute :o, Types::JSON::Decimal
129
+ attribute :v, Types::JSON::Decimal
130
+ end
131
+ attribute :todays_change, Types::JSON::Decimal
132
+ attribute :todays_change_perc, Types::JSON::Decimal
133
+ attribute :updated, Types::Integer
134
+ end
135
+
136
+ class FullSnapshotResponse < PolygonResponse
137
+ attribute :status, Types::String
138
+ attribute :tickers, Types::Array.of(SnapshotTicker)
139
+ end
140
+
141
+ def full_snapshot
142
+ res = client.request.get("/v2/snapshot/locale/global/markets/crypto/tickers")
143
+ FullSnapshotResponse[res.body]
144
+ end
145
+
146
+ class SnapshotResponse < PolygonResponse
147
+ attribute :status, Types::String
148
+ attribute :ticker, SnapshotTicker
149
+ end
150
+
151
+ def snapshot(ticker)
152
+ ticker = Types::String[ticker]
153
+ res = client.request.get("/v2/snapshot/locale/global/markets/crypto/tickers/#{ticker}")
154
+ SnapshotResponse[res.body]
155
+ end
156
+
157
+ class SnapshotBookResponse < PolygonResponse
158
+ attribute :status, Types::String
159
+ attribute :data do
160
+ attribute :ticker, Types::String
161
+ attribute :bids, Types::Array do
162
+ attribute :p, Types::JSON::Decimal
163
+ attribute :x do
164
+ PolygonResponse::NUMBERS_TO_WORDS.each do |_n, w|
165
+ attribute? w.to_sym, Types::JSON::Decimal
166
+ end
167
+ end
168
+ end
169
+ attribute :asks, Types::Array do
170
+ attribute :p, Types::JSON::Decimal
171
+ attribute :x do
172
+ PolygonResponse::NUMBERS_TO_WORDS.each do |_n, w|
173
+ attribute? w.to_sym, Types::JSON::Decimal
174
+ end
175
+ end
176
+ end
177
+ attribute :bid_count, Types::JSON::Decimal
178
+ attribute :ask_count, Types::JSON::Decimal
179
+ attribute :spread, Types::JSON::Decimal
180
+ attribute :updated, Types::Integer
181
+ end
182
+ end
183
+
184
+ def snapshot_book(ticker)
185
+ ticker = Types::String[ticker]
186
+ res = client.request.get("/v2/snapshot/locale/global/markets/crypto/tickers/#{ticker}/book")
187
+ SnapshotBookResponse[res.body]
188
+ end
189
+
190
+ class SnapshotGainersLosersResponse < FullSnapshotResponse; end
191
+
192
+ def snapshot_gainers_losers(direction)
193
+ direction = Types::Coercible::String.enum("gainers", "losers")[direction]
194
+ res = client.request.get("/v2/snapshot/locale/global/markets/crypto/#{direction}")
195
+ SnapshotGainersLosersResponse[res.body]
196
+ end
197
+ end
198
+ end
199
+ end