kensho-kfinance 2.4.2__py3-none-any.whl → 2.6.1__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.

Files changed (31) hide show
  1. {kensho_kfinance-2.4.2.dist-info → kensho_kfinance-2.6.1.dist-info}/METADATA +1 -1
  2. {kensho_kfinance-2.4.2.dist-info → kensho_kfinance-2.6.1.dist-info}/RECORD +29 -26
  3. kfinance/CHANGELOG.md +15 -0
  4. kfinance/batch_request_handling.py +2 -16
  5. kfinance/constants.py +14 -2
  6. kfinance/fetch.py +56 -0
  7. kfinance/kfinance.py +403 -90
  8. kfinance/mcp.py +23 -35
  9. kfinance/meta_classes.py +37 -12
  10. kfinance/tests/conftest.py +4 -0
  11. kfinance/tests/scratch.py +0 -0
  12. kfinance/tests/test_batch_requests.py +0 -32
  13. kfinance/tests/test_fetch.py +21 -0
  14. kfinance/tests/test_objects.py +239 -3
  15. kfinance/tests/test_tools.py +136 -24
  16. kfinance/tool_calling/__init__.py +2 -4
  17. kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py +39 -0
  18. kfinance/tool_calling/get_competitors_from_identifier.py +24 -0
  19. kfinance/tool_calling/get_financial_line_item_from_identifier.py +3 -3
  20. kfinance/tool_calling/get_financial_statement_from_identifier.py +3 -3
  21. kfinance/tool_calling/get_merger_info_from_transaction_id.py +62 -0
  22. kfinance/tool_calling/get_mergers_from_identifier.py +41 -0
  23. kfinance/tool_calling/get_segments_from_identifier.py +3 -3
  24. kfinance/tool_calling/shared_models.py +17 -2
  25. kfinance/version.py +2 -2
  26. kfinance/tests/test_mcp.py +0 -16
  27. kfinance/tool_calling/get_earnings_call_datetimes_from_identifier.py +0 -19
  28. {kensho_kfinance-2.4.2.dist-info → kensho_kfinance-2.6.1.dist-info}/WHEEL +0 -0
  29. {kensho_kfinance-2.4.2.dist-info → kensho_kfinance-2.6.1.dist-info}/licenses/AUTHORS.md +0 -0
  30. {kensho_kfinance-2.4.2.dist-info → kensho_kfinance-2.6.1.dist-info}/licenses/LICENSE +0 -0
  31. {kensho_kfinance-2.4.2.dist-info → kensho_kfinance-2.6.1.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.4.2
3
+ Version: 2.6.1
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,51 +1,54 @@
1
- kensho_kfinance-2.4.2.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
- kensho_kfinance-2.4.2.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
- kfinance/CHANGELOG.md,sha256=wwHuSowt4Rgr-a4aoSkc-dJz_fRfRIH2jW9yv-zAdhY,1534
1
+ kensho_kfinance-2.6.1.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
+ kensho_kfinance-2.6.1.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
+ kfinance/CHANGELOG.md,sha256=U74yQTIC0g8uDx0qjN-92xtYcHn0gEBu_bz9XvmgT7c,1817
4
4
  kfinance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- kfinance/batch_request_handling.py,sha256=p6p_G4_BL06GgeKlh7P1k9CUqOMahWCLEw1NoBwbLvU,5698
6
- kfinance/constants.py,sha256=UuFzqL253-2tRQfma785K9tfaZGv-o821tO2tVLwc5Q,48813
7
- kfinance/fetch.py,sha256=yLqKMYYP5MwHhRZBuY_ihudHeSpNvzA8u1meYrEYX90,23923
8
- kfinance/kfinance.py,sha256=9lcarUW4fLHJA_U7_1ihCMbNJWs0AztvKf_XEd0qupk,59889
9
- kfinance/mcp.py,sha256=57OoTrxo5x_v7u1s3WFQNG0LySXyLEGc6CKSVpJLJVw,3717
10
- kfinance/meta_classes.py,sha256=3V0nSXDDoake5o7kXnrqXuqNIiwI75KR4IYxFqSPhTE,20736
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=tsrmprBmG8zsIJrvLv-j-c7xXtU64EWbIjKw4cQBaGw,72456
9
+ kfinance/mcp.py,sha256=MbktclVfBOEwfe-eR7kPaTXopMJmn_8RMlf4Jx5CXKU,3689
10
+ kfinance/meta_classes.py,sha256=bUkksl5a9NkQQWmSM2XIWP3jsmmP4ZAfvSxPW5tRZg4,21492
11
11
  kfinance/prompt.py,sha256=PtVB8c_FcSlVdyGgByAnIFGzuUuBaEjciCqnBJl1hSQ,25133
12
12
  kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  kfinance/pydantic_models.py,sha256=avpbPqwrAyLqsCbrmFpK_B8_fj1nPlBHrnPxRcBaSkE,774
14
14
  kfinance/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdtLgA,2574
15
- kfinance/version.py,sha256=RUYmq8GFeP2I_XyABp0HnMjSBqGntVVhgCtP72xF2Nk,511
15
+ kfinance/version.py,sha256=ZCGpbBiHct-cyiHhdogfnoocBa55-WdHLBG45JCVyVk,511
16
16
  kfinance/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- kfinance/tests/conftest.py,sha256=voB-w8P_6L3Nel3rdgylXKe5WWaS1q7nCFt1O04uqoY,948
18
- kfinance/tests/test_batch_requests.py,sha256=uXJF2IcRdyBm5SthwIUHMKtkGZ21MY84pg_k1JeSNOY,11430
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
19
20
  kfinance/tests/test_client.py,sha256=O7icZCSDhlQ9WGhzoXlpiSvbuA-mQNJHBYVsilyP_dE,2209
20
21
  kfinance/tests/test_example_notebook.py,sha256=XHwDKw2avyMonTmi3snCcFWNfZhEJOkpBGOZNrMLrhk,6470
21
- kfinance/tests/test_fetch.py,sha256=nfnz_ZxE-W3KMzpDaRClX55fQJrRjwLTha-rHTallmE,16713
22
+ kfinance/tests/test_fetch.py,sha256=mIj61dd843p3D1qtTAO60rZi6Rax0NgefOTTiBFrQcQ,17887
22
23
  kfinance/tests/test_group_objects.py,sha256=SoMEZmkG4RYdgWOAwxLHHtzIQho92KM01YbQXPUg578,1689
23
- kfinance/tests/test_mcp.py,sha256=-pmeZ0PDp8GmXWcrWmaNNqMe7OVZONZLrjA0Y4b82os,594
24
- kfinance/tests/test_objects.py,sha256=0nDmCFrVcfI8VBo1Ph3YqXNo3uPLsSUiQkjEEHsax1M,30416
25
- kfinance/tests/test_tools.py,sha256=EWWWyPlGGES8Cn43_VaDAT7Vdp1nlIETE5dtOrP163o,24447
24
+ kfinance/tests/test_objects.py,sha256=YlpxjlT1kJsDf4SgTZkhhthODwCnwNukJF_wvi11p3A,40805
25
+ kfinance/tests/test_tools.py,sha256=OfyoS4LInkh8c6hlGj-qtTwaL0WqV-8H7od3uNYXnec,29086
26
26
  kfinance/tool_calling/README.md,sha256=omJq7Us6r4U45QB7hRpLjRJ5BMalCkZkh4uXBjTbJXc,2022
27
- kfinance/tool_calling/__init__.py,sha256=V5BVcJkLT1zC0QKZIQjLb-cZiQYV4T9Egj64uH807WE,2215
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
28
29
  kfinance/tool_calling/get_business_relationship_from_identifier.py,sha256=CipXvyqEjPm6BXYP0CA9Kp1BIyiIEm7abp85x1zXRV4,1472
29
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
30
32
  kfinance/tool_calling/get_cusip_from_ticker.py,sha256=houhGCYXoSzaaTtCvOBf3pPsYiSbcV1Ej5nAyGuMWcU,644
31
33
  kfinance/tool_calling/get_earnings.py,sha256=7xavYvqwq4fO0vpks25eDM87bCYwZxEQSwgT0I8jAok,1165
32
- kfinance/tool_calling/get_earnings_call_datetimes_from_identifier.py,sha256=Zp7gHP-z2ePu484wWx4xw89hl0z7NLcG3qliJT-6rUo,782
33
- kfinance/tool_calling/get_financial_line_item_from_identifier.py,sha256=bMK-GUMz_wmJ-7iFS72sM8AvvUvR83JYRWzYtr9Fofw,2153
34
- kfinance/tool_calling/get_financial_statement_from_identifier.py,sha256=9ouzC43skA78uI3dh3bvtM86db5RGxuWQAAJ24y-kBM,1906
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
35
36
  kfinance/tool_calling/get_history_metadata_from_identifier.py,sha256=kKIInfRC1Plf-Wnx9cmaJ46RRABm6zn3F5_8qAdqrBg,728
36
37
  kfinance/tool_calling/get_info_from_identifier.py,sha256=PRhSYpYs_iUcIVFGYCMN_7QJyhewua7c7pqngPIp-qg,766
37
38
  kfinance/tool_calling/get_isin_from_ticker.py,sha256=2fJBcA-rNGbVOQmQ7qJEYxqejQwJ6nyWOBSFlzxG7dY,638
38
39
  kfinance/tool_calling/get_latest.py,sha256=btGeVBmvX5QJutzrKfE6spatGGejDuHxtq53NoAaGNk,786
39
40
  kfinance/tool_calling/get_latest_earnings.py,sha256=pQdExGdztGY3pHcak0bd6ULNf_ROPc91bJ7zAVSKQkk,1117
41
+ kfinance/tool_calling/get_merger_info_from_transaction_id.py,sha256=PodFtnY1_sRXcp51mBobQTqj__GMRbbMxgoRIhPBArA,2938
42
+ kfinance/tool_calling/get_mergers_from_identifier.py,sha256=9tCaSrJsK3-i0ZDNKAJRhE-nRdJvQxTbrZbvVY0YmQw,1702
40
43
  kfinance/tool_calling/get_n_quarters_ago.py,sha256=A0ilwPKUqU0YYQSz3gNsVF0Jy4YttXrSaDhYj7y8GHA,713
41
44
  kfinance/tool_calling/get_next_earnings.py,sha256=knzQw-m-hscCvTuDUXG9v_dObKJBGn5BbDZWGKHKQcw,1097
42
45
  kfinance/tool_calling/get_prices_from_identifier.py,sha256=ViJkwLDvStB7grc8RuoKSDXQM399Wru4-OY3E8k1l_U,1882
43
- kfinance/tool_calling/get_segments_from_identifier.py,sha256=5schxaVyPT4-LqtkmqHMXUF4PiouEzS8disolJ8VAXE,1865
46
+ kfinance/tool_calling/get_segments_from_identifier.py,sha256=xDi6GF0GgZwATaxw9me64BDXVrmopKQed6j3HfXSASA,1865
44
47
  kfinance/tool_calling/get_transcript.py,sha256=eB-IsRwD-mllsMOYRZbH35caQ1Y3teKft0tmI9nVL-A,756
45
48
  kfinance/tool_calling/prompts.py,sha256=Yw1DJIMh90cjL-8q6_RMRiSjCtFDXvJAy7QiV5_uAU8,911
46
49
  kfinance/tool_calling/resolve_identifier.py,sha256=npslr6bBCu0qEDV1-8d24F5OC3nQ1KBMphuMbHVC1AU,626
47
- kfinance/tool_calling/shared_models.py,sha256=K-NPQyE_7Ew6Cs0zxG1xO2O47gp5uDHdHtWD7wUDZX4,2132
48
- kensho_kfinance-2.4.2.dist-info/METADATA,sha256=XcLbKXEwOlF1lvhcAOMRYwTX-3jKeq_hoF5gU0sm4H4,5191
49
- kensho_kfinance-2.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
- kensho_kfinance-2.4.2.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
51
- kensho_kfinance-2.4.2.dist-info/RECORD,,
50
+ kfinance/tool_calling/shared_models.py,sha256=loNoVFVyQnnpHLUIjkR6P9flGNbzp6kkGpL5hT37Sdg,2666
51
+ kensho_kfinance-2.6.1.dist-info/METADATA,sha256=OLtcQoyXfVs3KjB1RSZu4kNYktKoKqGV8qLJBfZKTiA,5191
52
+ kensho_kfinance-2.6.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
+ kensho_kfinance-2.6.1.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
54
+ kensho_kfinance-2.6.1.dist-info/RECORD,,
kfinance/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.6.1
4
+ - Remove get_earnings_call_datetimes_from_identifier tool
5
+
6
+ ## v2.6.0
7
+ - Add mergers & acquisitions.
8
+
9
+ ## v2.5.0
10
+ - Add competitors function and llm tools
11
+
12
+ ## v2.4.4
13
+ - Replace `cached_property` with `property` to enable batching
14
+
15
+ ## v2.4.3
16
+ - Improve MCP tool build process
17
+
3
18
  ## v2.4.2
4
19
  - Update missing permission warning
5
20
 
@@ -1,6 +1,5 @@
1
1
  from concurrent.futures import Future
2
2
  import functools
3
- from functools import cached_property
4
3
  import threading
5
4
  from typing import Any, Callable, Iterable, Protocol, Sized, Type, TypeVar
6
5
 
@@ -17,7 +16,7 @@ throttle = threading.Semaphore(MAX_WORKERS_CAP)
17
16
 
18
17
 
19
18
  def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Callable:
20
- """Returns a decorator that sets each method, property, and cached_property of"""
19
+ """Returns a decorator that adds methods and properties from a singular to a plural class."""
21
20
  "[singular_cls] as an attribute of the decorated class."
22
21
 
23
22
  class IterableKfinanceClass(Protocol, Sized, Iterable[T]):
@@ -32,7 +31,7 @@ def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Ca
32
31
  """Adds functions from a singular class to an iterable class.
33
32
 
34
33
  This decorator modifies the [iterable_cls] so that when an attribute
35
- (method, property, or cached property) added by the decorator is accessed,
34
+ (method or property) added by the decorator is accessed,
36
35
  it returns a dictionary. This dictionary maps each object in [iterable_cls]
37
36
  to the result of invoking the attribute on that specific object.
38
37
 
@@ -109,19 +108,6 @@ def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Ca
109
108
 
110
109
  setattr(iterable_cls, method_name, property(create_prop_wrapper(method)))
111
110
 
112
- elif isinstance(method, cached_property):
113
-
114
- def create_cached_prop_wrapper(method: cached_property) -> cached_property:
115
- @functools.wraps(method.func)
116
- def cached_prop_wrapper(self: IterableKfinanceClass) -> Any:
117
- return process_in_batch(method.func, self)
118
-
119
- wrapped_cached_property = cached_property(cached_prop_wrapper)
120
- wrapped_cached_property.__set_name__(iterable_cls, method_name)
121
- return wrapped_cached_property
122
-
123
- setattr(iterable_cls, method_name, create_cached_prop_wrapper(method))
124
-
125
111
  return iterable_cls
126
112
 
127
113
  return decorator
kfinance/constants.py CHANGED
@@ -56,10 +56,8 @@ class StatementType(StrEnum):
56
56
  """The type of financial statement"""
57
57
 
58
58
  balance_sheet = "balance_sheet"
59
- bs = "balance_sheet"
60
59
  income_statement = "income_statement"
61
60
  cashflow = "cashflow"
62
- cf = "cashflow"
63
61
 
64
62
 
65
63
  class SegmentType(StrEnum):
@@ -103,6 +101,20 @@ class Permission(StrEnum):
103
101
  RelationshipPermission = "RelationshipPermission"
104
102
  StatementsPermission = "StatementsPermission"
105
103
  SegmentsPermission = "SegmentsPermission"
104
+ MergersPermission = "MergersPermission"
105
+ CompetitorsPermission = "CompetitorsPermission"
106
+
107
+
108
+ class CompetitorSource(StrEnum):
109
+ """The source type of the competitor information: 'filing' (from SEC filings), 'key_dev' (from key developments), 'contact' (from contact relationships), 'third_party' (from third-party sources), 'self_identified' (self-identified), 'named_by_competitor' (from competitor's perspective)."""
110
+
111
+ all = "all"
112
+ filing = "filing"
113
+ key_dev = "key_dev"
114
+ contact = "contact"
115
+ third_party = "third_party"
116
+ self_identified = "self_identified"
117
+ named_by_competitor = "named_by_competitor"
106
118
 
107
119
 
108
120
  class YearAndQuarter(TypedDict):
kfinance/fetch.py CHANGED
@@ -11,6 +11,7 @@ import requests
11
11
 
12
12
  from .constants import (
13
13
  BusinessRelationshipType,
14
+ CompetitorSource,
14
15
  IdentificationTriple,
15
16
  IndustryClassification,
16
17
  Periodicity,
@@ -577,3 +578,58 @@ class KFinanceApiClient:
577
578
  """Get the transcript for an earnings item."""
578
579
  url = f"{self.url_base}transcript/{key_dev_id}"
579
580
  return self.fetch(url)
581
+
582
+ def fetch_competitors(self, company_id: int, competitor_source: CompetitorSource) -> dict:
583
+ """Get the competitors for a company."""
584
+ url = f"{self.url_base}competitors/{company_id}"
585
+ if competitor_source is not CompetitorSource.all:
586
+ url = url + f"/{competitor_source}"
587
+ return self.fetch(url)
588
+
589
+ def fetch_mergers_for_company(
590
+ self,
591
+ company_id: int,
592
+ ) -> dict[str, list[dict[str, int | str]]]:
593
+ """Fetches the mergers and acquisitions the given company was involved in.
594
+
595
+ Returns a dictionary of shape {"target", [{"transaction_id": <transaction_id>, "merger_title": <merger short title>}], "buyer": [...], "seller": [...]}
596
+ :param company_id: The company ID to filter on.
597
+ :type company_id: int
598
+ :return: A dictionary containing transaction IDs and 'merger titles' for each of the three kinds of roles the given company could be party to.
599
+ :rtype: dict[str, list[dict[str, int | str]]]
600
+ """
601
+ url = f"{self.url_base}mergers/{company_id}"
602
+ return self.fetch(url)
603
+
604
+ def fetch_merger_info(
605
+ self,
606
+ transaction_id: int,
607
+ ) -> dict:
608
+ """Fetches information about the given merger or acquisition, including the timeline, the participants, and the considerations.
609
+
610
+ Returns a complex dictionary.
611
+ :param transaction_id: The transaction ID to filter on.
612
+ :type transaction_id: int
613
+ :return: A dictionary containing the timeline, the participants, and the considerations (eith their details) of the transaction.
614
+ :rtype: dict
615
+ """
616
+ url = f"{self.url_base}merger/info/{transaction_id}"
617
+ return self.fetch(url)
618
+
619
+ def fetch_advisors_for_company_in_merger(
620
+ self,
621
+ transaction_id: int,
622
+ advised_company_id: int,
623
+ ) -> dict[str, list[dict[str, int | str]]]:
624
+ """Fetch information about the advisors of a given company involved in a given merger or acquisition.
625
+
626
+ Returns a dictionary of shape {"advisors": [{"advisor_company_id": <advisor_company_id>, "advisor_company_name": <advisor_company_name>, "advisor_type_name": <advisor_type_name>},...]}
627
+ :param transaction_id: The transaction ID to filter on.
628
+ :type transaction_id: int
629
+ :param advised_company_id: The company ID involved with the transaction.
630
+ :type advised_company_id: int
631
+ :return: A dictionary containing the list of companies advising a company involved with a merger or acquisition, along with their advisor type.
632
+ :rtype: dict[str, list[dict[str, int | str]]]
633
+ """
634
+ url = f"{self.url_base}merger/info/{transaction_id}/advisors/{advised_company_id}"
635
+ return self.fetch(url)