kensho-kfinance 3.0.3__tar.gz → 3.1.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 (153) hide show
  1. {kensho_kfinance-3.0.3/kensho_kfinance.egg-info → kensho_kfinance-3.1.1}/PKG-INFO +1 -1
  2. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1/kensho_kfinance.egg-info}/PKG-INFO +1 -1
  3. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kensho_kfinance.egg-info/SOURCES.txt +1 -0
  4. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/CHANGELOG.md +6 -0
  5. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/fetch.py +26 -17
  6. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/kfinance.py +17 -18
  7. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/meta_classes.py +2 -2
  8. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/tests/test_fetch.py +36 -24
  9. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/tests/test_objects.py +112 -120
  10. kensho_kfinance-3.1.1/kfinance/conftest.py +92 -0
  11. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/business_relationships/business_relationship_tools.py +30 -19
  12. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/business_relationships/tests/test_business_relationship_tools.py +18 -15
  13. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/capitalizations/capitalization_models.py +1 -1
  14. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/capitalizations/capitalization_tools.py +41 -24
  15. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/capitalizations/tests/test_capitalization_tools.py +38 -13
  16. kensho_kfinance-3.1.1/kfinance/domains/companies/company_models.py +120 -0
  17. kensho_kfinance-3.1.1/kfinance/domains/companies/company_tools.py +70 -0
  18. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/companies/tests/test_company_tools.py +11 -4
  19. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/competitors/competitor_tools.py +21 -21
  20. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/competitors/tests/test_competitor_tools.py +21 -7
  21. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/cusip_and_isin/cusip_and_isin_tools.py +38 -26
  22. kensho_kfinance-3.1.1/kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py +58 -0
  23. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/earnings/earning_tools.py +54 -47
  24. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/earnings/tests/test_earnings_tools.py +58 -63
  25. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/line_items/line_item_tools.py +29 -36
  26. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/line_items/tests/test_line_item_tools.py +23 -5
  27. kensho_kfinance-3.1.1/kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_models.py +15 -0
  28. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py +55 -38
  29. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py +22 -9
  30. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/prices/price_models.py +9 -9
  31. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/prices/price_tools.py +49 -38
  32. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/prices/tests/test_price_tools.py +52 -36
  33. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/segments/segment_models.py +7 -0
  34. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/segments/segment_tools.py +37 -20
  35. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/segments/tests/test_segment_tools.py +13 -6
  36. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/statements/statement_models.py +7 -0
  37. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/statements/statement_tools.py +38 -40
  38. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/statements/tests/test_statement_tools.py +39 -10
  39. kensho_kfinance-3.1.1/kfinance/integrations/tool_calling/prompts.py +24 -0
  40. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/tests/test_tool_calling_models.py +2 -2
  41. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/tool_calling_models.py +24 -5
  42. kensho_kfinance-3.1.1/kfinance/py.typed +0 -0
  43. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/version.py +16 -3
  44. kensho_kfinance-3.0.3/kfinance/conftest.py +0 -48
  45. kensho_kfinance-3.0.3/kfinance/domains/companies/company_identifiers.py +0 -175
  46. kensho_kfinance-3.0.3/kfinance/domains/companies/company_models.py +0 -27
  47. kensho_kfinance-3.0.3/kfinance/domains/companies/company_tools.py +0 -66
  48. kensho_kfinance-3.0.3/kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py +0 -57
  49. kensho_kfinance-3.0.3/kfinance/integrations/tool_calling/prompts.py +0 -17
  50. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/.coveragerc +0 -0
  51. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/.github/workflows/ci-lint.yml +0 -0
  52. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/.github/workflows/ci-test.yml +0 -0
  53. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/.github/workflows/python-publish.yml +0 -0
  54. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/.gitignore +0 -0
  55. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/.readthedocs.yaml +0 -0
  56. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/AUTHORS.md +0 -0
  57. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/CODE_OF_CONDUCT.md +0 -0
  58. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/CONTRIBUTING.md +0 -0
  59. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/LICENSE +0 -0
  60. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/README.md +0 -0
  61. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/build_tool_calling_documentation.py +0 -0
  62. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/conf.py +0 -0
  63. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/index.rst +0 -0
  64. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/kfinance.rst +0 -0
  65. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/requirements.txt +0 -0
  66. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/templates/apidoc/package.rst_t +0 -0
  67. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/templates/apidoc/toc.rst_t +0 -0
  68. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/docs/tool_calling.rst +0 -0
  69. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/basic_usage.ipynb +0 -0
  70. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/tool_calling/langchain/anthropic_langchain_tool_calling.ipynb +0 -0
  71. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/tool_calling/langchain/google_gemini_langchain_tool_calling.ipynb +0 -0
  72. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/tool_calling/langchain/openai_langchain_tool_calling.ipynb +0 -0
  73. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/tool_calling/non-langchain/anthropic_tool_calling.ipynb +0 -0
  74. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/tool_calling/non-langchain/google_gemini_tool_calling.ipynb +0 -0
  75. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/example_notebooks/tool_calling/non-langchain/openai_langchain_tool_calling.ipynb +0 -0
  76. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/images/colab_logo_32px.png +0 -0
  77. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/justfile +0 -0
  78. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kensho_kfinance.egg-info/dependency_links.txt +0 -0
  79. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kensho_kfinance.egg-info/requires.txt +0 -0
  80. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kensho_kfinance.egg-info/top_level.txt +0 -0
  81. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/__init__.py +0 -0
  82. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/README.md +0 -0
  83. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/__init__.py +0 -0
  84. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/batch_request_handling.py +0 -0
  85. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/industry_models.py +0 -0
  86. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/models/__init__.py +0 -0
  87. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/models/currency_models.py +0 -0
  88. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/models/date_and_period_models.py +0 -0
  89. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/models/decimal_with_unit.py +0 -0
  90. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/models/tests/__init__.py +0 -0
  91. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/models/tests/test_decimal_with_unit.py +0 -0
  92. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/permission_models.py +0 -0
  93. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/server_thread.py +0 -0
  94. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/tests/__init__.py +0 -0
  95. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/tests/test_batch_requests.py +0 -0
  96. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/tests/test_client.py +0 -0
  97. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/client/tests/test_group_objects.py +0 -0
  98. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/README.md +0 -0
  99. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/__init__.py +0 -0
  100. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/business_relationships/__init__.py +0 -0
  101. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/business_relationships/business_relationship_models.py +0 -0
  102. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/business_relationships/tests/__init__.py +0 -0
  103. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/capitalizations/__init__.py +0 -0
  104. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/capitalizations/tests/__init__.py +0 -0
  105. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/capitalizations/tests/test_capitalization_models.py +0 -0
  106. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/companies/__init__.py +0 -0
  107. /kensho_kfinance-3.0.3/kfinance/domains/companies/tests/__init__.py → /kensho_kfinance-3.1.1/kfinance/domains/companies/company_identifiers.py +0 -0
  108. {kensho_kfinance-3.0.3/kfinance/domains/competitors → kensho_kfinance-3.1.1/kfinance/domains/companies/tests}/__init__.py +0 -0
  109. {kensho_kfinance-3.0.3/kfinance/domains/competitors/tests → kensho_kfinance-3.1.1/kfinance/domains/competitors}/__init__.py +0 -0
  110. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/competitors/competitor_models.py +0 -0
  111. {kensho_kfinance-3.0.3/kfinance/domains/cusip_and_isin → kensho_kfinance-3.1.1/kfinance/domains/competitors/tests}/__init__.py +0 -0
  112. {kensho_kfinance-3.0.3/kfinance/domains/cusip_and_isin/tests → kensho_kfinance-3.1.1/kfinance/domains/cusip_and_isin}/__init__.py +0 -0
  113. {kensho_kfinance-3.0.3/kfinance/domains/earnings → kensho_kfinance-3.1.1/kfinance/domains/cusip_and_isin/tests}/__init__.py +0 -0
  114. {kensho_kfinance-3.0.3/kfinance/domains/earnings/tests → kensho_kfinance-3.1.1/kfinance/domains/earnings}/__init__.py +0 -0
  115. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/earnings/earning_models.py +0 -0
  116. {kensho_kfinance-3.0.3/kfinance/domains/line_items → kensho_kfinance-3.1.1/kfinance/domains/earnings/tests}/__init__.py +0 -0
  117. {kensho_kfinance-3.0.3/kfinance/domains/line_items/tests → kensho_kfinance-3.1.1/kfinance/domains/line_items}/__init__.py +0 -0
  118. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/line_items/line_item_models.py +0 -0
  119. {kensho_kfinance-3.0.3/kfinance/domains/mergers_and_acquisitions → kensho_kfinance-3.1.1/kfinance/domains/line_items/tests}/__init__.py +0 -0
  120. {kensho_kfinance-3.0.3/kfinance/domains/mergers_and_acquisitions/tests → kensho_kfinance-3.1.1/kfinance/domains/mergers_and_acquisitions}/__init__.py +0 -0
  121. {kensho_kfinance-3.0.3/kfinance/domains/prices → kensho_kfinance-3.1.1/kfinance/domains/mergers_and_acquisitions/tests}/__init__.py +0 -0
  122. {kensho_kfinance-3.0.3/kfinance/domains/prices/tests → kensho_kfinance-3.1.1/kfinance/domains/prices}/__init__.py +0 -0
  123. {kensho_kfinance-3.0.3/kfinance/domains/segments → kensho_kfinance-3.1.1/kfinance/domains/prices/tests}/__init__.py +0 -0
  124. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/domains/prices/tests/test_price_models.py +0 -0
  125. {kensho_kfinance-3.0.3/kfinance/domains/segments/tests → kensho_kfinance-3.1.1/kfinance/domains/segments}/__init__.py +0 -0
  126. {kensho_kfinance-3.0.3/kfinance/domains/statements → kensho_kfinance-3.1.1/kfinance/domains/segments/tests}/__init__.py +0 -0
  127. {kensho_kfinance-3.0.3/kfinance/domains/statements/tests → kensho_kfinance-3.1.1/kfinance/domains/statements}/__init__.py +0 -0
  128. {kensho_kfinance-3.0.3/kfinance/integrations → kensho_kfinance-3.1.1/kfinance/domains/statements/tests}/__init__.py +0 -0
  129. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/README.md +0 -0
  130. {kensho_kfinance-3.0.3/kfinance/integrations/local_mcp → kensho_kfinance-3.1.1/kfinance/integrations}/__init__.py +0 -0
  131. {kensho_kfinance-3.0.3/kfinance/integrations/tests → kensho_kfinance-3.1.1/kfinance/integrations/local_mcp}/__init__.py +0 -0
  132. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/local_mcp/local_mcp.py +0 -0
  133. {kensho_kfinance-3.0.3/kfinance/integrations/tool_calling → kensho_kfinance-3.1.1/kfinance/integrations/tests}/__init__.py +0 -0
  134. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tests/test_example_notebook.py +0 -0
  135. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/README.md +0 -0
  136. {kensho_kfinance-3.0.3/kfinance/integrations/tool_calling/static_tools → kensho_kfinance-3.1.1/kfinance/integrations/tool_calling}/__init__.py +0 -0
  137. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/all_tools.py +0 -0
  138. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/static_tools/README.md +0 -0
  139. {kensho_kfinance-3.0.3/kfinance/integrations/tool_calling/static_tools/tests → kensho_kfinance-3.1.1/kfinance/integrations/tool_calling/static_tools}/__init__.py +0 -0
  140. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/static_tools/get_latest.py +0 -0
  141. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/static_tools/get_n_quarters_ago.py +0 -0
  142. {kensho_kfinance-3.0.3/kfinance/integrations/tool_calling → kensho_kfinance-3.1.1/kfinance/integrations/tool_calling/static_tools}/tests/__init__.py +0 -0
  143. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/static_tools/tests/test_get_lastest.py +0 -0
  144. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py +0 -0
  145. /kensho_kfinance-3.0.3/kfinance/py.typed → /kensho_kfinance-3.1.1/kfinance/integrations/tool_calling/tests/__init__.py +0 -0
  146. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/mcp.py +0 -0
  147. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/kfinance/models/permission_models.py +0 -0
  148. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/pyproject.toml +0 -0
  149. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/scripts/copyright_line_check.sh +0 -0
  150. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/scripts/lint.sh +0 -0
  151. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/scripts/test.sh +0 -0
  152. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/setup.cfg +0 -0
  153. {kensho_kfinance-3.0.3 → kensho_kfinance-3.1.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kensho-kfinance
3
- Version: 3.0.3
3
+ Version: 3.1.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: 3.0.3
3
+ Version: 3.1.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
@@ -99,6 +99,7 @@ kfinance/domains/line_items/line_item_tools.py
99
99
  kfinance/domains/line_items/tests/__init__.py
100
100
  kfinance/domains/line_items/tests/test_line_item_tools.py
101
101
  kfinance/domains/mergers_and_acquisitions/__init__.py
102
+ kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_models.py
102
103
  kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py
103
104
  kfinance/domains/mergers_and_acquisitions/tests/__init__.py
104
105
  kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v3.1.1
4
+ - Update client base prompt
5
+
6
+ ## v3.1.0
7
+ - Use unified endpoint for company resolution
8
+
3
9
  ## v3.0.3
4
10
  - Add LineItemResponse model
5
11
 
@@ -17,12 +17,14 @@ from kfinance.domains.business_relationships.business_relationship_models import
17
17
  RelationshipResponse,
18
18
  )
