marketstack_wrapper 0.1.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: e4695a4460aa4fe3aa1ef8c51e63ce61641f9e237507a3cc38270d8e4108bb69
4
+ data.tar.gz: c95c6a5f6283494eda26cd2b59f5df68efa8ef8832780a0368ad9903cdba26f3
5
+ SHA512:
6
+ metadata.gz: 5910a5ba54261ac1c910a170523e0e4e9f1acd0e23d0655293e0ced158bd4a84b7f91d818e842f08d87309d4183e1c733f1c1d619030dca58955b91146538b3f
7
+ data.tar.gz: 528244bdbe3b2b819714de1ce0c05ce9fe0ac4b6c65a9c64b69d69cf315fdf281161e9f0a53beee1b02d87953aa5c622dbd3d10460b94281cbad049555cf1d69
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-12-01
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Nicolas Tonnelier
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ MarketStack Wrapper
2
+ ===================
3
+
4
+ **marketstack\_wrapper** is a Ruby gem that provides a simple interface for accessing the [MarketStack API](https://marketstack.com/documentation). The API offers stock market data including tickers, historical data, intraday data, and more.
5
+
6
+ Features
7
+ --------
8
+
9
+ * Fetch all available tickers
10
+
11
+ * Retrieve data for a specific ticker
12
+
13
+ * Access end-of-day (EOD) or intraday stock prices
14
+
15
+ * Fetch historical data for single or multiple tickers
16
+
17
+ * Pagination support for large datasets
18
+
19
+
20
+ Installation
21
+ ------------
22
+
23
+ Add the gem to your Gemfile:
24
+
25
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` gem 'marketstack_wrapper' `
26
+
27
+ Then, run:
28
+
29
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` bundle install `
30
+
31
+ Alternatively, install it directly:
32
+
33
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` gem install marketstack_wrapper `
34
+
35
+ Configuration
36
+ -------------
37
+
38
+ To use the gem, you need an API key from [MarketStack](https://marketstack.com). Sign up for a free or paid plan to get your access\_key.
39
+
40
+ Usage
41
+ -----
42
+
43
+ Here’s how you can use the gem to interact with the MarketStack API:
44
+
45
+ ### Initialization
46
+
47
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` require 'marketstack_wrapper' # Initialize the client with your API key client = MarketstackWrapper::Client.new('your_access_key') `
48
+
49
+ ### Fetch All Tickers
50
+
51
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` tickers = client.get_all_tickers(limit: 10, offset: 0) puts tickers `
52
+
53
+ ### Get Data for a Specific Ticker
54
+
55
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` ticker = client.get_ticker('AAPL') puts ticker `
56
+
57
+ ### Fetch End-of-Day (EOD) Data for a Ticker
58
+
59
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` eod_data = client.get_ticker_eod('AAPL', limit: 5) puts eod_data `
60
+
61
+ ### Fetch Intraday Data for a Ticker
62
+
63
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` intraday_data = client.get_ticker_intraday('AAPL', limit: 5) puts intraday_data `
64
+
65
+ ### Fetch Latest Intraday Data for a Ticker
66
+
67
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` latest_intraday = client.get_ticker_latest_intraday('AAPL') puts latest_intraday `
68
+
69
+ ### Fetch Latest End-of-Day Data for a Ticker
70
+
71
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` latest_eod = client.get_ticker_latest_eod('AAPL') puts latest_eod `
72
+
73
+ ### Fetch Historical Data for a Ticker
74
+
75
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` historical_data = client.get_historical_data( symbol: 'AAPL', date_from: '2023-01-01', date_to: '2023-02-01', limit: 10 ) puts historical_data `
76
+
77
+ ### Fetch Historical Data for Multiple Tickers
78
+
79
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` multi_historical = client.get_multiple_historical_data( symbols: ['AAPL', 'GOOG', 'MSFT'], date_from: '2023-01-01', date_to: '2023-02-01', limit: 10 ) puts multi_historical `
80
+
81
+ Pagination
82
+ ----------
83
+
84
+ All endpoints support pagination with limit and offset parameters. Adjust these to retrieve more results when necessary.
85
+
86
+ Error Handling
87
+ --------------
88
+
89
+ The gem raises exceptions if the API response indicates an error (e.g., invalid API key, rate limit exceeded). Make sure to handle these exceptions in your code:
90
+
91
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` begin tickers = client.get_all_tickers rescue => e puts "An error occurred: #{e.message}" end `
92
+
93
+ Development
94
+ -----------
95
+
96
+ Contributions are welcome! To get started with development:
97
+
98
+ 1. Clone the repository
99
+
100
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` git clone https://github.com/yourusername/marketstack\_wrapper.gitcd marketstack\_wrapper`
101
+
102
+ 2. Install the dependencies
103
+
104
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` bundle install`
105
+
106
+ 3. Run tests
107
+
108
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` rspec`
109
+
110
+
111
+ Contributing
112
+ ------------
113
+
114
+ 1. Fork the repository.
115
+
116
+ 2. Create a new feature branch
117
+
118
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` git checkout -b my-feature-branch`
119
+
120
+ 3. Commit your changes:
121
+
122
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` git commit -m "Add my new feature"`
123
+
124
+ 4. Push to your branch:
125
+
126
+ Plain textANTLR4BashCC#CSSCoffeeScriptCMakeDartDjangoDockerEJSErlangGitGoGraphQLGroovyHTMLJavaJavaScriptJSONJSXKotlinLaTeXLessLuaMakefileMarkdownMATLABMarkupObjective-CPerlPHPPowerShell.propertiesProtocol BuffersPythonRRubySass (Sass)Sass (Scss)SchemeSQLShellSwiftSVGTSXTypeScriptWebAssemblyYAMLXML` git push origin my-feature-branch`
127
+
128
+ 5. Open a pull request on GitHub.
129
+
130
+
131
+ License
132
+ -------
133
+
134
+ This project is licensed under the MIT License. See the LICENSE file for details.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,96 @@
1
+ require "faraday"
2
+ require "json"
3
+
4
+ module MarketstackWrapper
5
+ class Client
6
+ BASE_URI = "http://api.marketstack.com/v1/"
7
+
8
+ # Initialize the client
9
+ # @param access_key [String] The API access key
10
+ def initialize(access_key)
11
+ @access_key = access_key
12
+ @connection = Faraday.new(url: BASE_URI)
13
+ end
14
+
15
+ # Fetch all tickers
16
+ # @param limit [Integer] The number of tickers to fetch
17
+ # @param offset [Integer] The offset to start fetching tickers
18
+ def get_all_tickers(limit: nil, offset: nil)
19
+ make_request("tickers", { limit: limit, offset: offset })
20
+ end
21
+
22
+ # Fetch a specific ticker
23
+ # @param symbol [String] The ticker symbol
24
+ def get_ticker(symbol)
25
+ make_request("tickers/#{symbol}")
26
+ end
27
+
28
+ # Fetch the end-of-day data for a specific ticker
29
+ # @param symbol [String] The ticker symbol
30
+ # @param limit [Integer] The number of data points to fetch
31
+ def get_ticker_eod(symbol, limit: nil, offset: nil)
32
+ make_request("tickers/#{symbol}/eod", { limit: limit, offset: offset })
33
+ end
34
+
35
+ # Fetch the intraday and real-time data for a specific ticker
36
+ # @param symbol [String] The ticker symbol
37
+ # @param limit [Integer] The number of data points to fetch
38
+ def get_ticker_intraday(symbol, limit: nil, offset: nil)
39
+ make_request("tickers/#{symbol}/intraday", { limit: limit, offset: offset })
40
+ end
41
+
42
+ # Fetch the latest intraday data for a specific ticker
43
+ # @param symbol [String] The ticker symbol
44
+ def get_ticker_latest_intraday(symbol)
45
+ make_request("tickers/#{symbol}/intraday/latest")
46
+ end
47
+
48
+ # Fetch the latest end-of-day data for a specific ticker
49
+ # @param symbol [String] The ticker symbol
50
+ def get_ticker_latest_eod(symbol)
51
+ make_request("tickers/#{symbol}/eod/latest")
52
+ end
53
+
54
+ # Fetch the historical data for a specific ticker
55
+ # @param symbol [String] The ticker symbol
56
+ # @param date_from [String] The start date for the historical data (YYYY-MM-DD)
57
+ # @param date_to [String] The end date for the historical data (YYYY-MM-DD)
58
+ # @param limit [Integer] The number of data points to fetch
59
+ # @param offset [Integer] The offset to start fetching data points
60
+ def get_historical_data(symbol:, date_from:, date_to:, limit: nil, offset: nil)
61
+ make_request(
62
+ "eod",
63
+ { symbol: symbol, date_from: date_from, date_to: date_to, limit: limit, offset: offset }
64
+ )
65
+ end
66
+
67
+ # Fetch the historical data for multiple tickers
68
+ # @param symbols [Array<String>] The ticker symbols
69
+ # @param date_from [String] The start date for the historical data (YYYY-MM-DD)
70
+ # @param date_to [String] The end date for the historical data (YYYY-MM-DD)
71
+ # @param limit [Integer] The number of data points to fetch
72
+ # @param offset [Integer] The offset to start fetching data points
73
+ def get_multiple_historical_data(symbols:, date_from:, date_to:, limit: nil, offset: nil)
74
+ make_request(
75
+ "eod",
76
+ { symbols: symbols.join(","), date_from: date_from, date_to: date_to, limit: limit, offset: offset }
77
+ )
78
+ end
79
+
80
+ private
81
+
82
+ def make_request(endpoint, params = {})
83
+ params[:access_key] = @access_key
84
+ response = @connection.get(endpoint, params)
85
+ parse_response(response)
86
+ end
87
+
88
+ def parse_response(response)
89
+ if response.success?
90
+ JSON.parse(response.body)
91
+ else
92
+ raise "Error: #{response.status} - #{response.body}"
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MarketstackWrapper
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "marketstack_wrapper/version"
4
+ require_relative "marketstack_wrapper/client"
5
+
6
+ module MarketstackWrapper
7
+ class Error < StandardError; end
8
+ end
@@ -0,0 +1,4 @@
1
+ module MarketstackWrapper
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marketstack_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nicolas Tonnelier
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ description: Wrapper for the main endpoints provided by the MarketStack API
42
+ email:
43
+ - na.tonnelier@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - CHANGELOG.md
50
+ - CODE_OF_CONDUCT.md
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/marketstack_wrapper.rb
55
+ - lib/marketstack_wrapper/client.rb
56
+ - lib/marketstack_wrapper/version.rb
57
+ - sig/marketstack_wrapper.rbs
58
+ homepage: https://github.com/natonnelier/marketstack_wrapper
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ allowed_push_host: https://rubygems.org
63
+ homepage_uri: https://github.com/natonnelier/marketstack_wrapper
64
+ source_code_uri: https://github.com/natonnelier/marketstack_wrapper
65
+ changelog_uri: https://github.com/natonnelier/marketstack_wrapper/blob/main/CHANGELOG.md
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 3.0.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.5.22
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Ruby Client for MarketStack API
85
+ test_files: []