kensho-kfinance 2.6.2__py3-none-any.whl → 2.6.5__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-2.6.2.dist-info → kensho_kfinance-2.6.5.dist-info}/METADATA +1 -1
- kensho_kfinance-2.6.5.dist-info/RECORD +54 -0
- kfinance/CHANGELOG.md +7 -1
- kfinance/constants.py +1 -0
- kfinance/kfinance.py +5 -2
- kfinance/meta_classes.py +12 -5
- kfinance/tests/test_client.py +35 -0
- kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py +1 -1
- kfinance/tool_calling/get_business_relationship_from_identifier.py +1 -1
- kfinance/tool_calling/get_capitalization_from_identifier.py +1 -1
- kfinance/tool_calling/get_competitors_from_identifier.py +2 -2
- kfinance/tool_calling/get_cusip_from_ticker.py +1 -1
- kfinance/tool_calling/get_earnings.py +4 -1
- kfinance/tool_calling/get_financial_line_item_from_identifier.py +1 -1
- kfinance/tool_calling/get_financial_statement_from_identifier.py +1 -1
- kfinance/tool_calling/get_history_metadata_from_identifier.py +1 -1
- kfinance/tool_calling/get_info_from_identifier.py +1 -1
- kfinance/tool_calling/get_isin_from_ticker.py +1 -1
- kfinance/tool_calling/get_latest.py +1 -1
- kfinance/tool_calling/get_latest_earnings.py +4 -1
- kfinance/tool_calling/get_merger_info_from_transaction_id.py +1 -1
- kfinance/tool_calling/get_mergers_from_identifier.py +1 -1
- kfinance/tool_calling/get_n_quarters_ago.py +1 -1
- kfinance/tool_calling/get_next_earnings.py +4 -1
- kfinance/tool_calling/get_prices_from_identifier.py +1 -1
- kfinance/tool_calling/get_segments_from_identifier.py +1 -1
- kfinance/tool_calling/get_transcript.py +1 -1
- kfinance/tool_calling/resolve_identifier.py +1 -1
- kfinance/tool_calling/shared_models.py +3 -1
- kfinance/version.py +2 -2
- kensho_kfinance-2.6.2.dist-info/RECORD +0 -54
- {kensho_kfinance-2.6.2.dist-info → kensho_kfinance-2.6.5.dist-info}/WHEEL +0 -0
- {kensho_kfinance-2.6.2.dist-info → kensho_kfinance-2.6.5.dist-info}/licenses/AUTHORS.md +0 -0
- {kensho_kfinance-2.6.2.dist-info → kensho_kfinance-2.6.5.dist-info}/licenses/LICENSE +0 -0
- {kensho_kfinance-2.6.2.dist-info → kensho_kfinance-2.6.5.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.5
|
|
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
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
kensho_kfinance-2.6.5.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
|
|
2
|
+
kensho_kfinance-2.6.5.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
|
|
3
|
+
kfinance/CHANGELOG.md,sha256=YiHif7EkkMz4H_xOuDpLlFZ1-8nJE3LOR6yHs1mO_6w,2065
|
|
4
|
+
kfinance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
kfinance/batch_request_handling.py,sha256=G9rhpgQaCdb5C1dsfuJip8383iszibcOJ5k8gxld-tQ,5001
|
|
6
|
+
kfinance/constants.py,sha256=Zh7ruf-gFR6twCy5CUjOCgT_cGX-rgFdmR84AkcztYw,49453
|
|
7
|
+
kfinance/fetch.py,sha256=QyQjL2t9Z_tT1DD_Xzal59URH7QtnrpLQywcHSFtoWA,26691
|
|
8
|
+
kfinance/kfinance.py,sha256=-KilPs5VK5DDddfcFtt5NB_S8ITPfixlRUyovgE3LZA,72931
|
|
9
|
+
kfinance/mcp.py,sha256=MbktclVfBOEwfe-eR7kPaTXopMJmn_8RMlf4Jx5CXKU,3689
|
|
10
|
+
kfinance/meta_classes.py,sha256=ulRNnWZ4P0HURs8XPzCTsJ3SYbvnT4SXyG4dIuITxAo,21766
|
|
11
|
+
kfinance/prompt.py,sha256=PtVB8c_FcSlVdyGgByAnIFGzuUuBaEjciCqnBJl1hSQ,25133
|
|
12
|
+
kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
kfinance/pydantic_models.py,sha256=avpbPqwrAyLqsCbrmFpK_B8_fj1nPlBHrnPxRcBaSkE,774
|
|
14
|
+
kfinance/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdtLgA,2574
|
|
15
|
+
kfinance/version.py,sha256=-IQDAMhAOM7pwUeC1G5pNoAyrR4v-SlcNn3yoDx_kZw,511
|
|
16
|
+
kfinance/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
kfinance/tests/conftest.py,sha256=dhL_RSc-af3j-2_UrAGRE9mxgcbjuIRtj08DTx79pQc,1123
|
|
18
|
+
kfinance/tests/scratch.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
kfinance/tests/test_batch_requests.py,sha256=2A0XnDDDSPkq0-BuiRryZx8b9_jBDtjYd2kWxFVyRew,10140
|
|
20
|
+
kfinance/tests/test_client.py,sha256=_OJ8fZ14aa7Oj2znheuRIRKz7FyQLqwkhWexEZetxmg,3855
|
|
21
|
+
kfinance/tests/test_example_notebook.py,sha256=XHwDKw2avyMonTmi3snCcFWNfZhEJOkpBGOZNrMLrhk,6470
|
|
22
|
+
kfinance/tests/test_fetch.py,sha256=mIj61dd843p3D1qtTAO60rZi6Rax0NgefOTTiBFrQcQ,17887
|
|
23
|
+
kfinance/tests/test_group_objects.py,sha256=SoMEZmkG4RYdgWOAwxLHHtzIQho92KM01YbQXPUg578,1689
|
|
24
|
+
kfinance/tests/test_objects.py,sha256=YlpxjlT1kJsDf4SgTZkhhthODwCnwNukJF_wvi11p3A,40805
|
|
25
|
+
kfinance/tests/test_tools.py,sha256=OfyoS4LInkh8c6hlGj-qtTwaL0WqV-8H7od3uNYXnec,29086
|
|
26
|
+
kfinance/tool_calling/README.md,sha256=omJq7Us6r4U45QB7hRpLjRJ5BMalCkZkh4uXBjTbJXc,2022
|
|
27
|
+
kfinance/tool_calling/__init__.py,sha256=UmtbtG6PvQHB1fInEL-K5q0kPHL__zTY9wzaPRSp1wg,2174
|
|
28
|
+
kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py,sha256=rrUVesFG3EpdVnvML42o6apJyBfWOBk0iYydJgIZaig,1615
|
|
29
|
+
kfinance/tool_calling/get_business_relationship_from_identifier.py,sha256=vILN4k2NGCIrpgWiT_p7CLwDv_uQf9qXwojmQwDRsJo,1480
|
|
30
|
+
kfinance/tool_calling/get_capitalization_from_identifier.py,sha256=7n52UH0oug6KspPxCQsRinb6WPC4M5UNK1CFhQxKAaE,1529
|
|
31
|
+
kfinance/tool_calling/get_competitors_from_identifier.py,sha256=RZ1ngeeZee12GOKUvw1rpzij9A55Zfs3MTt6O-DC98M,1096
|
|
32
|
+
kfinance/tool_calling/get_cusip_from_ticker.py,sha256=P4J2JS0_jwmfBWD9k-URlJ0gPFsgTkglivN-d3fA9Ek,652
|
|
33
|
+
kfinance/tool_calling/get_earnings.py,sha256=53mpdno7uaVMQVQXC_IXYEGvBh2kM7e41SFxI9LG--A,1230
|
|
34
|
+
kfinance/tool_calling/get_financial_line_item_from_identifier.py,sha256=iQywFZzXQdvL3oSWPHZJ6v1kifR27tsHLcXa6089Wls,2161
|
|
35
|
+
kfinance/tool_calling/get_financial_statement_from_identifier.py,sha256=4nJvQBaZZpD9-cKBONEimicUsQxIftFfdVj7rRqdUck,1914
|
|
36
|
+
kfinance/tool_calling/get_history_metadata_from_identifier.py,sha256=N-ZXYMT0YGIcTmCEAKgs5IK134WKFeuVzrGyPYIliXM,734
|
|
37
|
+
kfinance/tool_calling/get_info_from_identifier.py,sha256=XRan7nKa0FQuBF0i8UmoN2E0FOMEx34N8H-El4J51E0,772
|
|
38
|
+
kfinance/tool_calling/get_isin_from_ticker.py,sha256=iy4p8dhOpkooPZP8BPQRijsZbDbuAf9WyV5t8zBGMi8,646
|
|
39
|
+
kfinance/tool_calling/get_latest.py,sha256=CHtR8MvUdOxI63kWVWFONUaqlHPhSrE9qv96RRCJsiw,792
|
|
40
|
+
kfinance/tool_calling/get_latest_earnings.py,sha256=lUahH0G-QbxxeN4ClF-ETrMACFesw5UXOl9pnssDgzM,1182
|
|
41
|
+
kfinance/tool_calling/get_merger_info_from_transaction_id.py,sha256=uTtUFMtKrN53BxZ53s_HlTyyc4ToO1qIPFUts6IQFu8,3150
|
|
42
|
+
kfinance/tool_calling/get_mergers_from_identifier.py,sha256=Av86oG4Rf4eUYG3aHIzIMwJEkrxKR1CqRYLPnCQN5po,1710
|
|
43
|
+
kfinance/tool_calling/get_n_quarters_ago.py,sha256=R-_Wn-VUYABb7CPD2OQ_xauMAOZoYXW0FPw6ccvw6Ho,719
|
|
44
|
+
kfinance/tool_calling/get_next_earnings.py,sha256=O7bIXqJmvxgBZZ9jjcvN2WGy2KIsBe6YegnymiYJy-E,1162
|
|
45
|
+
kfinance/tool_calling/get_prices_from_identifier.py,sha256=4yTEPWTMqfUfU6JdsD_TQJLEFTNji0wic-8oXtdSqVY,1890
|
|
46
|
+
kfinance/tool_calling/get_segments_from_identifier.py,sha256=-6I5pK_VSNxszUuQX6ne9zr7HFwaeWCFMddmJ3PYA_g,1873
|
|
47
|
+
kfinance/tool_calling/get_transcript.py,sha256=2Vzab47kMw1288AubFXwhNGHtodmy_n2itITgk5szOg,767
|
|
48
|
+
kfinance/tool_calling/prompts.py,sha256=Yw1DJIMh90cjL-8q6_RMRiSjCtFDXvJAy7QiV5_uAU8,911
|
|
49
|
+
kfinance/tool_calling/resolve_identifier.py,sha256=_XEfGtDEB5tnAnseyQaugn4AuNsy6wZe5f-QOh8myko,632
|
|
50
|
+
kfinance/tool_calling/shared_models.py,sha256=COwOWhzgBMJMv1uXEhlsZJ0iwgA6yX2knFG8t9wY0uU,2819
|
|
51
|
+
kensho_kfinance-2.6.5.dist-info/METADATA,sha256=Ajs4li5Ux4TEl-zmEd2QoQB-W07xiCTgdsghc6mHORQ,6197
|
|
52
|
+
kensho_kfinance-2.6.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
53
|
+
kensho_kfinance-2.6.5.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
|
|
54
|
+
kensho_kfinance-2.6.5.dist-info/RECORD,,
|
kfinance/CHANGELOG.md
CHANGED
kfinance/constants.py
CHANGED
|
@@ -94,6 +94,7 @@ class BusinessRelationshipType(StrEnum):
|
|
|
94
94
|
|
|
95
95
|
class Permission(StrEnum):
|
|
96
96
|
EarningsPermission = "EarningsPermission"
|
|
97
|
+
TranscriptsPermission = "TranscriptsPermission"
|
|
97
98
|
GICSPermission = "GICSPermission"
|
|
98
99
|
IDPermission = "IDPermission"
|
|
99
100
|
ISCRSPermission = "ISCRSPermission"
|
kfinance/kfinance.py
CHANGED
|
@@ -1644,8 +1644,11 @@ class Client:
|
|
|
1644
1644
|
for tool_cls in ALL_TOOLS:
|
|
1645
1645
|
tool = tool_cls(kfinance_client=self) # type: ignore[call-arg]
|
|
1646
1646
|
if (
|
|
1647
|
-
tool.
|
|
1648
|
-
or tool
|
|
1647
|
+
tool.accepted_permissions is None
|
|
1648
|
+
# if one or more of the required permission for a tool is a permission the user has
|
|
1649
|
+
or tool.accepted_permissions.intersection(
|
|
1650
|
+
self.kfinance_api_client.user_permissions
|
|
1651
|
+
)
|
|
1649
1652
|
):
|
|
1650
1653
|
self._tools.append(tool)
|
|
1651
1654
|
|
kfinance/meta_classes.py
CHANGED
|
@@ -427,19 +427,26 @@ class CompanyFunctionsMetaClass:
|
|
|
427
427
|
def competitors(
|
|
428
428
|
self, competitor_source: CompetitorSource = CompetitorSource.all
|
|
429
429
|
) -> "Companies":
|
|
430
|
-
"""Get the list of
|
|
430
|
+
"""Get the list of company_id and company_name that are competitors of company_id, optionally filtered by the competitor_source type.
|
|
431
431
|
|
|
432
|
-
:return: The list of
|
|
432
|
+
:return: The list of company_id and company_name that are competitors of company_id, optionally filtered by the competitor_source type
|
|
433
433
|
:rtype: Companies
|
|
434
434
|
"""
|
|
435
|
-
from .kfinance import Companies
|
|
435
|
+
from .kfinance import Companies, Company
|
|
436
436
|
|
|
437
437
|
competitors_data = self.kfinance_api_client.fetch_competitors(
|
|
438
438
|
company_id=self.company_id, competitor_source=competitor_source
|
|
439
|
-
)["
|
|
439
|
+
)["competitors"]
|
|
440
440
|
return Companies(
|
|
441
441
|
kfinance_api_client=self.kfinance_api_client,
|
|
442
|
-
|
|
442
|
+
companies=[
|
|
443
|
+
Company(
|
|
444
|
+
kfinance_api_client=self.kfinance_api_client,
|
|
445
|
+
company_id=company["company_id"],
|
|
446
|
+
company_name=company["company_name"],
|
|
447
|
+
)
|
|
448
|
+
for company in competitors_data
|
|
449
|
+
],
|
|
443
450
|
)
|
|
444
451
|
|
|
445
452
|
|
kfinance/tests/test_client.py
CHANGED
|
@@ -6,9 +6,14 @@ from kfinance.constants import Permission
|
|
|
6
6
|
from kfinance.kfinance import Client
|
|
7
7
|
from kfinance.tool_calling import (
|
|
8
8
|
GetBusinessRelationshipFromIdentifier,
|
|
9
|
+
GetEarnings,
|
|
9
10
|
GetFinancialStatementFromIdentifier,
|
|
10
11
|
GetLatest,
|
|
12
|
+
GetLatestEarnings,
|
|
13
|
+
GetNextEarnings,
|
|
14
|
+
GetTranscript,
|
|
11
15
|
)
|
|
16
|
+
from kfinance.tool_calling.shared_models import KfinanceTool
|
|
12
17
|
|
|
13
18
|
|
|
14
19
|
class TestLangchainTools:
|
|
@@ -52,3 +57,33 @@ class TestLangchainTools:
|
|
|
52
57
|
assert GetLatest in tool_classes
|
|
53
58
|
# User should not have access to functions that require statement permissions
|
|
54
59
|
assert GetFinancialStatementFromIdentifier not in tool_classes
|
|
60
|
+
|
|
61
|
+
@pytest.mark.parametrize(
|
|
62
|
+
"user_permission, expected_tool",
|
|
63
|
+
[
|
|
64
|
+
pytest.param(
|
|
65
|
+
Permission.TranscriptsPermission, GetTranscript, id="Transcript Permissions"
|
|
66
|
+
),
|
|
67
|
+
pytest.param(Permission.EarningsPermission, GetEarnings, id="Earnings Permissions"),
|
|
68
|
+
],
|
|
69
|
+
)
|
|
70
|
+
def test_permission_set_handling(
|
|
71
|
+
self, user_permission: Permission, expected_tool: KfinanceTool, mock_client: Client
|
|
72
|
+
):
|
|
73
|
+
"""
|
|
74
|
+
GIVEN a user with a permission that is in a set of required permission for a tool
|
|
75
|
+
WHEN we filter tools by permissions
|
|
76
|
+
THEN we successfully return the correct tools that either don't require permissions or tools that the user
|
|
77
|
+
specifically has access to.
|
|
78
|
+
"""
|
|
79
|
+
mock_client.kfinance_api_client._user_permissions = {user_permission} # noqa: SLF001
|
|
80
|
+
tool_classes = [type(t) for t in mock_client.langchain_tools]
|
|
81
|
+
# User should have access to GetEarnings, GetNextEarnings, GetLatestEarnings, GetTranscript
|
|
82
|
+
assert GetEarnings in tool_classes
|
|
83
|
+
assert GetNextEarnings in tool_classes
|
|
84
|
+
assert GetLatestEarnings in tool_classes
|
|
85
|
+
assert expected_tool in tool_classes
|
|
86
|
+
# User should have access to functions that don't require permissions
|
|
87
|
+
assert GetLatest in tool_classes
|
|
88
|
+
# User should not have access to functions that require statement permissions
|
|
89
|
+
assert GetFinancialStatementFromIdentifier not in tool_classes
|
|
@@ -15,7 +15,7 @@ class GetAdvisorsForCompanyInTransactionFromIdentifier(KfinanceTool):
|
|
|
15
15
|
name: str = "get_advisors_for_company_in_transaction_from_identifier"
|
|
16
16
|
description: str = 'Get the companies advising a company in a given transaction. For example, "Who advised S&P Global during their purchase of Kensho?"'
|
|
17
17
|
args_schema: Type[BaseModel] = GetAdvisorsForCompanyInTransactionFromIdentifierArgs
|
|
18
|
-
|
|
18
|
+
accepted_permissions: set[Permission] | None = {Permission.MergersPermission}
|
|
19
19
|
|
|
20
20
|
def _run(self, identifier: str, transaction_id: int) -> list:
|
|
21
21
|
ticker = self.kfinance_client.ticker(identifier)
|
|
@@ -16,7 +16,7 @@ class GetBusinessRelationshipFromIdentifier(KfinanceTool):
|
|
|
16
16
|
name: str = "get_business_relationship_from_identifier"
|
|
17
17
|
description: str = 'Get the current and previous company IDs that are relationship_type of a given identifier. For example, "What are the current distributors of SPGI?" or "What are the previous borrowers of JPM?"'
|
|
18
18
|
args_schema: Type[BaseModel] = GetBusinessRelationshipFromIdentifierArgs
|
|
19
|
-
|
|
19
|
+
accepted_permissions: set[Permission] | None = {Permission.RelationshipPermission}
|
|
20
20
|
|
|
21
21
|
def _run(self, identifier: str, business_relationship: BusinessRelationshipType) -> dict:
|
|
22
22
|
ticker = self.kfinance_client.ticker(identifier)
|
|
@@ -21,7 +21,7 @@ class GetCapitalizationFromIdentifier(KfinanceTool):
|
|
|
21
21
|
name: str = "get_capitalization_from_identifier"
|
|
22
22
|
description: str = "Get the historical market cap, tev (Total Enterprise Value), or shares outstanding of an identifier between inclusive start_date and inclusive end date. When requesting the most recent values, leave start_date and end_date empty."
|
|
23
23
|
args_schema = GetCapitalizationFromIdentifierArgs
|
|
24
|
-
|
|
24
|
+
accepted_permissions: set[Permission] | None = {Permission.PricingPermission}
|
|
25
25
|
|
|
26
26
|
def _run(
|
|
27
27
|
self,
|
|
@@ -9,9 +9,9 @@ class GetCompetitorsFromIdentifierArgs(ToolArgsWithIdentifier):
|
|
|
9
9
|
|
|
10
10
|
class GetCompetitorsFromIdentifier(KfinanceTool):
|
|
11
11
|
name: str = "get_competitors_from_identifier"
|
|
12
|
-
description: str = "Retrieves a list of competitors for a given company, optionally filtered by the source of the competitor information."
|
|
12
|
+
description: str = "Retrieves a list of company_id and company_name that are competitors for a given company, optionally filtered by the source of the competitor information."
|
|
13
13
|
args_schema = GetCompetitorsFromIdentifierArgs
|
|
14
|
-
|
|
14
|
+
accepted_permissions: set[Permission] | None = {Permission.CompetitorsPermission}
|
|
15
15
|
|
|
16
16
|
def _run(
|
|
17
17
|
self,
|
|
@@ -14,7 +14,7 @@ class GetCusipFromTicker(KfinanceTool):
|
|
|
14
14
|
name: str = "get_cusip_from_ticker"
|
|
15
15
|
description: str = "Get the CUSIP associated with a ticker."
|
|
16
16
|
args_schema: Type[BaseModel] = GetCusipFromTickerArgs
|
|
17
|
-
|
|
17
|
+
accepted_permissions: set[Permission] | None = {Permission.IDPermission}
|
|
18
18
|
|
|
19
19
|
def _run(self, ticker_str: str) -> str:
|
|
20
20
|
return self.kfinance_client.ticker(ticker_str).cusip
|
|
@@ -11,7 +11,10 @@ class GetEarnings(KfinanceTool):
|
|
|
11
11
|
name: str = "get_earnings"
|
|
12
12
|
description: str = "Get all earnings for a given identifier. Returns a list of dictionaries, each with 'name' (str), 'key_dev_id' (int), and 'datetime' (str in ISO 8601 format with UTC timezone) attributes."
|
|
13
13
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
14
|
-
|
|
14
|
+
accepted_permissions: set[Permission] | None = {
|
|
15
|
+
Permission.EarningsPermission,
|
|
16
|
+
Permission.TranscriptsPermission,
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
def _run(self, identifier: str) -> list[dict]:
|
|
17
20
|
ticker = self.kfinance_client.ticker(identifier)
|
|
@@ -24,7 +24,7 @@ class GetFinancialLineItemFromIdentifier(KfinanceTool):
|
|
|
24
24
|
name: str = "get_financial_line_item_from_identifier"
|
|
25
25
|
description: str = "Get the financial line item associated with an identifier."
|
|
26
26
|
args_schema: Type[BaseModel] = GetFinancialLineItemFromIdentifierArgs
|
|
27
|
-
|
|
27
|
+
accepted_permissions: set[Permission] | None = {Permission.StatementsPermission}
|
|
28
28
|
|
|
29
29
|
def _run(
|
|
30
30
|
self,
|
|
@@ -20,7 +20,7 @@ class GetFinancialStatementFromIdentifier(KfinanceTool):
|
|
|
20
20
|
name: str = "get_financial_statement_from_identifier"
|
|
21
21
|
description: str = "Get the financial statement associated with an identifier."
|
|
22
22
|
args_schema: Type[BaseModel] = GetFinancialStatementFromIdentifierArgs
|
|
23
|
-
|
|
23
|
+
accepted_permissions: set[Permission] | None = {Permission.StatementsPermission}
|
|
24
24
|
|
|
25
25
|
def _run(
|
|
26
26
|
self,
|
|
@@ -10,7 +10,7 @@ class GetHistoryMetadataFromIdentifier(KfinanceTool):
|
|
|
10
10
|
name: str = "get_history_metadata_from_identifier"
|
|
11
11
|
description: str = "Get the history metadata associated with an identifier. History metadata includes currency, symbol, exchange name, instrument type, and first trade date."
|
|
12
12
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
13
|
-
|
|
13
|
+
accepted_permissions: set[Permission] | None = None
|
|
14
14
|
|
|
15
15
|
def _run(self, identifier: str) -> HistoryMetadata:
|
|
16
16
|
return self.kfinance_client.ticker(identifier).history_metadata
|
|
@@ -10,7 +10,7 @@ class GetInfoFromIdentifier(KfinanceTool):
|
|
|
10
10
|
name: str = "get_info_from_identifier"
|
|
11
11
|
description: str = "Get the information associated with an identifier. Info includes company name, status, type, simple industry, number of employees (if available), founding date, webpage, HQ address, HQ city, HQ zip code, HQ state, HQ country, and HQ country iso code."
|
|
12
12
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
13
|
-
|
|
13
|
+
accepted_permissions: set[Permission] | None = None
|
|
14
14
|
|
|
15
15
|
def _run(self, identifier: str) -> str:
|
|
16
16
|
return str(self.kfinance_client.ticker(identifier).info)
|
|
@@ -14,7 +14,7 @@ class GetIsinFromTicker(KfinanceTool):
|
|
|
14
14
|
name: str = "get_isin_from_ticker"
|
|
15
15
|
description: str = "Get the ISIN associated with a ticker."
|
|
16
16
|
args_schema: Type[BaseModel] = GetIsinFromTickerArgs
|
|
17
|
-
|
|
17
|
+
accepted_permissions: set[Permission] | None = {Permission.IDPermission}
|
|
18
18
|
|
|
19
19
|
def _run(self, ticker_str: str) -> str:
|
|
20
20
|
return self.kfinance_client.ticker(ticker_str).isin
|
|
@@ -16,7 +16,7 @@ class GetLatest(KfinanceTool):
|
|
|
16
16
|
name: str = "get_latest"
|
|
17
17
|
description: str = "Get the latest annual reporting year, latest quarterly reporting quarter and year, and current date."
|
|
18
18
|
args_schema: Type[BaseModel] = GetLatestArgs
|
|
19
|
-
|
|
19
|
+
accepted_permissions: set[Permission] | None = None
|
|
20
20
|
|
|
21
21
|
def _run(self, use_local_timezone: bool = True) -> LatestPeriods:
|
|
22
22
|
return self.kfinance_client.get_latest(use_local_timezone=use_local_timezone)
|
|
@@ -11,7 +11,10 @@ class GetLatestEarnings(KfinanceTool):
|
|
|
11
11
|
name: str = "get_latest_earnings"
|
|
12
12
|
description: str = "Get the latest earnings for a given identifier. Returns a dictionary with 'name' (str), 'key_dev_id' (int), and 'datetime' (str in ISO 8601 format with UTC timezone) attributes."
|
|
13
13
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
14
|
-
|
|
14
|
+
accepted_permissions: set[Permission] | None = {
|
|
15
|
+
Permission.EarningsPermission,
|
|
16
|
+
Permission.TranscriptsPermission,
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
def _run(self, identifier: str) -> dict:
|
|
17
20
|
ticker = self.kfinance_client.ticker(identifier)
|
|
@@ -15,7 +15,7 @@ class GetMergerInfoFromTransactionId(KfinanceTool):
|
|
|
15
15
|
name: str = "get_merger_info_from_transaction_id"
|
|
16
16
|
description: str = 'Get the timeline, the participants, and the consideration of the merger or acquisition from the given transaction ID. For example, "How much was Ben & Jerrys purchased for?" or "What was the price per share for LinkedIn?" or "When did S&P purchase Kensho?"'
|
|
17
17
|
args_schema: Type[BaseModel] = GetMergerInfoFromTransactionIdArgs
|
|
18
|
-
|
|
18
|
+
accepted_permissions: set[Permission] | None = {Permission.MergersPermission}
|
|
19
19
|
|
|
20
20
|
def _run(self, transaction_id: int) -> dict:
|
|
21
21
|
merger_or_acquisition = MergerOrAcquisition(
|
|
@@ -10,7 +10,7 @@ class GetMergersFromIdentifier(KfinanceTool):
|
|
|
10
10
|
name: str = "get_mergers_from_identifier"
|
|
11
11
|
description: str = 'Get the transaction IDs that involve the given identifier. For example, "Which companies did Microsoft purchase?" or "Which company bought Ben & Jerrys?"'
|
|
12
12
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
13
|
-
|
|
13
|
+
accepted_permissions: set[Permission] | None = {Permission.MergersPermission}
|
|
14
14
|
|
|
15
15
|
def _run(self, identifier: str) -> dict:
|
|
16
16
|
ticker = self.kfinance_client.ticker(identifier)
|
|
@@ -16,7 +16,7 @@ class GetNQuartersAgo(KfinanceTool):
|
|
|
16
16
|
"Get the year and quarter corresponding to [n] quarters before the current quarter."
|
|
17
17
|
)
|
|
18
18
|
args_schema: Type[BaseModel] = GetNQuartersAgoArgs
|
|
19
|
-
|
|
19
|
+
accepted_permissions: set[Permission] | None = None
|
|
20
20
|
|
|
21
21
|
def _run(self, n: int) -> YearAndQuarter:
|
|
22
22
|
return self.kfinance_client.get_n_quarters_ago(n)
|
|
@@ -11,7 +11,10 @@ class GetNextEarnings(KfinanceTool):
|
|
|
11
11
|
name: str = "get_next_earnings"
|
|
12
12
|
description: str = "Get the next earnings for a given identifier. Returns a dictionary with 'name' (str), 'key_dev_id' (int), and 'datetime' (str in ISO 8601 format with UTC timezone) attributes."
|
|
13
13
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
14
|
-
|
|
14
|
+
accepted_permissions: set[Permission] | None = {
|
|
15
|
+
Permission.EarningsPermission,
|
|
16
|
+
Permission.TranscriptsPermission,
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
def _run(self, identifier: str) -> dict:
|
|
17
20
|
ticker = self.kfinance_client.ticker(identifier)
|
|
@@ -26,7 +26,7 @@ class GetPricesFromIdentifier(KfinanceTool):
|
|
|
26
26
|
name: str = "get_prices_from_identifier"
|
|
27
27
|
description: str = "Get the historical open, high, low, and close prices, and volume of an identifier between inclusive start_date and inclusive end date. When requesting the most recent values, leave start_date and end_date empty."
|
|
28
28
|
args_schema: Type[BaseModel] = GetPricesFromIdentifierArgs
|
|
29
|
-
|
|
29
|
+
accepted_permissions: set[Permission] | None = {Permission.PricingPermission}
|
|
30
30
|
|
|
31
31
|
def _run(
|
|
32
32
|
self,
|
|
@@ -20,7 +20,7 @@ class GetSegmentsFromIdentifier(KfinanceTool):
|
|
|
20
20
|
name: str = "get_segments_from_identifier"
|
|
21
21
|
description: str = "Get the templated segments associated with an identifier."
|
|
22
22
|
args_schema: Type[BaseModel] = GetSegmentsFromIdentifierArgs
|
|
23
|
-
|
|
23
|
+
accepted_permissions: set[Permission] | None = {Permission.SegmentsPermission}
|
|
24
24
|
|
|
25
25
|
def _run(
|
|
26
26
|
self,
|
|
@@ -16,7 +16,7 @@ class GetTranscript(KfinanceTool):
|
|
|
16
16
|
name: str = "get_transcript"
|
|
17
17
|
description: str = "Get the raw transcript text for an earnings call by key dev ID."
|
|
18
18
|
args_schema: Type[BaseModel] = GetTranscriptArgs
|
|
19
|
-
|
|
19
|
+
accepted_permissions: set[Permission] | None = {Permission.TranscriptsPermission}
|
|
20
20
|
|
|
21
21
|
def _run(self, key_dev_id: int) -> str:
|
|
22
22
|
transcript = self.kfinance_client.transcript(key_dev_id)
|
|
@@ -12,7 +12,7 @@ class ResolveIdentifier(KfinanceTool):
|
|
|
12
12
|
"Get the company_id, security_id, and trading_item_id associated with an identifier."
|
|
13
13
|
)
|
|
14
14
|
args_schema: Type[BaseModel] = ToolArgsWithIdentifier
|
|
15
|
-
|
|
15
|
+
accepted_permissions: set[Permission] | None = None
|
|
16
16
|
|
|
17
17
|
def _run(self, identifier: str) -> dict[str, int]:
|
|
18
18
|
return self.kfinance_client.ticker(identifier).id_triple._asdict()
|
|
@@ -16,7 +16,9 @@ class KfinanceTool(BaseTool):
|
|
|
16
16
|
|
|
17
17
|
kfinance_client: Client
|
|
18
18
|
args_schema: Type[BaseModel]
|
|
19
|
-
|
|
19
|
+
accepted_permissions: set[Permission] | None = Field(
|
|
20
|
+
description="The set of accepted permissions needed to access the tool. Only one of the permissions is required (or None)."
|
|
21
|
+
)
|
|
20
22
|
|
|
21
23
|
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
22
24
|
|
kfinance/version.py
CHANGED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
kensho_kfinance-2.6.2.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
|
|
2
|
-
kensho_kfinance-2.6.2.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
|
|
3
|
-
kfinance/CHANGELOG.md,sha256=ndCVbkomHlJ7kB7FoNB3N17A97hrPPtu02dxh-JBdJA,1927
|
|
4
|
-
kfinance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
kfinance/batch_request_handling.py,sha256=G9rhpgQaCdb5C1dsfuJip8383iszibcOJ5k8gxld-tQ,5001
|
|
6
|
-
kfinance/constants.py,sha256=jaHsTXEmGKLp55x1_ob_MA-GVn_hua5B6RZCbujKWz0,49401
|
|
7
|
-
kfinance/fetch.py,sha256=QyQjL2t9Z_tT1DD_Xzal59URH7QtnrpLQywcHSFtoWA,26691
|
|
8
|
-
kfinance/kfinance.py,sha256=WNw6hR7eIKVFM5iBtGrArJcOowange_ed5_PAc0aLzE,72768
|
|
9
|
-
kfinance/mcp.py,sha256=MbktclVfBOEwfe-eR7kPaTXopMJmn_8RMlf4Jx5CXKU,3689
|
|
10
|
-
kfinance/meta_classes.py,sha256=bUkksl5a9NkQQWmSM2XIWP3jsmmP4ZAfvSxPW5tRZg4,21492
|
|
11
|
-
kfinance/prompt.py,sha256=PtVB8c_FcSlVdyGgByAnIFGzuUuBaEjciCqnBJl1hSQ,25133
|
|
12
|
-
kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
kfinance/pydantic_models.py,sha256=avpbPqwrAyLqsCbrmFpK_B8_fj1nPlBHrnPxRcBaSkE,774
|
|
14
|
-
kfinance/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdtLgA,2574
|
|
15
|
-
kfinance/version.py,sha256=0Bv8KyeMcw-iHj2UIKRw0oUzwjzKa7KzZIuWroBAK1A,511
|
|
16
|
-
kfinance/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
kfinance/tests/conftest.py,sha256=dhL_RSc-af3j-2_UrAGRE9mxgcbjuIRtj08DTx79pQc,1123
|
|
18
|
-
kfinance/tests/scratch.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
kfinance/tests/test_batch_requests.py,sha256=2A0XnDDDSPkq0-BuiRryZx8b9_jBDtjYd2kWxFVyRew,10140
|
|
20
|
-
kfinance/tests/test_client.py,sha256=O7icZCSDhlQ9WGhzoXlpiSvbuA-mQNJHBYVsilyP_dE,2209
|
|
21
|
-
kfinance/tests/test_example_notebook.py,sha256=XHwDKw2avyMonTmi3snCcFWNfZhEJOkpBGOZNrMLrhk,6470
|
|
22
|
-
kfinance/tests/test_fetch.py,sha256=mIj61dd843p3D1qtTAO60rZi6Rax0NgefOTTiBFrQcQ,17887
|
|
23
|
-
kfinance/tests/test_group_objects.py,sha256=SoMEZmkG4RYdgWOAwxLHHtzIQho92KM01YbQXPUg578,1689
|
|
24
|
-
kfinance/tests/test_objects.py,sha256=YlpxjlT1kJsDf4SgTZkhhthODwCnwNukJF_wvi11p3A,40805
|
|
25
|
-
kfinance/tests/test_tools.py,sha256=OfyoS4LInkh8c6hlGj-qtTwaL0WqV-8H7od3uNYXnec,29086
|
|
26
|
-
kfinance/tool_calling/README.md,sha256=omJq7Us6r4U45QB7hRpLjRJ5BMalCkZkh4uXBjTbJXc,2022
|
|
27
|
-
kfinance/tool_calling/__init__.py,sha256=UmtbtG6PvQHB1fInEL-K5q0kPHL__zTY9wzaPRSp1wg,2174
|
|
28
|
-
kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py,sha256=u9FNRiNYiwsFXuWJNOsaW8msMrAYqGcMp-blPG-cIfg,1607
|
|
29
|
-
kfinance/tool_calling/get_business_relationship_from_identifier.py,sha256=CipXvyqEjPm6BXYP0CA9Kp1BIyiIEm7abp85x1zXRV4,1472
|
|
30
|
-
kfinance/tool_calling/get_capitalization_from_identifier.py,sha256=TdWdJDeI-jSL-1YfhnnwIA9D1SXobidvoHrjK42QmqQ,1521
|
|
31
|
-
kfinance/tool_calling/get_competitors_from_identifier.py,sha256=sCmimHZexWzvKE-13TOAErKKUoyBChxp9h_oa3W0Duo,1051
|
|
32
|
-
kfinance/tool_calling/get_cusip_from_ticker.py,sha256=houhGCYXoSzaaTtCvOBf3pPsYiSbcV1Ej5nAyGuMWcU,644
|
|
33
|
-
kfinance/tool_calling/get_earnings.py,sha256=7xavYvqwq4fO0vpks25eDM87bCYwZxEQSwgT0I8jAok,1165
|
|
34
|
-
kfinance/tool_calling/get_financial_line_item_from_identifier.py,sha256=TgZCHOKwMVUc0c7k5RGN5FWfXEM9cmJXTrDWiGudad8,2153
|
|
35
|
-
kfinance/tool_calling/get_financial_statement_from_identifier.py,sha256=QM3DfctPq8gMJzRZl508Qc184MWq_o6gwGNZEwbYopg,1906
|
|
36
|
-
kfinance/tool_calling/get_history_metadata_from_identifier.py,sha256=kKIInfRC1Plf-Wnx9cmaJ46RRABm6zn3F5_8qAdqrBg,728
|
|
37
|
-
kfinance/tool_calling/get_info_from_identifier.py,sha256=PRhSYpYs_iUcIVFGYCMN_7QJyhewua7c7pqngPIp-qg,766
|
|
38
|
-
kfinance/tool_calling/get_isin_from_ticker.py,sha256=2fJBcA-rNGbVOQmQ7qJEYxqejQwJ6nyWOBSFlzxG7dY,638
|
|
39
|
-
kfinance/tool_calling/get_latest.py,sha256=btGeVBmvX5QJutzrKfE6spatGGejDuHxtq53NoAaGNk,786
|
|
40
|
-
kfinance/tool_calling/get_latest_earnings.py,sha256=pQdExGdztGY3pHcak0bd6ULNf_ROPc91bJ7zAVSKQkk,1117
|
|
41
|
-
kfinance/tool_calling/get_merger_info_from_transaction_id.py,sha256=8aMktxIs89czDRCn4o7LcUmoTO8ueUDI40nXHo6rNZY,3142
|
|
42
|
-
kfinance/tool_calling/get_mergers_from_identifier.py,sha256=9tCaSrJsK3-i0ZDNKAJRhE-nRdJvQxTbrZbvVY0YmQw,1702
|
|
43
|
-
kfinance/tool_calling/get_n_quarters_ago.py,sha256=A0ilwPKUqU0YYQSz3gNsVF0Jy4YttXrSaDhYj7y8GHA,713
|
|
44
|
-
kfinance/tool_calling/get_next_earnings.py,sha256=knzQw-m-hscCvTuDUXG9v_dObKJBGn5BbDZWGKHKQcw,1097
|
|
45
|
-
kfinance/tool_calling/get_prices_from_identifier.py,sha256=ViJkwLDvStB7grc8RuoKSDXQM399Wru4-OY3E8k1l_U,1882
|
|
46
|
-
kfinance/tool_calling/get_segments_from_identifier.py,sha256=xDi6GF0GgZwATaxw9me64BDXVrmopKQed6j3HfXSASA,1865
|
|
47
|
-
kfinance/tool_calling/get_transcript.py,sha256=eB-IsRwD-mllsMOYRZbH35caQ1Y3teKft0tmI9nVL-A,756
|
|
48
|
-
kfinance/tool_calling/prompts.py,sha256=Yw1DJIMh90cjL-8q6_RMRiSjCtFDXvJAy7QiV5_uAU8,911
|
|
49
|
-
kfinance/tool_calling/resolve_identifier.py,sha256=npslr6bBCu0qEDV1-8d24F5OC3nQ1KBMphuMbHVC1AU,626
|
|
50
|
-
kfinance/tool_calling/shared_models.py,sha256=loNoVFVyQnnpHLUIjkR6P9flGNbzp6kkGpL5hT37Sdg,2666
|
|
51
|
-
kensho_kfinance-2.6.2.dist-info/METADATA,sha256=gmrV13LppEUpW6KMJKZftWQz1UlN165RC-G5Uwpxts8,6197
|
|
52
|
-
kensho_kfinance-2.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
53
|
-
kensho_kfinance-2.6.2.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
|
|
54
|
-
kensho_kfinance-2.6.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|