19
19
  from kfinance.domains.capitalizations.capitalization_models import Capitalizations
20
- from kfinance.domains.companies.company_models import IdentificationTriple
20
+ from kfinance.domains.companies.company_models import IdentificationTriple, UnifiedIdTripleResponse
21
21
  from kfinance.domains.competitors.competitor_models import CompetitorResponse, CompetitorSource
22
22
  from kfinance.domains.earnings.earning_models import EarningsCallResp
23
23
  from kfinance.domains.line_items.line_item_models import LineItemResponse
24
- from kfinance.domains.prices.price_models import PriceHistory
25
- from kfinance.domains.segments.segment_models import SegmentType
24
+ from kfinance.domains.mergers_and_acquisitions.merger_and_acquisition_models import MergersResp
25
+ from kfinance.domains.prices.price_models import HistoryMetadataResp, PriceHistory
26
+ from kfinance.domains.segments.segment_models import SegmentsResp, SegmentType
27
+ from kfinance.domains.statements.statement_models import StatementsResp
26
28
 
27
29
 
28
30
  # version.py gets autogenerated by setuptools-scm and is not available
@@ -227,7 +229,7 @@ class KFinanceApiClient:
227
229
  finally:
228
230
  self._endpoint_tracker_queue = None
229
231
 
230
- def fetch(self, url: str) -> dict:
232
+ def fetch(self, url: str, method: str = "GET", request_body: dict | None = None) -> dict:
231
233
  """Does the request and auth"""
