kensho-kfinance 3.0.2__py3-none-any.whl → 3.0.3__py3-none-any.whl
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.
Potentially problematic release.
This version of kensho-kfinance might be problematic. Click here for more details.
- {kensho_kfinance-3.0.2.dist-info → kensho_kfinance-3.0.3.dist-info}/METADATA +1 -1
- {kensho_kfinance-3.0.2.dist-info → kensho_kfinance-3.0.3.dist-info}/RECORD +14 -14
- kfinance/CHANGELOG.md +4 -1
- kfinance/client/fetch.py +3 -2
- kfinance/client/meta_classes.py +10 -11
- kfinance/client/tests/test_fetch.py +15 -10
- kfinance/client/tests/test_objects.py +19 -10
- kfinance/domains/line_items/line_item_models.py +7 -0
- kfinance/domains/line_items/line_item_tools.py +12 -4
- kfinance/version.py +2 -2
- {kensho_kfinance-3.0.2.dist-info → kensho_kfinance-3.0.3.dist-info}/WHEEL +0 -0
- {kensho_kfinance-3.0.2.dist-info → kensho_kfinance-3.0.3.dist-info}/licenses/AUTHORS.md +0 -0
- {kensho_kfinance-3.0.2.dist-info → kensho_kfinance-3.0.3.dist-info}/licenses/LICENSE +0 -0
- {kensho_kfinance-3.0.2.dist-info → kensho_kfinance-3.0.3.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.3
|
|
4
4
|
Summary: Python CLI for kFinance
|
|
5
5
|
Author-email: Luke Brown <luke.brown@kensho.com>, Michelle Keoy <michelle.keoy@kensho.com>, Keith Page <keith.page@kensho.com>, Matthew Rosen <matthew.rosen@kensho.com>, Nick Roshdieh <nick.roshdieh@kensho.com>
|
|
6
6
|
Project-URL: source, https://github.com/kensho-technologies/kfinance
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
kensho_kfinance-3.0.
|
|
2
|
-
kensho_kfinance-3.0.
|
|
3
|
-
kfinance/CHANGELOG.md,sha256=
|
|
1
|
+
kensho_kfinance-3.0.3.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
|
|
2
|
+
kensho_kfinance-3.0.3.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
|
|
3
|
+
kfinance/CHANGELOG.md,sha256=NF3WF3p_EkEyIRyUij-KIJY23KeEK2MMu_1Lt6_iy-s,2519
|
|
4
4
|
kfinance/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
5
5
|
kfinance/conftest.py,sha256=JyBWZuJopwN9MuisFVS_U8jd9L-UU74d-ALUTa43J1Q,1599
|
|
6
6
|
kfinance/mcp.py,sha256=LTzCIlqsDKRD-0Xcpa_P99-JmJ8duAneO_-GzM43kjw,424
|
|
7
7
|
kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
kfinance/version.py,sha256=
|
|
8
|
+
kfinance/version.py,sha256=O6w_VzBqFS0kxgb4zZyd_f0eDILnwM3pkHDxNPPNEoE,511
|
|
9
9
|
kfinance/client/README.md,sha256=DA5vg4uz1JmJNiqvYywrj46YNhOr584WO8L83Ysx_Mk,372
|
|
10
10
|
kfinance/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
kfinance/client/batch_request_handling.py,sha256=opwJJAU2JtqH-s4vt8wRqhH34MiU4tQP6Ng7K6b3upA,6561
|
|
12
|
-
kfinance/client/fetch.py,sha256=
|
|
12
|
+
kfinance/client/fetch.py,sha256=zdVqMdfD3Gvsn_MSl-emN36hY5dbwbDkVjZTzqaHRSw,27975
|
|
13
13
|
kfinance/client/industry_models.py,sha256=ydB_cTIsNsfCUeaO7K2qqLUuHdG6WfUCoAzBigKVV8M,243
|
|
14
14
|
kfinance/client/kfinance.py,sha256=BwywHwYvw1PEO3wvecKaRQGYdHdIkM0yxAVdTEgRjLM,72693
|
|
15
|
-
kfinance/client/meta_classes.py,sha256=
|
|
15
|
+
kfinance/client/meta_classes.py,sha256=fqrU6U2XL6SJubJiZX5DIpi6wxSsSQEsc2vASLQTEq4,21394
|
|
16
16
|
kfinance/client/permission_models.py,sha256=G0so8ZOsD1YDsCM4he0z5R9M_shUbSRwD3hUDJdqZl0,635
|
|
17
17
|
kfinance/client/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdtLgA,2574
|
|
18
18
|
kfinance/client/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -24,9 +24,9 @@ kfinance/client/models/tests/test_decimal_with_unit.py,sha256=7WlmVXFOFNHFqwsvXQ
|
|
|
24
24
|
kfinance/client/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
kfinance/client/tests/test_batch_requests.py,sha256=KcE5rNJHBP27xaZOmwg8cVyUMZAAPt6jDiCeq94wUUk,11661
|
|
26
26
|
kfinance/client/tests/test_client.py,sha256=GlK89ZOGL9bwrAUFUk8nua2ooKt0JYm7o_rpAfajFXA,4312
|
|
27
|
-
kfinance/client/tests/test_fetch.py,sha256=
|
|
27
|
+
kfinance/client/tests/test_fetch.py,sha256=_32Rc79nYIwv48kWc-YLpXKF0xoAetmGcxMzR2t6Hao,18051
|
|
28
28
|
kfinance/client/tests/test_group_objects.py,sha256=wb7MEyGm-Qya3CXWM5Xz3kUhKFWdHT8FF3cQcjt1WxQ,1696
|
|
29
|
-
kfinance/client/tests/test_objects.py,sha256=
|
|
29
|
+
kfinance/client/tests/test_objects.py,sha256=3ShSI-lgsZJxRjNOZPGMxoZ8kHnaV_M2Jnaw6gVrzDc,43142
|
|
30
30
|
kfinance/domains/README.md,sha256=ehD15VwLupdXbz5M7hHUI7Y-2SCGxaP5W7Q4NuMcN64,664
|
|
31
31
|
kfinance/domains/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
32
|
kfinance/domains/business_relationships/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -61,8 +61,8 @@ kfinance/domains/earnings/earning_tools.py,sha256=2W-OzGljXpVmoiLUOwLDPBCAVybvIZ
|
|
|
61
61
|
kfinance/domains/earnings/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
62
62
|
kfinance/domains/earnings/tests/test_earnings_tools.py,sha256=nKoYTG2bh7-ySoYGx0EXN68GHjrq-ziW5KVyiTTQfKk,6668
|
|
63
63
|
kfinance/domains/line_items/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
64
|
-
kfinance/domains/line_items/line_item_models.py,sha256=
|
|
65
|
-
kfinance/domains/line_items/line_item_tools.py,sha256=
|
|
64
|
+
kfinance/domains/line_items/line_item_models.py,sha256=09JnV2RRxl-rSmZEVlKRfEwD-5-zYmvsUAIkmz9gFqc,45530
|
|
65
|
+
kfinance/domains/line_items/line_item_tools.py,sha256=f94XdsNRAev48-RPXpdy1a2OKfTaBWkjX33OQZEljVI,5051
|
|
66
66
|
kfinance/domains/line_items/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
67
67
|
kfinance/domains/line_items/tests/test_line_item_tools.py,sha256=aJxyDyW--1kyNVtjy2uGVou6NCTiVbypsFTsnvW-GVQ,3441
|
|
68
68
|
kfinance/domains/mergers_and_acquisitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -106,7 +106,7 @@ kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py
|
|
|
106
106
|
kfinance/integrations/tool_calling/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
107
107
|
kfinance/integrations/tool_calling/tests/test_tool_calling_models.py,sha256=PWNNHaF7mFDZXXfwf4o5Hdemvr8VWl71ODHddr0FMwA,2596
|
|
108
108
|
kfinance/models/permission_models.py,sha256=G0so8ZOsD1YDsCM4he0z5R9M_shUbSRwD3hUDJdqZl0,635
|
|
109
|
-
kensho_kfinance-3.0.
|
|
110
|
-
kensho_kfinance-3.0.
|
|
111
|
-
kensho_kfinance-3.0.
|
|
112
|
-
kensho_kfinance-3.0.
|
|
109
|
+
kensho_kfinance-3.0.3.dist-info/METADATA,sha256=3GOK0VNZzeKwUmMZ7-UtNx3S6vhKPi3y1NlkYDIje94,6202
|
|
110
|
+
kensho_kfinance-3.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
111
|
+
kensho_kfinance-3.0.3.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
|
|
112
|
+
kensho_kfinance-3.0.3.dist-info/RECORD,,
|
kfinance/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v3.0.3
|
|
4
|
+
- Add LineItemResponse model
|
|
5
|
+
|
|
3
6
|
## v3.0.2
|
|
4
7
|
- Add kfinance.mcp back to simplify transition to 3.0
|
|
5
8
|
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
- Add transcript permission and update accepted_permissions type to set[Permission]
|
|
26
29
|
|
|
27
30
|
## v2.6.3
|
|
28
|
-
- Bump urllib3 to 2.5 to
|
|
31
|
+
- Bump urllib3 to 2.5 to address CVEs
|
|
29
32
|
|
|
30
33
|
## v2.6.2
|
|
31
34
|
- Safely check for incomplete merger information
|
kfinance/client/fetch.py
CHANGED
|
@@ -20,6 +20,7 @@ from kfinance.domains.capitalizations.capitalization_models import Capitalizatio
|
|
|
20
20
|
from kfinance.domains.companies.company_models import IdentificationTriple
|
|
21
21
|
from kfinance.domains.competitors.competitor_models import CompetitorResponse, CompetitorSource
|
|
22
22
|
from kfinance.domains.earnings.earning_models import EarningsCallResp
|
|
23
|
+
from kfinance.domains.line_items.line_item_models import LineItemResponse
|
|
23
24
|
from kfinance.domains.prices.price_models import PriceHistory
|
|
24
25
|
from kfinance.domains.segments.segment_models import SegmentType
|
|
25
26
|
|
|
@@ -410,7 +411,7 @@ class KFinanceApiClient:
|
|
|
410
411
|
end_year: Optional[int] = None,
|
|
411
412
|
start_quarter: Optional[int] = None,
|
|
412
413
|
end_quarter: Optional[int] = None,
|
|
413
|
-
) ->
|
|
414
|
+
) -> LineItemResponse:
|
|
414
415
|
"""Get a specified financial line item for a specified duration."""
|
|
415
416
|
url = (
|
|
416
417
|
f"{self.url_base}line_item/{company_id}/{line_item}/"
|
|
@@ -420,7 +421,7 @@ class KFinanceApiClient:
|
|
|
420
421
|
f"{start_quarter if start_quarter is not None else 'none'}/"
|
|
421
422
|
f"{end_quarter if end_quarter is not None else 'none'}"
|
|
422
423
|
)
|
|
423
|
-
return self.fetch(url)
|
|
424
|
+
return LineItemResponse.model_validate(self.fetch(url))
|
|
424
425
|
|
|
425
426
|
def fetch_info(self, company_id: int) -> dict:
|
|
426
427
|
"""Get the company info."""
|
kfinance/client/meta_classes.py
CHANGED
|
@@ -202,18 +202,17 @@ class CompanyFunctionsMetaClass:
|
|
|
202
202
|
except ValueError:
|
|
203
203
|
return pd.DataFrame()
|
|
204
204
|
|
|
205
|
+
line_item_response = self.kfinance_api_client.fetch_line_item(
|
|
206
|
+
company_id=self.company_id,
|
|
207
|
+
line_item=line_item,
|
|
208
|
+
period_type=period_type,
|
|
209
|
+
start_year=start_year,
|
|
210
|
+
end_year=end_year,
|
|
211
|
+
start_quarter=start_quarter,
|
|
212
|
+
end_quarter=end_quarter,
|
|
213
|
+
)
|
|
205
214
|
return (
|
|
206
|
-
pd.DataFrame(
|
|
207
|
-
self.kfinance_api_client.fetch_line_item(
|
|
208
|
-
company_id=self.company_id,
|
|
209
|
-
line_item=line_item,
|
|
210
|
-
period_type=period_type,
|
|
211
|
-
start_year=start_year,
|
|
212
|
-
end_year=end_year,
|
|
213
|
-
start_quarter=start_quarter,
|
|
214
|
-
end_quarter=end_quarter,
|
|
215
|
-
)
|
|
216
|
-
)
|
|
215
|
+
pd.DataFrame({"line_item": line_item_response.line_item})
|
|
217
216
|
.transpose()
|
|
218
217
|
.apply(pd.to_numeric)
|
|
219
218
|
.replace(np.nan, None)
|
|
@@ -115,7 +115,9 @@ class TestFetchItem(TestCase):
|
|
|
115
115
|
company_id = 21719
|
|
116
116
|
line_item = "cash"
|
|
117
117
|
expected_fetch_url = f"{self.kfinance_api_client.url_base}line_item/{company_id}/{line_item}/none/none/none/none/none"
|
|
118
|
-
|
|
118
|
+
# Validation error is ok, we only care that the function was called with the correct url
|
|
119
|
+
with pytest.raises(ValidationError):
|
|
120
|
+
self.kfinance_api_client.fetch_line_item(company_id=company_id, line_item=line_item)
|
|
119
121
|
self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
|
|
120
122
|
period_type = PeriodType.quarterly
|
|
121
123
|
start_year = 2024
|
|
@@ -123,15 +125,18 @@ class TestFetchItem(TestCase):
|
|
|
123
125
|
start_quarter = 1
|
|
124
126
|
end_quarter = 4
|
|
125
127
|
expected_fetch_url = f"{self.kfinance_api_client.url_base}line_item/{company_id}/{line_item}/{period_type.value}/{start_year}/{end_year}/{start_quarter}/{end_quarter}"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
|
|
129
|
+
# Validation error is ok, we only care that the function was called with the correct url
|
|
130
|
+
with pytest.raises(ValidationError):
|
|
131
|
+
self.kfinance_api_client.fetch_line_item(
|
|
132
|
+
company_id=company_id,
|
|
133
|
+
line_item=line_item,
|
|
134
|
+
period_type=period_type,
|
|
135
|
+
start_year=start_year,
|
|
136
|
+
end_year=end_year,
|
|
137
|
+
start_quarter=start_quarter,
|
|
138
|
+
end_quarter=end_quarter,
|
|
139
|
+
)
|
|
135
140
|
self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
|
|
136
141
|
|
|
137
142
|
def test_fetch_info(self) -> None:
|
|
@@ -28,6 +28,7 @@ from kfinance.domains.business_relationships.business_relationship_models import
|
|
|
28
28
|
from kfinance.domains.capitalizations.capitalization_models import Capitalizations
|
|
29
29
|
from kfinance.domains.companies.company_models import CompanyIdAndName
|
|
30
30
|
from kfinance.domains.earnings.earning_models import EarningsCallResp
|
|
31
|
+
from kfinance.domains.line_items.line_item_models import LineItemResponse
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
msft_company_id = "21835"
|
|
@@ -106,15 +107,17 @@ MOCK_COMPANY_DB = {
|
|
|
106
107
|
}
|
|
107
108
|
},
|
|
108
109
|
"line_items": {
|
|
109
|
-
"revenue":
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
"revenue": LineItemResponse.model_validate(
|
|
111
|
+
{
|
|
112
|
+
"line_item": {
|
|
113
|
+
"2019": "125843000000.000000",
|
|
114
|
+
"2020": "143015000000.000000",
|
|
115
|
+
"2021": "168088000000.000000",
|
|
116
|
+
"2022": "198270000000.000000",
|
|
117
|
+
"2023": "211915000000.000000",
|
|
118
|
+
}
|
|
116
119
|
}
|
|
117
|
-
|
|
120
|
+
)
|
|
118
121
|
},
|
|
119
122
|
"segments": {
|
|
120
123
|
"2024": {
|
|
@@ -533,8 +536,11 @@ class TestCompany(TestCase):
|
|
|
533
536
|
|
|
534
537
|
def test_revenue(self) -> None:
|
|
535
538
|
"""test revenue"""
|
|
539
|
+
line_item_response: LineItemResponse = MOCK_COMPANY_DB[msft_company_id]["line_items"][
|
|
540
|
+
"revenue"
|
|
541
|
+
]
|
|
536
542
|
expected_revenue = (
|
|
537
|
-
pd.DataFrame(
|
|
543
|
+
pd.DataFrame({"line_item": line_item_response.line_item})
|
|
538
544
|
.transpose()
|
|
539
545
|
.apply(pd.to_numeric)
|
|
540
546
|
.replace(np.nan, None)
|
|
@@ -862,8 +868,11 @@ class TestTicker(TestCase):
|
|
|
862
868
|
|
|
863
869
|
def test_revenue(self) -> None:
|
|
864
870
|
"""test revenue"""
|
|
871
|
+
line_item_response: LineItemResponse = MOCK_COMPANY_DB[msft_company_id]["line_items"][
|
|
872
|
+
"revenue"
|
|
873
|
+
]
|
|
865
874
|
expected_revenue = (
|
|
866
|
-
pd.DataFrame(
|
|
875
|
+
pd.DataFrame({"line_item": line_item_response.line_item})
|
|
867
876
|
.transpose()
|
|
868
877
|
.apply(pd.to_numeric)
|
|
869
878
|
.replace(np.nan, None)
|
|
@@ -9,10 +9,14 @@ from kfinance.client.batch_request_handling import Task, process_tasks_in_thread
|
|
|
9
9
|
from kfinance.client.models.date_and_period_models import PeriodType
|
|
10
10
|
from kfinance.client.permission_models import Permission
|
|
11
11
|
from kfinance.domains.companies.company_identifiers import (
|
|
12
|
+
Identifier,
|
|
12
13
|
fetch_company_ids_from_identifiers,
|
|
13
14
|
parse_identifiers,
|
|
14
15
|
)
|
|
15
|
-
from kfinance.domains.line_items.line_item_models import
|
|
16
|
+
from kfinance.domains.line_items.line_item_models import (
|
|
17
|
+
LINE_ITEM_NAMES_AND_ALIASES,
|
|
18
|
+
LineItemResponse,
|
|
19
|
+
)
|
|
16
20
|
from kfinance.integrations.tool_calling.tool_calling_models import (
|
|
17
21
|
KfinanceTool,
|
|
18
22
|
ToolArgsWithIdentifiers,
|
|
@@ -94,13 +98,17 @@ class GetFinancialLineItemFromIdentifiers(KfinanceTool):
|
|
|
94
98
|
for identifier, company_id in identifiers_to_company_ids.items()
|
|
95
99
|
]
|
|
96
100
|
|
|
97
|
-
line_item_responses =
|
|
98
|
-
api_client=api_client, tasks=tasks
|
|
101
|
+
line_item_responses: dict[Identifier, LineItemResponse] = (
|
|
102
|
+
process_tasks_in_thread_pool_executor(api_client=api_client, tasks=tasks)
|
|
99
103
|
)
|
|
100
104
|
|
|
101
105
|
output = dict()
|
|
102
106
|
for identifier, result in line_item_responses.items():
|
|
103
|
-
df =
|
|
107
|
+
df = (
|
|
108
|
+
pd.DataFrame({"line_item": result.line_item})
|
|
109
|
+
.apply(pd.to_numeric)
|
|
110
|
+
.replace(np.nan, None)
|
|
111
|
+
)
|
|
104
112
|
# If no date and multiple companies, only return the most recent value.
|
|
105
113
|
# By default, we return 5 years of data, which can be too much when
|
|
106
114
|
# returning data for many companies.
|
kfinance/version.py
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|