-
Notifications
You must be signed in to change notification settings - Fork 20
Add fundamental data support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tylerhaugen-stanley
wants to merge
8
commits into
StefanoMartin:master
Choose a base branch
from
tylerhaugen-stanley:add_fundamental_data_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4233e13
Add support for the fundamental api
tylerhaugen-stanley-amount daf3413
Add gemfile.lock
tylerhaugen-stanley-amount 249326a
Add specs and a few other ways to intantiate a Fundamental_Data objec…
tylerhaugen-stanley-amount 85cb114
Revert and add fundamental data to core gem file
tylerhaugen-stanley-amount 0a96a58
Clean up specs
tylerhaugen-stanley-amount ff5e4b9
Add constants for endpoints and small code cleanup based on code review
tylerhaugen-stanley-amount 53f3b91
Update readme
tylerhaugen-stanley-amount bebdcb8
Add argument checking
tylerhaugen-stanley-amount File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| spec/config.yml | ||
| *.lock | ||
| *.gem | ||
| .idea | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| GEM | ||
| remote: https://rubygems.org/ | ||
| specs: | ||
| awesome_print (1.8.0) | ||
| byebug (11.1.3) | ||
| coderay (1.1.3) | ||
| diff-lcs (1.4.4) | ||
| httparty (0.18.1) | ||
| mime-types (~> 3.0) | ||
| multi_xml (>= 0.5.2) | ||
| humanize (2.4.3) | ||
| method_source (1.0.0) | ||
| mime-types (3.3.1) | ||
| mime-types-data (~> 3.2015) | ||
| mime-types-data (3.2020.0512) | ||
| multi_xml (0.6.0) | ||
| pry (0.13.1) | ||
| coderay (~> 1.1) | ||
| method_source (~> 1.0) | ||
| pry-byebug (3.9.0) | ||
| byebug (~> 11.0) | ||
| pry (~> 0.13.0) | ||
| rspec (3.9.0) | ||
| rspec-core (~> 3.9.0) | ||
| rspec-expectations (~> 3.9.0) | ||
| rspec-mocks (~> 3.9.0) | ||
| rspec-core (3.9.2) | ||
| rspec-support (~> 3.9.3) | ||
| rspec-expectations (3.9.2) | ||
| diff-lcs (>= 1.2.0, < 2.0) | ||
| rspec-support (~> 3.9.0) | ||
| rspec-mocks (3.9.1) | ||
| diff-lcs (>= 1.2.0, < 2.0) | ||
| rspec-support (~> 3.9.0) | ||
| rspec-support (3.9.3) | ||
|
|
||
| PLATFORMS | ||
| ruby | ||
|
|
||
| DEPENDENCIES | ||
| awesome_print (>= 1.7) | ||
| httparty (>= 0.17.0) | ||
| humanize (>= 1.7.0) | ||
| pry-byebug | ||
| rspec (>= 3.5) | ||
|
|
||
| BUNDLED WITH | ||
| 2.1.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| class Endpoints | ||
| OVERVIEW = "OVERVIEW" | ||
| BALANCE_SHEET = "BALANCE_SHEET" | ||
| INCOME_STATEMENT = "INCOME_STATEMENT" | ||
| CASH_FLOW = "CASH_FLOW" | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| module Alphavantage | ||
| class Fundamental_Data | ||
| include HelperFunctions | ||
|
|
||
| def initialize(symbol:, datatype: "json", key:, verbose: false) | ||
| check_argument([true, false], verbose, "verbose") | ||
| @client = return_client(key, verbose) | ||
|
tylerhaugen-stanley marked this conversation as resolved.
|
||
| @symbol = symbol | ||
| @datatype = datatype | ||
| end | ||
|
|
||
| def overview(file: nil, datatype: @datatype) | ||
| check_argument(["json", "csv"], datatype, "datatype") | ||
| make_request(file: file, datatype: datatype, endpoint: Endpoints::OVERVIEW) | ||
| end | ||
|
|
||
| def income_statements(file: nil, datatype: @datatype, period: :both) | ||
| check_argument([:both, :quarterly, :annually], period, "period") | ||
| payload = make_request(file: file, datatype: datatype, endpoint: Endpoints::INCOME_STATEMENT) | ||
|
|
||
| extract_period_data(payload, period) | ||
| end | ||
|
|
||
| def balance_sheets(file: nil, datatype: @datatype, period: :both) | ||
| check_argument([:both, :quarterly, :annually], period, "period") | ||
| payload = make_request(file: file, datatype: datatype, endpoint: Endpoints::BALANCE_SHEET) | ||
|
|
||
| extract_period_data(payload, period) | ||
| end | ||
|
|
||
| def cash_flow_statements(file: nil, datatype: @datatype, period: :both) | ||
| check_argument([:both, :quarterly, :annually], period, "period") | ||
| payload = make_request(file: file, datatype: datatype, endpoint: Endpoints::CASH_FLOW) | ||
|
|
||
| extract_period_data(payload, period) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def make_request(file: nil, datatype: @datatype, endpoint:) | ||
| check_datatype(datatype, file) | ||
| url = "function=#{endpoint}&symbol=#{@symbol}" | ||
| return @client.download(url, file) if datatype == "csv" | ||
| @client.request(url) | ||
| end | ||
|
|
||
| def extract_period_data(payload, period) | ||
| return quarterly(payload) if period == :quarterly | ||
| return annually(payload) if period == :annually | ||
| payload # Return both periods in one hash | ||
| end | ||
|
|
||
| def quarterly(payload) | ||
| payload['quarterlyReports'] | ||
| end | ||
|
|
||
| def annually(payload) | ||
| payload['annualReports'] | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Why?
edit: in description, my bad