232
234
 
233
235
  # _endpoint_tracker_queue will only be initialized if inside the endpoint_tracker context manager
@@ -245,9 +247,11 @@ class KFinanceApiClient:
245
247
  {"Kfinance-Batch-Id": self._batch_id, "Kfinance-Batch-Size": self._batch_size}
246
248
  )
247
249
 
248
- response = requests.get(
249
- url,
250
+ response = requests.request(
251
+ method=method,
252
+ url=url,
250
253
  headers=headers,
254
+ json=request_body,
251
255
  timeout=60,
252
256
  )
253
257
  response.raise_for_status()
@@ -290,6 +294,12 @@ class KFinanceApiClient:
290
294
  url = f"{self.url_base}trading_items/{security_id}/primary"
291
295
  return self.fetch(url)
292
296
 
297
+ def unified_fetch_id_triples(self, identifiers: list[str]) -> UnifiedIdTripleResponse:
298
+ """Resolve one or more identifiers to id triples using the unified (/ids) endpoint."""
299
+ url = f"{self.url_base}ids"
300
+ resp = self.fetch(url=url, method="POST", request_body=dict(identifiers=identifiers))
301
+ return UnifiedIdTripleResponse.model_validate(resp)
302
+
293
303
  def fetch_trading_items(self, security_id: int) -> dict:
294
304
  """Get the list of trading items of a security."""
295
305
  url = f"{self.url_base}trading_items/{security_id}"
@@ -313,10 +323,10 @@ class KFinanceApiClient:
313
323
  )
