-
Notifications
You must be signed in to change notification settings - Fork 15
#87 Add bulk cash-flow-statement-growth endpoint #127
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
Closed
lukinoo0
wants to merge
9
commits into
marketdataapi:master
from
lukinoo0:cash-flow-statement-growth-bulk
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7b917de
Add bulk cash-flow-statement-growth endpoint (Closes #87)
b803d4b
Merge branch 'sorndotdev:master' into master
lukinoo0 f8a4f9e
syncing with main
e4e9464
Merge remote-tracking branch 'upstream/master' into cash-flow-stateme…
c6b874f
syncing with main
73413d6
Merge branch 'sorndotdev:master' into master
lukinoo0 f06d8cf
#87 added normalization of param in FmpService
95cb21f
Merge remote-tracking branch 'origin/master' into cash-flow-statement…
e30cf52
#87 resolved conflicts
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
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,23 @@ | ||
| package dev.sorn.fmp4j.clients; | ||
|
|
||
| import dev.sorn.fmp4j.cfg.FmpConfig; | ||
| import dev.sorn.fmp4j.http.FmpHttpClient; | ||
| import dev.sorn.fmp4j.models.FmpCashFlowStatementGrowth; | ||
| import dev.sorn.fmp4j.services.FmpCashFlowStatementGrowthBulkService; | ||
| import dev.sorn.fmp4j.services.FmpService; | ||
| import dev.sorn.fmp4j.types.FmpPeriod; | ||
| import dev.sorn.fmp4j.types.FmpYear; | ||
|
|
||
| public class FmpBulkClient { | ||
| private final FmpService<FmpCashFlowStatementGrowth[]> cashFlowStatementGrowthService; | ||
|
|
||
| public FmpBulkClient(FmpConfig fmpConfig, FmpHttpClient fmpHttpClient) { | ||
| this.cashFlowStatementGrowthService = new FmpCashFlowStatementGrowthBulkService(fmpConfig, fmpHttpClient); | ||
| } | ||
|
|
||
| public synchronized FmpCashFlowStatementGrowth[] cashFlowStatementGrowth(FmpYear year, FmpPeriod period) { | ||
| cashFlowStatementGrowthService.param("year", year); | ||
| cashFlowStatementGrowthService.param("period", period); | ||
| return cashFlowStatementGrowthService.download(); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/main/java/dev/sorn/fmp4j/services/FmpCashFlowStatementGrowthBulkService.java
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,29 @@ | ||
| package dev.sorn.fmp4j.services; | ||
|
|
||
| import static dev.sorn.fmp4j.json.FmpJsonUtils.typeRef; | ||
|
|
||
| import dev.sorn.fmp4j.cfg.FmpConfig; | ||
| import dev.sorn.fmp4j.http.FmpHttpClient; | ||
| import dev.sorn.fmp4j.models.FmpCashFlowStatementGrowth; | ||
| import java.util.Set; | ||
|
|
||
| public class FmpCashFlowStatementGrowthBulkService extends FmpService<FmpCashFlowStatementGrowth[]> { | ||
| public FmpCashFlowStatementGrowthBulkService(FmpConfig cfg, FmpHttpClient http) { | ||
| super(cfg, http, typeRef(FmpCashFlowStatementGrowth[].class)); | ||
| } | ||
|
|
||
| @Override | ||
| protected String relativeUrl() { | ||
| return "/v4/cash-flow-statement-growth-bulk"; | ||
| } | ||
|
|
||
| @Override | ||
| protected Set<String> requiredParams() { | ||
| return Set.of("year", "period"); | ||
| } | ||
|
|
||
| @Override | ||
| protected Set<String> optionalParams() { | ||
| return Set.of(); | ||
| } | ||
| } | ||
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
72 changes: 72 additions & 0 deletions
72
src/test/java/dev/sorn/fmp4j/services/FmpCashFlowStatementGrowthBulkServiceTest.java
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,72 @@ | ||
| package dev.sorn.fmp4j.services; | ||
|
|
||
| import static dev.sorn.fmp4j.HttpClientStub.httpClientStub; | ||
| import static dev.sorn.fmp4j.TestUtils.assertAllFieldsNonNull; | ||
| import static dev.sorn.fmp4j.TestUtils.jsonTestResource; | ||
| import static dev.sorn.fmp4j.json.FmpJsonDeserializerImpl.FMP_JSON_DESERIALIZER; | ||
| import static dev.sorn.fmp4j.types.FmpPeriod.period; | ||
| import static dev.sorn.fmp4j.types.FmpYear.year; | ||
| import static java.util.stream.IntStream.range; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import dev.sorn.fmp4j.HttpClientStub; | ||
| import dev.sorn.fmp4j.cfg.FmpConfigImpl; | ||
| import dev.sorn.fmp4j.http.FmpHttpClient; | ||
| import dev.sorn.fmp4j.http.FmpHttpClientImpl; | ||
| import dev.sorn.fmp4j.models.FmpCashFlowStatementGrowth; | ||
| import java.util.Set; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class FmpCashFlowStatementGrowthBulkServiceTest { | ||
| private final HttpClientStub httpStub = httpClientStub(); | ||
| private final FmpHttpClient http = new FmpHttpClientImpl(httpStub, FMP_JSON_DESERIALIZER); | ||
| private final FmpService<FmpCashFlowStatementGrowth[]> service = | ||
| new FmpCashFlowStatementGrowthBulkService(new FmpConfigImpl(), http); | ||
|
|
||
| @Test | ||
| void relative_url() { | ||
| // when | ||
| var relativeUrl = service.relativeUrl(); | ||
|
|
||
| // then | ||
| assertEquals("/v4/cash-flow-statement-growth-bulk", relativeUrl); | ||
| } | ||
|
|
||
| @Test | ||
| void required_params() { | ||
| // when | ||
| var params = service.requiredParams(); | ||
|
|
||
| // then | ||
| assertEquals(Set.of("year", "period"), params); | ||
| } | ||
|
|
||
| @Test | ||
| void optional_params() { | ||
| // when | ||
| var params = service.optionalParams(); | ||
|
|
||
| // then | ||
| assertEquals(Set.of(), params); | ||
| } | ||
|
|
||
| @Test | ||
| void successful_download() { | ||
| // given | ||
| var year = year("2025"); | ||
| var period = period("quarter"); | ||
| service.param("year", year); | ||
| service.param("period", period); | ||
| httpStub.configureResponse() | ||
| .body(jsonTestResource("stable/cash-flow-statement-growth-bulk/?year=%s&period=%s.json", year, period)) | ||
| .statusCode(200) | ||
| .apply(); | ||
|
|
||
| // when | ||
| var result = service.download(); | ||
|
|
||
| // then | ||
| assertEquals(2, result.length); | ||
| range(0, result.length).forEach(i -> assertAllFieldsNonNull(result[i])); | ||
| } | ||
| } |
90 changes: 90 additions & 0 deletions
90
...ixtures/resources/stable/cash-flow-statement-growth-bulk/%3Fyear=2025&period=quarter.json
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,90 @@ | ||
| [ | ||
| { | ||
| "symbol": "AAPL", | ||
| "date": "2025-06-28", | ||
| "fiscalYear": "2025", | ||
| "period": "Q3", | ||
| "reportedCurrency": "USD", | ||
| "growthNetIncome": -0.054317998385795, | ||
| "growthDepreciationAndAmortization": 0.06350995866215708, | ||
| "growthDeferredIncomeTax": 0, | ||
| "growthStockBasedCompensation": -0.017978921264724116, | ||
| "growthChangeInWorkingCapital": 3.652374366067312, | ||
| "growthAccountsReceivables": -2.1114327062228653, | ||
| "growthInventory": -0.432348367029549, | ||
| "growthAccountsPayables": 0.5115340980713475, | ||
| "growthOtherWorkingCapital": 4.545270498256664, | ||
| "growthOtherNonCashItems": -89.5, | ||
| "growthNetCashProvidedByOperatingActivites": 0.16345190380761523, | ||
| "growthInvestmentsInPropertyPlantAndEquipment": -0.12732009117551285, | ||
| "growthAcquisitionsNet": 0, | ||
| "growthPurchasesOfInvestments": 0.18502690724912946, | ||
| "growthSalesMaturitiesOfInvestments": 0.13665099692008428, | ||
| "growthOtherInvestingActivites": -9.625, | ||
| "growthNetCashUsedForInvestingActivites": 0.7391155296537538, | ||
| "growthDebtRepayment": -1.9816398390342052, | ||
| "growthCommonStockIssued": 0, | ||
| "growthCommonStockRepurchased": 0.186230596957294, | ||
| "growthDividendsPaid": -0.04976051091005854, | ||
| "growthOtherFinancingActivites": 7.0030674846625764, | ||
| "growthNetCashUsedProvidedByFinancingActivities": 0.1438667861821692, | ||
| "growthEffectOfForexChangesOnCash": 0, | ||
| "growthNetChangeInCash": 4.793635938231165, | ||
| "growthCashAtEndOfPeriod": 0.287870179674739, | ||
| "growthCashAtBeginningOfPeriod": -0.0705303805406119, | ||
| "growthOperatingCashFlow": 0.16345190380761523, | ||
| "growthCapitalExpenditure": -0.12732009117551285, | ||
| "growthFreeCashFlow": 0.1687658637038456, | ||
| "growthNetDebtIssuance": -2.8135245901639343, | ||
| "growthLongTermNetDebtIssuance": -0.891, | ||
| "growthShortTermNetDebtIssuance": -0.018360160965794767, | ||
| "growthNetStockIssuance": 0.186230596957294, | ||
| "growthPreferredDividendsPaid": -0.04976051091005854, | ||
| "growthIncomeTaxesPaid": -0.5665285451197053, | ||
| "growthInterestPaid": 0 | ||
| }, | ||
| { | ||
| "symbol": "AAPL", | ||
| "date": "2025-03-29", | ||
| "fiscalYear": "2025", | ||
| "period": "Q2", | ||
| "reportedCurrency": "USD", | ||
| "growthNetIncome": -0.3179190751445087, | ||
| "growthDepreciationAndAmortization": -0.13603896103896104, | ||
| "growthDeferredIncomeTax": 0, | ||
| "growthStockBasedCompensation": -0.018259281801582473, | ||
| "growthChangeInWorkingCapital": 0.39481026785714285, | ||
| "growthAccountsReceivables": 0.4304302824190448, | ||
| "growthInventory": 1.9906976744186047, | ||
| "growthAccountsPayables": -0.18917703492729726, | ||
| "growthOtherWorkingCapital": 0.1960394249027941, | ||
| "growthOtherNonCashItems": 0.8964659034345446, | ||
| "growthNetCashProvidedByOperatingActivites": -0.19986637715049274, | ||
| "growthInvestmentsInPropertyPlantAndEquipment": -0.0445578231292517, | ||
| "growthAcquisitionsNet": 0, | ||
| "growthPurchasesOfInvestments": -0.03167864141084259, | ||
| "growthSalesMaturitiesOfInvestments": -0.3659489182383473, | ||
| "growthOtherInvestingActivites": 0.9469320066334992, | ||
| "growthNetCashUsedForInvestingActivites": -0.7021037581699346, | ||
| "growthDebtRepayment": 0.499496475327291, | ||
| "growthCommonStockIssued": 0, | ||
| "growthCommonStockRepurchased": -0.09709395916292468, | ||
| "growthDividendsPaid": 0.0254149377593361, | ||
| "growthOtherFinancingActivites": 0.8897158322056834, | ||
| "growthNetCashUsedProvidedByFinancingActivities": 0.2632648396027533, | ||
| "growthEffectOfForexChangesOnCash": 0, | ||
| "growthNetChangeInCash": -7.002808988764045, | ||
| "growthCashAtEndOfPeriod": -0.0705303805406119, | ||
| "growthCashAtBeginningOfPeriod": 0.011889256253548409, | ||
| "growthOperatingCashFlow": -0.19986637715049274, | ||
| "growthCapitalExpenditure": -0.0445578231292517, | ||
| "growthFreeCashFlow": -0.06145749353918026, | ||
| "growthNetDebtIssuance": -0.5714828897338403, | ||
| "growthLongTermNetDebtIssuance": 0.499496475327291, | ||
| "growthShortTermNetDebtIssuance": -0.04017094017094017, | ||
| "growthNetStockIssuance": -0.09709395916292468, | ||
| "growthPreferredDividendsPaid": 0.0254149377593361, | ||
| "growthIncomeTaxesPaid": 0.34269662921348315, | ||
| "growthInterestPaid": -0.30952380952380953 | ||
| } | ||
| ] |
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.
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.
fmp4j only works with
/stable/, not/vX/Docs for stable (note: it returns CSV, not JSON).
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.
Okay, will be fixed soon.