kensho-kfinance 2.4.2__tar.gz → 2.6.1__tar.gz

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 (90) hide show
  1. {kensho_kfinance-2.4.2/kensho_kfinance.egg-info → kensho_kfinance-2.6.1}/PKG-INFO +1 -1
  2. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1/kensho_kfinance.egg-info}/PKG-INFO +1 -1
  3. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kensho_kfinance.egg-info/SOURCES.txt +5 -2
  4. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/CHANGELOG.md +15 -0
  5. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/batch_request_handling.py +2 -16
  6. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/constants.py +14 -2
  7. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/fetch.py +56 -0
  8. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/kfinance.py +403 -90
  9. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/mcp.py +23 -35
  10. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/meta_classes.py +37 -12
  11. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/conftest.py +4 -0
  12. kensho_kfinance-2.6.1/kfinance/tests/scratch.py +0 -0
  13. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_batch_requests.py +0 -32
  14. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_fetch.py +21 -0
  15. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_objects.py +239 -3
  16. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_tools.py +136 -24
  17. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/__init__.py +2 -4
  18. kensho_kfinance-2.6.1/kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py +39 -0
  19. kensho_kfinance-2.6.1/kfinance/tool_calling/get_competitors_from_identifier.py +24 -0
  20. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_financial_line_item_from_identifier.py +3 -3
  21. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_financial_statement_from_identifier.py +3 -3
  22. kensho_kfinance-2.6.1/kfinance/tool_calling/get_merger_info_from_transaction_id.py +62 -0
  23. kensho_kfinance-2.6.1/kfinance/tool_calling/get_mergers_from_identifier.py +41 -0
  24. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_segments_from_identifier.py +3 -3
  25. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/shared_models.py +17 -2
  26. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/version.py +2 -2
  27. kensho_kfinance-2.4.2/kfinance/tests/test_mcp.py +0 -16
  28. kensho_kfinance-2.4.2/kfinance/tool_calling/get_earnings_call_datetimes_from_identifier.py +0 -19
  29. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/.coveragerc +0 -0
  30. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/.github/workflows/ci-lint.yml +0 -0
  31. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/.github/workflows/ci-test.yml +0 -0
  32. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/.github/workflows/python-publish.yml +0 -0
  33. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/.gitignore +0 -0
  34. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/.readthedocs.yaml +0 -0
  35. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/AUTHORS.md +0 -0
  36. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/CODE_OF_CONDUCT.md +0 -0
  37. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/CONTRIBUTING.md +0 -0
  38. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/LICENSE +0 -0
  39. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/README.md +0 -0
  40. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/build_tool_calling_documentation.py +0 -0
  41. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/conf.py +0 -0
  42. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/index.rst +0 -0
  43. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/kfinance.rst +0 -0
  44. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/requirements.txt +0 -0
  45. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/templates/apidoc/package.rst_t +0 -0
  46. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/templates/apidoc/toc.rst_t +0 -0
  47. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/docs/tool_calling.rst +0 -0
  48. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/basic_usage.ipynb +0 -0
  49. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/tool_calling/langchain/anthropic_langchain_tool_calling.ipynb +0 -0
  50. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/tool_calling/langchain/google_gemini_langchain_tool_calling.ipynb +0 -0
  51. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/tool_calling/langchain/openai_langchain_tool_calling.ipynb +0 -0
  52. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/tool_calling/non-langchain/anthropic_tool_calling.ipynb +0 -0
  53. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/tool_calling/non-langchain/google_gemini_tool_calling.ipynb +0 -0
  54. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/example_notebooks/tool_calling/non-langchain/openai_langchain_tool_calling.ipynb +0 -0
  55. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/images/colab_logo_32px.png +0 -0
  56. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/justfile +0 -0
  57. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kensho_kfinance.egg-info/dependency_links.txt +0 -0
  58. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kensho_kfinance.egg-info/requires.txt +0 -0
  59. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kensho_kfinance.egg-info/top_level.txt +0 -0
  60. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/__init__.py +0 -0
  61. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/prompt.py +0 -0
  62. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/py.typed +0 -0
  63. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/pydantic_models.py +0 -0
  64. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/server_thread.py +0 -0
  65. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/__init__.py +0 -0
  66. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_client.py +0 -0
  67. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_example_notebook.py +0 -0
  68. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tests/test_group_objects.py +0 -0
  69. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/README.md +0 -0
  70. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_business_relationship_from_identifier.py +0 -0
  71. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_capitalization_from_identifier.py +0 -0
  72. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_cusip_from_ticker.py +0 -0
  73. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_earnings.py +0 -0
  74. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_history_metadata_from_identifier.py +0 -0
  75. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_info_from_identifier.py +0 -0
  76. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_isin_from_ticker.py +0 -0
  77. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_latest.py +0 -0
  78. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_latest_earnings.py +0 -0
  79. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_n_quarters_ago.py +0 -0
  80. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_next_earnings.py +0 -0
  81. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_prices_from_identifier.py +0 -0
  82. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/get_transcript.py +0 -0
  83. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/prompts.py +0 -0
  84. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/kfinance/tool_calling/resolve_identifier.py +0 -0
  85. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/pyproject.toml +0 -0
  86. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/scripts/copyright_line_check.sh +0 -0
  87. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/scripts/lint.sh +0 -0
  88. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/scripts/test.sh +0 -0
  89. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/setup.cfg +0 -0
  90. {kensho_kfinance-2.4.2 → kensho_kfinance-2.6.1}/setup.py +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,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
@@ -48,21 +48,22 @@ kfinance/server_thread.py
48
48
  kfinance/version.py
49
49
  kfinance/tests/__init__.py
50
50
  kfinance/tests/conftest.py
51
+ kfinance/tests/scratch.py
51
52
  kfinance/tests/test_batch_requests.py
52
53
  kfinance/tests/test_client.py
53
54
  kfinance/tests/test_example_notebook.py
54
55
  kfinance/tests/test_fetch.py
55
56
  kfinance/tests/test_group_objects.py
56
- kfinance/tests/test_mcp.py
57
57
  kfinance/tests/test_objects.py
58
58
  kfinance/tests/test_tools.py
59
59
  kfinance/tool_calling/README.md
60
60
  kfinance/tool_calling/__init__.py
61
+ kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py
61
62
  kfinance/tool_calling/get_business_relationship_from_identifier.py
62
63
  kfinance/tool_calling/get_capitalization_from_identifier.py
64
+ kfinance/tool_calling/get_competitors_from_identifier.py
63
65
  kfinance/tool_calling/get_cusip_from_ticker.py
64
66
  kfinance/tool_calling/get_earnings.py
65
- kfinance/tool_calling/get_earnings_call_datetimes_from_identifier.py
66
67
  kfinance/tool_calling/get_financial_line_item_from_identifier.py
67
68
  kfinance/tool_calling/get_financial_statement_from_identifier.py
68
69
  kfinance/tool_calling/get_history_metadata_from_identifier.py
@@ -70,6 +71,8 @@ kfinance/tool_calling/get_info_from_identifier.py
70
71
  kfinance/tool_calling/get_isin_from_ticker.py
71
72
  kfinance/tool_calling/get_latest.py
72
73
  kfinance/tool_calling/get_latest_earnings.py
74
+ kfinance/tool_calling/get_merger_info_from_transaction_id.py
75
+ kfinance/tool_calling/get_mergers_from_identifier.py
73
76
  kfinance/tool_calling/get_n_quarters_ago.py
74
77
  kfinance/tool_calling/get_next_earnings.py
75
78
  kfinance/tool_calling/get_prices_from_identifier.py
@@ -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
@@ -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):
@@ -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)