314
324
  return PriceHistory.model_validate(self.fetch(url))
315
325
 
316
- def fetch_history_metadata(self, trading_item_id: int) -> dict[str, str]:
326
+ def fetch_history_metadata(self, trading_item_id: int) -> HistoryMetadataResp:
317
327
  """Get the pricing history metadata."""
318
328
  url = f"{self.url_base}pricing/{trading_item_id}/metadata"
319
- return self.fetch(url)
329
+ return HistoryMetadataResp.model_validate(self.fetch(url))
320
330
 
321
331
  def fetch_market_caps_tevs_and_shares_outstanding(
322
332
  self,
@@ -341,7 +351,7 @@ class KFinanceApiClient:
341
351
  end_year: Optional[int] = None,
342
352
  start_quarter: Optional[int] = None,
343
353
  end_quarter: Optional[int] = None,
344
- ) -> dict:
354
+ ) -> SegmentsResp:
345
355
  """Get a specified segment type for a specified duration."""
346
356
  url = (
347
357
  f"{self.url_base}segments/{company_id}/{segment_type}/"
@@ -351,7 +361,7 @@ class KFinanceApiClient:
351
361
  f"{start_quarter if start_quarter is not None else 'none'}/"
352
362
  f"{end_quarter if end_quarter is not None else 'none'}"
353
363
  )
354
- return self.fetch(url)
364
+ return SegmentsResp.model_validate(self.fetch(url))
355
365
 
356
366
  def fetch_price_chart(
357
367
  self,
@@ -390,7 +400,7 @@ class KFinanceApiClient:
390
400
  end_year: Optional[int] = None,
391
401
  start_quarter: Optional[int] = None,
392
402
  end_quarter: Optional[int] = None,
393
- ) -> dict:
403
+ ) -> StatementsResp:
394
404
  """Get a specified financial statement for a specified duration."""
395
405
  url = (
396
406
  f"{self.url_base}statements/{company_id}/{statement_type}/"
@@ -400,7 +410,7 @@ class KFinanceApiClient:
400
410
  f"{start_quarter if start_quarter is not None else 'none'}/"
401
411
  f"{end_quarter if end_quarter is not None else 'none'}"
402
412
  )
403
- return self.fetch(url)
413
+ return StatementsResp.model_validate(self.fetch(url))
404
414
 
405
415
  def fetch_line_item(
406
416
  self,
@@ -604,17 +614,16 @@ class KFinanceApiClient:
604
614
  def fetch_mergers_for_company(
605
615
  self,
606
616
  company_id: int,
607
- ) -> dict[str, list[dict[str, int | str]]]:
617
+ ) -> MergersResp:
608
618
  """Fetches the mergers and acquisitions the given company was involved in.
609
619
 
610
- Returns a dictionary of shape {"target", [{"transaction_id": <transaction_id>, "merger_title": <merger short title>}], "buyer": [...], "seller": [...]}
611
620
  :param company_id: The company ID to filter on.
612
621
  :type company_id: int
613
- :return: A dictionary containing transaction IDs and 'merger titles' for each of the three kinds of roles the given company could be party to.
614
- :rtype: dict[str, list[dict[str, int | str]]]
622
+ :return: A MergersResp, containing transaction IDs, closed_date, and 'merger titles' for each of the three kinds of roles the given company could be party to.
623
+ :rtype: MergersResp
615
624
  """
616
625
  url = f"{self.url_base}mergers/{company_id}"
617
- return self.fetch(url)
626
+ return MergersResp.model_validate(self.fetch(url))
618
627
 
619
628
  def fetch_merger_info(
620
629
  self,
@@ -38,7 +38,7 @@ from kfinance.client.models.date_and_period_models import (
38
38
  from kfinance.client.server_thread import ServerThread
39
39
  from kfinance.domains.companies.company_models import IdentificationTriple
40
40
  from kfinance.domains.earnings.earning_models import EarningsCall, TranscriptComponent
41
- from kfinance.domains.prices.price_models import HistoryMetadata, PriceHistory
41
+ from kfinance.domains.prices.price_models import HistoryMetadataResp, PriceHistory
42
42
 
43
43
 
44
44
  if TYPE_CHECKING:
@@ -78,7 +78,7 @@ class TradingItem:
78
78
  self.trading_item_id = trading_item_id
79
79
 
80
80
  self._ticker: str | None = None
81
- self._history_metadata: HistoryMetadata | None = None
81
+ self._history_metadata: HistoryMetadataResp | None = None
82
82
 
83
83
  def __str__(self) -> str:
84
84
  """String representation for the company object"""
@@ -105,20 +105,15 @@ class TradingItem:
105
105
  return trading_item
106
106
 
107
107
  @property
108
- def history_metadata(self) -> HistoryMetadata:
108
+ def history_metadata(self) -> HistoryMetadataResp:
109
109
  """Get information about exchange and quotation
110
110
 
111
111
  :return: A dict containing data about the currency, symbol, exchange, type of instrument, and the first trading date
112
112
  :rtype: HistoryMetadata
113
113
  """
114
114
  if self._history_metadata is None:
115
- metadata = self.kfinance_api_client.fetch_history_metadata(self.trading_item_id)
116
- self._history_metadata = HistoryMetadata(
117
- currency=metadata["currency"],
118
- symbol=metadata["symbol"],
119
- exchange_name=metadata["exchange_name"],
120
- instrument_type=metadata["instrument_type"],
121
- first_trade_date=datetime.strptime(metadata["first_trade_date"], "%Y-%m-%d").date(),
115
+ self._history_metadata = self.kfinance_api_client.fetch_history_metadata(
116
+ self.trading_item_id
122
117
  )
123
118
  return self._history_metadata
124
119
 
@@ -129,7 +124,7 @@ class TradingItem:
129
124
  :return: The exchange code of the trading item.
130
125
  :rtype: str
131
126
  """
132
- return self.history_metadata["exchange_name"]
127
+ return self.history_metadata.exchange_name
133
128
 
134
129
  def history(
135
130
  self,
@@ -635,7 +630,7 @@ class Company(CompanyFunctionsMetaClass):
635
630
  if self._mergers_for_company is None:
636
631
  mergers_for_company = self.kfinance_api_client.fetch_mergers_for_company(
637
632
  company_id=self.company_id
638
- )
633
+ ).model_dump(mode="json")
639
634
  output: dict = {}
640
635
  for literal in ["target", "buyer", "seller"]:
641
636
  output[literal] = MergersAndAcquisitions(
@@ -872,7 +867,7 @@ class Ticker(DelegatedCompanyFunctionsMetaClass):
872
867
  self._primary_security: Security | None = None
873
868
  self._primary_trading_item: TradingItem | None = None
874
869
  self._company: Company | None = None
875
- self._history_metadata: HistoryMetadata | None = None
870
+ self._history_metadata: HistoryMetadataResp | None = None
876
871
 
877
872
  @property
878
873
  def id_triple(self) -> IdentificationTriple:
@@ -946,6 +941,8 @@ class Ticker(DelegatedCompanyFunctionsMetaClass):
946
941
  :return: the CIQ security id
947
942
  :rtype: int
948
943
  """
944
+ if self.id_triple.security_id is None:
945
+ raise ValueError(f"Ticker {self.ticker} does not have a security_id.")
949
946
  return self.id_triple.security_id
950
947
 
951
948
  @property
@@ -955,6 +952,8 @@ class Ticker(DelegatedCompanyFunctionsMetaClass):
955
952
  :return: the CIQ trading item id
956
953
  :rtype: int
957
954
  """
955
+ if self.id_triple.trading_item_id is None:
956
+ raise ValueError(f"Ticker {self.ticker} does not have a trading_item_id.")
958
957
  return self.id_triple.trading_item_id
959
958
 
960
959
  @property
@@ -1158,7 +1157,7 @@ class Ticker(DelegatedCompanyFunctionsMetaClass):
1158
1157
  return self.company.earnings_call_datetimes
1159
1158
 
1160
1159
  @property
1161
- def history_metadata(self) -> HistoryMetadata:
1160
+ def history_metadata(self) -> HistoryMetadataResp:
1162
1161
  """Get information about exchange and quotation
1163
1162
 
1164
1163
  :return: A dict containing data about the currency, symbol, exchange, type of instrument, and the first trading date
@@ -1166,9 +1165,9 @@ class Ticker(DelegatedCompanyFunctionsMetaClass):
1166
1165
  """
1167
1166
  metadata = self.primary_trading_item.history_metadata
1168
1167
  if self.exchange_code is None:
1169
- self.exchange_code = metadata["exchange_name"]
1168
+ self.exchange_code = metadata.exchange_name
1170
1169
  if self._ticker is None:
1171
- self._ticker = metadata["symbol"]
1170
+ self._ticker = metadata.symbol
1172
1171
  return metadata
1173
1172
 
1174
1173
  @property
@@ -1176,7 +1175,7 @@ class Ticker(DelegatedCompanyFunctionsMetaClass):
1176
1175
  """Get the ticker if it isn't available from initialization"""
1177
1176
  if self._ticker is not None:
1178
1177
  return self._ticker
1179
- return self.history_metadata["symbol"]
1178
+ return self.history_metadata.symbol
1180
1179
 
1181
1180
  def history(
1182
1181
  self,
@@ -1870,7 +1869,7 @@ class Client:
1870
1869
  """
1871
1870
  mergers_for_company = self.kfinance_api_client.fetch_mergers_for_company(
1872
1871
  company_id=company_id
1873
- )
1872
+ ).model_dump(mode="json")
1874
1873
  output: dict = {}
1875
1874
  for literal in ["target", "buyer", "seller"]:
1876
1875
  output[literal] = MergersAndAcquisitions(
@@ -85,7 +85,7 @@ class CompanyFunctionsMetaClass:
85
85
  end_year=end_year,
86
86
  start_quarter=start_quarter,
87
87
  end_quarter=end_quarter,
88
- )["statements"]
88
+ ).model_dump(mode="json")["statements"]
89
89
  )
90
90
  .apply(pd.to_numeric)
91
91
  .replace(np.nan, None)
@@ -349,7 +349,7 @@ class CompanyFunctionsMetaClass:
349
349
  end_year=end_year,
350
350
  start_quarter=start_quarter,
351
351
  end_quarter=end_quarter,
352
- )["segments"]
352
+ ).model_dump(mode="json")["segments"]
353
353
 
354
354
  def business_segments(
355
355
  self,
@@ -83,16 +83,20 @@ class TestFetchItem(TestCase):
83
83
  expected_fetch_url = (
84
84
  f"{self.kfinance_api_client.url_base}pricing/{trading_item_id}/metadata"
85
85
  )
86
- self.kfinance_api_client.fetch_history_metadata(trading_item_id=trading_item_id)
86
+ # Validation error is ok, we only care that the function was called with the correct url
87
+ with pytest.raises(ValidationError):
88
+ self.kfinance_api_client.fetch_history_metadata(trading_item_id=trading_item_id)
87
89
  self.kfinance_api_client.fetch.assert_called_once_with(expected_fetch_url)
88
90
 
89
91
  def test_fetch_statement(self) -> None:
90
92
  company_id = 21719
91
93
  statement_type = "BS"
92
94
  expected_fetch_url = f"{self.kfinance_api_client.url_base}statements/{company_id}/{statement_type}/none/none/none/none/none"
93
- self.kfinance_api_client.fetch_statement(
94
- company_id=company_id, statement_type=statement_type
95
- )
95
+ # Validation error is ok, we only care that the function was called with the correct url
96
+ with pytest.raises(ValidationError):
97
+ self.kfinance_api_client.fetch_statement(
98
+ company_id=company_id, statement_type=statement_type
99
+ )
96
100
  self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
97
101
  period_type = PeriodType.quarterly
98
102
  start_year = 2024
@@ -100,15 +104,17 @@ class TestFetchItem(TestCase):
100
104
  start_quarter = 1
101
105
  end_quarter = 4
102
106
  expected_fetch_url = f"{self.kfinance_api_client.url_base}statements/{company_id}/{statement_type}/{period_type.value}/{start_year}/{end_year}/{start_quarter}/{end_quarter}"
103
- self.kfinance_api_client.fetch_statement(
104
- company_id=company_id,
105
- statement_type=statement_type,
106
- period_type=period_type,
107
- start_year=start_year,
108
- end_year=end_year,
109
- start_quarter=start_quarter,
110
- end_quarter=end_quarter,
111
- )
107
+ # Validation error is ok, we only care that the function was called with the correct url
108
+ with pytest.raises(ValidationError):
109
+ self.kfinance_api_client.fetch_statement(
110
+ company_id=company_id,
111
+ statement_type=statement_type,
112
+ period_type=period_type,
113
+ start_year=start_year,
114
+ end_year=end_year,
115
+ start_quarter=start_quarter,
116
+ end_quarter=end_quarter,
117
+ )
112
118
  self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
113
119
 
114
120
  def test_fetch_line_item(self) -> None:
@@ -267,7 +273,10 @@ class TestFetchItem(TestCase):
267
273
  company_id = 21719
268
274
  segment_type = "business"
269
275
  expected_fetch_url = f"{self.kfinance_api_client.url_base}segments/{company_id}/{segment_type}/none/none/none/none/none"
270
- self.kfinance_api_client.fetch_segments(company_id=company_id, segment_type=segment_type)
276
+ with pytest.raises(ValidationError):
277
+ self.kfinance_api_client.fetch_segments(
278
+ company_id=company_id, segment_type=segment_type
279
+ )
271
280
  self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
272
281
  period_type = PeriodType.quarterly
273
282
  start_year = 2023
@@ -275,21 +284,24 @@ class TestFetchItem(TestCase):
275
284
  start_quarter = 1
276
285
  end_quarter = 4
277
286
  expected_fetch_url = f"{self.kfinance_api_client.url_base}segments/{company_id}/{segment_type}/{period_type.value}/{start_year}/{end_year}/{start_quarter}/{end_quarter}"
278
- self.kfinance_api_client.fetch_segments(
279
- company_id=company_id,
280
- segment_type=segment_type,
281
- period_type=period_type,
282
- start_year=start_year,
283
- end_year=end_year,
284
- start_quarter=start_quarter,
285
- end_quarter=end_quarter,
286
- )
287
+ with pytest.raises(ValidationError):
288
+ self.kfinance_api_client.fetch_segments(
289
+ company_id=company_id,
290
+ segment_type=segment_type,
291
+ period_type=period_type,
292
+ start_year=start_year,
293
+ end_year=end_year,
294
+ start_quarter=start_quarter,
295
+ end_quarter=end_quarter,
296
+ )
287
297
  self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
288
298
 
289
299
  def test_fetch_mergers_for_company(self) -> None:
290
300
  company_id = 21719
291
301
  expected_fetch_url = f"{self.kfinance_api_client.url_base}mergers/{company_id}"
292
- self.kfinance_api_client.fetch_mergers_for_company(company_id=company_id)
302
+ # Validation error is ok, we only care that the function was called with the correct url
303
+ with pytest.raises(ValidationError):
304
+ self.kfinance_api_client.fetch_mergers_for_company(company_id=company_id)
293
305
  self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
294
306
 
295
307
  def test_fetch_merger_info(self) -> None: