kensho-kfinance 2.8.0__py3-none-any.whl → 3.0.0__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.8.0.dist-info → kensho_kfinance-3.0.0.dist-info}/METADATA +2 -2
- kensho_kfinance-3.0.0.dist-info/RECORD +110 -0
- kfinance/CHANGELOG.md +6 -0
- kfinance/__init__.py +1 -0
- kfinance/client/README.md +9 -0
- kfinance/{batch_request_handling.py → client/batch_request_handling.py} +63 -27
- kfinance/{fetch.py → client/fetch.py} +23 -29
- kfinance/{kfinance.py → client/kfinance.py} +105 -111
- kfinance/{meta_classes.py → client/meta_classes.py} +26 -35
- kfinance/{decimal_with_unit.py → client/models/decimal_with_unit.py} +1 -1
- kfinance/{tests → client/models/tests}/test_decimal_with_unit.py +1 -1
- kfinance/client/tests/__init__.py +0 -0
- kfinance/{tests → client/tests}/test_batch_requests.py +8 -6
- kfinance/{tests → client/tests}/test_client.py +25 -19
- kfinance/{tests → client/tests}/test_fetch.py +11 -29
- kfinance/{tests → client/tests}/test_group_objects.py +1 -1
- kfinance/{tests → client/tests}/test_objects.py +111 -63
- kfinance/{tests/conftest.py → conftest.py} +14 -2
- kfinance/domains/README.md +14 -0
- kfinance/domains/__init__.py +0 -0
- kfinance/domains/business_relationships/__init__.py +0 -0
- kfinance/{models → domains/business_relationships}/business_relationship_models.py +10 -0
- kfinance/domains/business_relationships/business_relationship_tools.py +74 -0
- kfinance/domains/business_relationships/tests/__init__.py +0 -0
- kfinance/domains/business_relationships/tests/test_business_relationship_tools.py +55 -0
- kfinance/domains/capitalizations/__init__.py +0 -0
- kfinance/{models → domains/capitalizations}/capitalization_models.py +24 -17
- kfinance/domains/capitalizations/capitalization_tools.py +89 -0
- kfinance/domains/capitalizations/tests/__init__.py +0 -0
- kfinance/{tests/test_models → domains/capitalizations/tests}/test_capitalization_models.py +8 -10
- kfinance/domains/capitalizations/tests/test_capitalization_tools.py +85 -0
- kfinance/domains/companies/__init__.py +0 -0
- kfinance/domains/companies/company_identifiers.py +175 -0
- kfinance/domains/companies/company_models.py +27 -0
- kfinance/domains/companies/company_tools.py +66 -0
- kfinance/domains/companies/tests/__init__.py +0 -0
- kfinance/domains/companies/tests/test_company_tools.py +26 -0
- kfinance/domains/competitors/__init__.py +0 -0
- kfinance/{models → domains/competitors}/competitor_models.py +7 -0
- kfinance/domains/competitors/competitor_tools.py +62 -0
- kfinance/domains/competitors/tests/__init__.py +0 -0
- kfinance/domains/competitors/tests/test_competitor_tools.py +45 -0
- kfinance/domains/cusip_and_isin/__init__.py +0 -0
- kfinance/domains/cusip_and_isin/cusip_and_isin_tools.py +80 -0
- kfinance/domains/cusip_and_isin/tests/__init__.py +0 -0
- kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py +57 -0
- kfinance/domains/earnings/__init__.py +0 -0
- kfinance/domains/earnings/earning_models.py +41 -0
- kfinance/domains/earnings/earning_tools.py +174 -0
- kfinance/domains/earnings/tests/__init__.py +0 -0
- kfinance/domains/earnings/tests/test_earnings_tools.py +195 -0
- kfinance/domains/line_items/__init__.py +0 -0
- kfinance/domains/line_items/line_item_tools.py +114 -0
- kfinance/domains/line_items/tests/__init__.py +0 -0
- kfinance/domains/line_items/tests/test_line_item_tools.py +86 -0
- kfinance/domains/mergers_and_acquisitions/__init__.py +0 -0
- kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py +176 -0
- kfinance/domains/mergers_and_acquisitions/tests/__init__.py +0 -0
- kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py +124 -0
- kfinance/domains/prices/__init__.py +0 -0
- kfinance/{models → domains/prices}/price_models.py +1 -1
- kfinance/domains/prices/price_tools.py +165 -0
- kfinance/domains/prices/tests/__init__.py +0 -0
- kfinance/{tests/test_models → domains/prices/tests}/test_price_models.py +2 -2
- kfinance/domains/prices/tests/test_price_tools.py +141 -0
- kfinance/domains/segments/__init__.py +0 -0
- kfinance/domains/segments/segment_tools.py +91 -0
- kfinance/domains/segments/tests/__init__.py +0 -0
- kfinance/domains/segments/tests/test_segment_tools.py +80 -0
- kfinance/domains/statements/__init__.py +0 -0
- kfinance/domains/statements/statement_tools.py +113 -0
- kfinance/domains/statements/tests/__init__.py +0 -0
- kfinance/domains/statements/tests/test_statement_tools.py +73 -0
- kfinance/integrations/README.md +8 -0
- kfinance/integrations/__init__.py +0 -0
- kfinance/integrations/mcp/__init__.py +0 -0
- kfinance/{mcp.py → integrations/mcp/mcp.py} +2 -2
- kfinance/integrations/tests/__init__.py +0 -0
- kfinance/{tests → integrations/tests}/test_example_notebook.py +4 -4
- kfinance/{tool_calling → integrations/tool_calling}/README.md +2 -2
- kfinance/integrations/tool_calling/__init__.py +0 -0
- kfinance/integrations/tool_calling/all_tools.py +55 -0
- kfinance/{tool_calling → integrations/tool_calling}/prompts.py +3 -2
- kfinance/integrations/tool_calling/static_tools/README.md +4 -0
- kfinance/integrations/tool_calling/static_tools/__init__.py +0 -0
- kfinance/{tool_calling → integrations/tool_calling/static_tools}/get_latest.py +3 -3
- kfinance/{tool_calling → integrations/tool_calling/static_tools}/get_n_quarters_ago.py +3 -3
- kfinance/integrations/tool_calling/static_tools/tests/__init__.py +0 -0
- kfinance/integrations/tool_calling/static_tools/tests/test_get_lastest.py +30 -0
- kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py +24 -0
- kfinance/integrations/tool_calling/tests/__init__.py +0 -0
- kfinance/integrations/tool_calling/tests/test_tool_calling_models.py +69 -0
- kfinance/{tool_calling/shared_models.py → integrations/tool_calling/tool_calling_models.py} +37 -7
- kfinance/version.py +2 -2
- kensho_kfinance-2.8.0.dist-info/RECORD +0 -70
- kfinance/models/id_models.py +0 -7
- kfinance/prompt.py +0 -526
- kfinance/pydantic_models.py +0 -33
- kfinance/tests/test_tools.py +0 -804
- kfinance/tool_calling/__init__.py +0 -53
- kfinance/tool_calling/get_advisors_for_company_in_transaction_from_identifier.py +0 -39
- kfinance/tool_calling/get_business_relationship_from_identifier.py +0 -30
- kfinance/tool_calling/get_capitalization_from_identifier.py +0 -35
- kfinance/tool_calling/get_competitors_from_identifier.py +0 -25
- kfinance/tool_calling/get_cusip_from_ticker.py +0 -20
- kfinance/tool_calling/get_earnings.py +0 -33
- kfinance/tool_calling/get_financial_line_item_from_identifier.py +0 -48
- kfinance/tool_calling/get_financial_statement_from_identifier.py +0 -44
- kfinance/tool_calling/get_history_metadata_from_identifier.py +0 -17
- kfinance/tool_calling/get_info_from_identifier.py +0 -16
- kfinance/tool_calling/get_isin_from_ticker.py +0 -20
- kfinance/tool_calling/get_latest_earnings.py +0 -30
- kfinance/tool_calling/get_merger_info_from_transaction_id.py +0 -68
- kfinance/tool_calling/get_mergers_from_identifier.py +0 -41
- kfinance/tool_calling/get_next_earnings.py +0 -30
- kfinance/tool_calling/get_prices_from_identifier.py +0 -46
- kfinance/tool_calling/get_segments_from_identifier.py +0 -44
- kfinance/tool_calling/get_transcript.py +0 -23
- kfinance/tool_calling/resolve_identifier.py +0 -18
- {kensho_kfinance-2.8.0.dist-info → kensho_kfinance-3.0.0.dist-info}/WHEEL +0 -0
- {kensho_kfinance-2.8.0.dist-info → kensho_kfinance-3.0.0.dist-info}/licenses/AUTHORS.md +0 -0
- {kensho_kfinance-2.8.0.dist-info → kensho_kfinance-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {kensho_kfinance-2.8.0.dist-info → kensho_kfinance-3.0.0.dist-info}/top_level.txt +0 -0
- /kfinance/{models → client}/__init__.py +0 -0
- /kfinance/{models → client}/industry_models.py +0 -0
- /kfinance/{tests → client/models}/__init__.py +0 -0
- /kfinance/{models → client/models}/currency_models.py +0 -0
- /kfinance/{models → client/models}/date_and_period_models.py +0 -0
- /kfinance/{tests/test_models → client/models/tests}/__init__.py +0 -0
- /kfinance/{models → client}/permission_models.py +0 -0
- /kfinance/{server_thread.py → client/server_thread.py} +0 -0
- /kfinance/{models → domains/line_items}/line_item_models.py +0 -0
- /kfinance/{models → domains/segments}/segment_models.py +0 -0
- /kfinance/{models → domains/statements}/statement_models.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
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
|
|
@@ -14,7 +14,7 @@ License-File: LICENSE
|
|
|
14
14
|
License-File: AUTHORS.md
|
|
15
15
|
Requires-Dist: cachetools<6,>=5.5
|
|
16
16
|
Requires-Dist: click<=9,>=8.2.1
|
|
17
|
-
Requires-Dist: fastmcp<
|
|
17
|
+
Requires-Dist: fastmcp<2.10,>=2.9
|
|
18
18
|
Requires-Dist: langchain-core>=0.3.15
|
|
19
19
|
Requires-Dist: langchain-google-genai<3,>=2.1.5
|
|
20
20
|
Requires-Dist: numpy>=1.22.4
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
kensho_kfinance-3.0.0.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
|
|
2
|
+
kensho_kfinance-3.0.0.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
|
|
3
|
+
kfinance/CHANGELOG.md,sha256=E0r1EJ4GGj2Q77ghjimkpNlaR9GhZmICIJP_DtZ5Xfs,2342
|
|
4
|
+
kfinance/__init__.py,sha256=k3nXA7nYUeLDrs3B0E_NcVOh_LRIfLSXGr9X78HNHeg,63
|
|
5
|
+
kfinance/conftest.py,sha256=JyBWZuJopwN9MuisFVS_U8jd9L-UU74d-ALUTa43J1Q,1599
|
|
6
|
+
kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
kfinance/version.py,sha256=feOY2rjYM8_-oXmp5ErPlMe-6zWTpyiw538tUrvFyEA,511
|
|
8
|
+
kfinance/client/README.md,sha256=DA5vg4uz1JmJNiqvYywrj46YNhOr584WO8L83Ysx_Mk,372
|
|
9
|
+
kfinance/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
kfinance/client/batch_request_handling.py,sha256=opwJJAU2JtqH-s4vt8wRqhH34MiU4tQP6Ng7K6b3upA,6561
|
|
11
|
+
kfinance/client/fetch.py,sha256=g06-j_pOl2PeX7_E-kdeEG-xcudsDIpbRupZ6J0wbo0,27856
|
|
12
|
+
kfinance/client/industry_models.py,sha256=ydB_cTIsNsfCUeaO7K2qqLUuHdG6WfUCoAzBigKVV8M,243
|
|
13
|
+
kfinance/client/kfinance.py,sha256=BwywHwYvw1PEO3wvecKaRQGYdHdIkM0yxAVdTEgRjLM,72693
|
|
14
|
+
kfinance/client/meta_classes.py,sha256=eJP09HQPQIp7H5DEFbuCKd1BZajFkzf6WpDbEnoXTuI,21415
|
|
15
|
+
kfinance/client/permission_models.py,sha256=z6MKY7Zf7StPKwsucsoVqltUesicU6MC6rxRGmlRwZI,557
|
|
16
|
+
kfinance/client/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdtLgA,2574
|
|
17
|
+
kfinance/client/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
kfinance/client/models/currency_models.py,sha256=JfDZf-nATCyjThBw-Ky2BNvM-n2oHepBLIHMCIyCRUE,19201
|
|
19
|
+
kfinance/client/models/date_and_period_models.py,sha256=B508v1SLy_mbSSuSbPz41xeFNRAeBFv41gJSlaXyHnU,1062
|
|
20
|
+
kfinance/client/models/decimal_with_unit.py,sha256=lfBvOQDk1cdWnqRh7oZoXe3_TbjNsbaV31KyosH_OoY,2911
|
|
21
|
+
kfinance/client/models/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
kfinance/client/models/tests/test_decimal_with_unit.py,sha256=7WlmVXFOFNHFqwsvXQvcgyPfa6noRm3-mLTcXz4GvRs,2202
|
|
23
|
+
kfinance/client/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
kfinance/client/tests/test_batch_requests.py,sha256=KcE5rNJHBP27xaZOmwg8cVyUMZAAPt6jDiCeq94wUUk,11661
|
|
25
|
+
kfinance/client/tests/test_client.py,sha256=GlK89ZOGL9bwrAUFUk8nua2ooKt0JYm7o_rpAfajFXA,4312
|
|
26
|
+
kfinance/client/tests/test_fetch.py,sha256=S0-HlF2o1dQRHVUCw26hmefDWKnqRww3hOoo8Z34ELU,17726
|
|
27
|
+
kfinance/client/tests/test_group_objects.py,sha256=wb7MEyGm-Qya3CXWM5Xz3kUhKFWdHT8FF3cQcjt1WxQ,1696
|
|
28
|
+
kfinance/client/tests/test_objects.py,sha256=m7wS9vr7WrY4AI0Ub9z6Ml9iOuo303ficSYlImhR_EU,42747
|
|
29
|
+
kfinance/domains/README.md,sha256=ehD15VwLupdXbz5M7hHUI7Y-2SCGxaP5W7Q4NuMcN64,664
|
|
30
|
+
kfinance/domains/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
+
kfinance/domains/business_relationships/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
kfinance/domains/business_relationships/business_relationship_models.py,sha256=6uJKR7pfPBwlfn8YLuZOt7Jagg0Gv1bHefXrOJ9Ef20,1080
|
|
33
|
+
kfinance/domains/business_relationships/business_relationship_tools.py,sha256=H5BPb7PLY6feq-gpSGbtrknpuTAfAC_EFYFpF8b0w5Q,2929
|
|
34
|
+
kfinance/domains/business_relationships/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
+
kfinance/domains/business_relationships/tests/test_business_relationship_tools.py,sha256=HhyZ4DODnPOTfSckxkTfQbkL4yKkDwFh-VBmDoETyiY,2189
|
|
36
|
+
kfinance/domains/capitalizations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
+
kfinance/domains/capitalizations/capitalization_models.py,sha256=dzPYRaDTuP6X2gqRhOP-8TaUCThYAi2Z4WH0y_19ZeY,3360
|
|
38
|
+
kfinance/domains/capitalizations/capitalization_tools.py,sha256=lcXX_Vj50LEtjkeO8AKt-Gtt6tiRRTTzupKSoIPJQTo,3636
|
|
39
|
+
kfinance/domains/capitalizations/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
kfinance/domains/capitalizations/tests/test_capitalization_models.py,sha256=SSFxEVnSLvuNjOK-gx4I3OCHso80OA37zOLmiHJhsro,3143
|
|
41
|
+
kfinance/domains/capitalizations/tests/test_capitalization_tools.py,sha256=pJ8u5aO3K2Me9_9p8_gVaREv7qTtYlLzJgE2_-H5eYA,3299
|
|
42
|
+
kfinance/domains/companies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
+
kfinance/domains/companies/company_identifiers.py,sha256=nSscL8WlpHdCAPlminTiFfh-K4VYnJULZtbDmvg18yw,6207
|
|
44
|
+
kfinance/domains/companies/company_models.py,sha256=cC3MluvkkiAVfg-IkVwI3NLyX7PvJ7Gpr-IIK_eB7Zk,637
|
|
45
|
+
kfinance/domains/companies/company_tools.py,sha256=5n3BsSo3l4xSu85RwlOQWtrUMJa4jZGtmSTWKo81qNo,2595
|
|
46
|
+
kfinance/domains/companies/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
kfinance/domains/companies/tests/test_company_tools.py,sha256=iJ82TfzeSm13B9FN7WabJh-49Zu686D-y_UN9LnbRW0,1028
|
|
48
|
+
kfinance/domains/competitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
|
+
kfinance/domains/competitors/competitor_models.py,sha256=HAEn2AzKZNusclsFzyAufpS-627RfRGL4Vw1AiT_Ek0,747
|
|
50
|
+
kfinance/domains/competitors/competitor_tools.py,sha256=fHRezFZpWMS6r3BcFFTfAfhGx28MeExjTHDi55H67_k,2496
|
|
51
|
+
kfinance/domains/competitors/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
+
kfinance/domains/competitors/tests/test_competitor_tools.py,sha256=A32zVmVfYFd643PxOFrQh-iAEnt72g4d-LJIw5AZGe4,1863
|
|
53
|
+
kfinance/domains/cusip_and_isin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
|
+
kfinance/domains/cusip_and_isin/cusip_and_isin_tools.py,sha256=9ehO2jSuD6hDf3Cq72PKsJKDHME6-D9KJ96UqmU12YA,2943
|
|
55
|
+
kfinance/domains/cusip_and_isin/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
+
kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py,sha256=-PyopFw7HqJ6_t6UWE5hVVNqDpkjQ7uj5iYaXIgaOrk,2211
|
|
57
|
+
kfinance/domains/earnings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
|
+
kfinance/domains/earnings/earning_models.py,sha256=3iPnjx3n511wqwSVB9_FMJ1ceCgIURnKpc3hwr9fIjY,1197
|
|
59
|
+
kfinance/domains/earnings/earning_tools.py,sha256=2W-OzGljXpVmoiLUOwLDPBCAVybvIZ77TUPLpyUe62A,6446
|
|
60
|
+
kfinance/domains/earnings/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
61
|
+
kfinance/domains/earnings/tests/test_earnings_tools.py,sha256=nKoYTG2bh7-ySoYGx0EXN68GHjrq-ziW5KVyiTTQfKk,6668
|
|
62
|
+
kfinance/domains/line_items/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
|
+
kfinance/domains/line_items/line_item_models.py,sha256=JIdoSYxoJDQVkmqUK6_ABpb6lULXRvrCDJGiKL6kRhE,45399
|
|
64
|
+
kfinance/domains/line_items/line_item_tools.py,sha256=7WJVuvKn6nOgraEd-YhhYB_a5KsyqosY6-LC1JSzjlA,4805
|
|
65
|
+
kfinance/domains/line_items/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
|
+
kfinance/domains/line_items/tests/test_line_item_tools.py,sha256=aJxyDyW--1kyNVtjy2uGVou6NCTiVbypsFTsnvW-GVQ,3441
|
|
67
|
+
kfinance/domains/mergers_and_acquisitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
|
+
kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py,sha256=FZ4sa8iBzSLYuteuv0jRazNR2poJcw8LxTPLwrptaKM,7500
|
|
69
|
+
kfinance/domains/mergers_and_acquisitions/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
|
+
kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py,sha256=TyWhQ0o6Wtwl8PlLa03eEdY0ypyvwWlwi3FRcWdISnw,5493
|
|
71
|
+
kfinance/domains/prices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
72
|
+
kfinance/domains/prices/price_models.py,sha256=SG0vZk__IpuxBbfC-1OuL3iezBKE9eFwyo131dfY0kI,2163
|
|
73
|
+
kfinance/domains/prices/price_tools.py,sha256=AL2TIFR-fk13vz03EjgCf3DmXyyXTsd3-3kLp3RNG6E,6587
|
|
74
|
+
kfinance/domains/prices/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
|
+
kfinance/domains/prices/tests/test_price_models.py,sha256=PWGqbR9aCys2ldHZMF5anMXsSYEVOjgygfpxLcLVKL8,2400
|
|
76
|
+
kfinance/domains/prices/tests/test_price_tools.py,sha256=Zj1b8pN1oJD1mjd7pbj0wsnWoDpUWEVW9jXUn8yn3UE,5274
|
|
77
|
+
kfinance/domains/segments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
|
+
kfinance/domains/segments/segment_models.py,sha256=GSJhK1HmbMmwRDFmrDTZzx8aYrAaHN13IJ0J9GTBn9Y,145
|
|
79
|
+
kfinance/domains/segments/segment_tools.py,sha256=6JzR0na6vi259EeQ8FwXguHI8fsF_T5Ag7Y-_KAgP3M,3845
|
|
80
|
+
kfinance/domains/segments/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
81
|
+
kfinance/domains/segments/tests/test_segment_tools.py,sha256=CKhRdtuyxhkM5grTtZF12XkJ8rkISVufpUXgq5qru4U,3024
|
|
82
|
+
kfinance/domains/statements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
|
+
kfinance/domains/statements/statement_models.py,sha256=RmclTeyahCODUP0-KgZZZequFgQ2pUQ8cdfHI96c9vA,207
|
|
84
|
+
kfinance/domains/statements/statement_tools.py,sha256=69L5lknrYmostd0ROqEskKMGZ2N4AIvQPHG6_4WfUjs,4560
|
|
85
|
+
kfinance/domains/statements/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
|
+
kfinance/domains/statements/tests/test_statement_tools.py,sha256=O2fzCLmp98jxLD6cl16l65PvGYqa-_fQClayZzMOJxI,3015
|
|
87
|
+
kfinance/integrations/README.md,sha256=GalSN11UHzbLfcNzKAlObNbw5XqMKVXSVzzGlryM3zc,320
|
|
88
|
+
kfinance/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
89
|
+
kfinance/integrations/mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
|
+
kfinance/integrations/mcp/mcp.py,sha256=9Wja-FvXZ-zK9iNRJmma3nGZ1r2VhRU1cVTxZ6BGLeE,3729
|
|
91
|
+
kfinance/integrations/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
92
|
+
kfinance/integrations/tests/test_example_notebook.py,sha256=NrqYFn_XyOn0YlV9QYEnNMBB7LEkg70pP1eqiLGxcBE,6529
|
|
93
|
+
kfinance/integrations/tool_calling/README.md,sha256=TSk-AJddoEctzc0HXQvGNac2CckbnWxHcRDtEifSe1w,2029
|
|
94
|
+
kfinance/integrations/tool_calling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
95
|
+
kfinance/integrations/tool_calling/all_tools.py,sha256=MbvAZX2yEyovGtBNcr5f6n2G_lV5Zc9nnSn7xgH3zjQ,2115
|
|
96
|
+
kfinance/integrations/tool_calling/prompts.py,sha256=cLslVoubJyuh4W2-Eeok2dLOV4R7wUQGCu1HeQ1kNQo,1005
|
|
97
|
+
kfinance/integrations/tool_calling/tool_calling_models.py,sha256=lb6r_1ULIA9RA5YsC9VLCY2kBwGrykx4UI0uDvlCZkM,5300
|
|
98
|
+
kfinance/integrations/tool_calling/static_tools/README.md,sha256=lWQWdLY1tkGxqE8o4f61gc-RCX0doaCnZM0GmcNO6Jo,97
|
|
99
|
+
kfinance/integrations/tool_calling/static_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
100
|
+
kfinance/integrations/tool_calling/static_tools/get_latest.py,sha256=pSLjofq9E6cQqGSFC73KmVpLATk9t5e-dUChsRmYUIQ,883
|
|
101
|
+
kfinance/integrations/tool_calling/static_tools/get_n_quarters_ago.py,sha256=e29Mln2ExFZQwXLQmIrIk6eZToPI_IcfEMiVInR-NLU,810
|
|
102
|
+
kfinance/integrations/tool_calling/static_tools/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
103
|
+
kfinance/integrations/tool_calling/static_tools/tests/test_get_lastest.py,sha256=26CpdDcb-Ai3w-6qPVRRFPdlT2EKAFuOWkIRhxvb_Fk,989
|
|
104
|
+
kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py,sha256=r7wtp7ttcJkKi2DQd42nzjfSXcpZAL97SrbltnjHuEI,775
|
|
105
|
+
kfinance/integrations/tool_calling/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
106
|
+
kfinance/integrations/tool_calling/tests/test_tool_calling_models.py,sha256=PWNNHaF7mFDZXXfwf4o5Hdemvr8VWl71ODHddr0FMwA,2596
|
|
107
|
+
kensho_kfinance-3.0.0.dist-info/METADATA,sha256=IEoMmqwKpotcwZmC_vn2vYmlRhIMBtiqIRk52PSeHJY,6202
|
|
108
|
+
kensho_kfinance-3.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
109
|
+
kensho_kfinance-3.0.0.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
|
|
110
|
+
kensho_kfinance-3.0.0.dist-info/RECORD,,
|
kfinance/CHANGELOG.md
CHANGED
kfinance/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from kfinance.integrations.mcp.mcp import run_mcp # noqa:F401
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Client
|
|
2
|
+
|
|
3
|
+
Client contains the main Kfinance `Client` class from `kfinance.py`
|
|
4
|
+
and the lower level `KFinanceApiClient` from `fetch.py`. It also
|
|
5
|
+
includes the objects like `Company` on which the `Client` operates
|
|
6
|
+
and related helpers like batch processing functionality.
|
|
7
|
+
|
|
8
|
+
It may at some point make sense to factor out objects and fetch
|
|
9
|
+
functions into their related domains.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
from concurrent.futures import Future
|
|
2
|
+
from dataclasses import dataclass, field
|
|
2
3
|
import functools
|
|
3
4
|
import threading
|
|
4
|
-
from typing import Any, Callable, Iterable, Protocol, Sized, Type, TypeVar
|
|
5
|
+
from typing import Any, Callable, Hashable, Iterable, Protocol, Sized, Type, TypeVar
|
|
5
6
|
|
|
6
7
|
from requests.exceptions import HTTPError
|
|
7
8
|
|
|
8
|
-
from .fetch import KFinanceApiClient
|
|
9
|
+
from kfinance.client.fetch import KFinanceApiClient
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
T = TypeVar("T")
|
|
@@ -54,29 +55,6 @@ def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Ca
|
|
|
54
55
|
instances of [singular_cls].
|
|
55
56
|
"""
|
|
56
57
|
|
|
57
|
-
def process_in_batch(
|
|
58
|
-
method: Callable, self: IterableKfinanceClass, *args: Any, **kwargs: Any
|
|
59
|
-
) -> dict:
|
|
60
|
-
with self.kfinance_api_client.batch_request_header(batch_size=len(self)):
|
|
61
|
-
futures = []
|
|
62
|
-
for obj in self:
|
|
63
|
-
# Acquire throttle before submitting the task
|
|
64
|
-
throttle.acquire()
|
|
65
|
-
future = self.kfinance_api_client.thread_pool.submit(
|
|
66
|
-
method, obj, *args, **kwargs
|
|
67
|
-
)
|
|
68
|
-
# On success or failure, release the throttle.
|
|
69
|
-
# This releases the throttle before the
|
|
70
|
-
# `resolve_future_with_error_handling` call.
|
|
71
|
-
future.add_done_callback(lambda f: throttle.release())
|
|
72
|
-
futures.append(future)
|
|
73
|
-
|
|
74
|
-
results = {}
|
|
75
|
-
for obj, future in zip(self, futures):
|
|
76
|
-
results[obj] = resolve_future_with_error_handling(future)
|
|
77
|
-
|
|
78
|
-
return results
|
|
79
|
-
|
|
80
58
|
for method_name in dir(singular_cls):
|
|
81
59
|
method = getattr(singular_cls, method_name)
|
|
82
60
|
if method_name.startswith("__") or method_name.startswith("set_"):
|
|
@@ -88,7 +66,13 @@ def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Ca
|
|
|
88
66
|
def method_wrapper(
|
|
89
67
|
self: IterableKfinanceClass, *args: Any, **kwargs: Any
|
|
90
68
|
) -> dict:
|
|
91
|
-
return
|
|
69
|
+
return process_tasks_in_thread_pool_executor(
|
|
70
|
+
api_client=self.kfinance_api_client,
|
|
71
|
+
tasks=[
|
|
72
|
+
Task(func=method, args=(obj, *args), kwargs=kwargs, result_key=obj)
|
|
73
|
+
for obj in self
|
|
74
|
+
],
|
|
75
|
+
)
|
|
92
76
|
|
|
93
77
|
return method_wrapper
|
|
94
78
|
|
|
@@ -102,7 +86,12 @@ def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Ca
|
|
|
102
86
|
@functools.wraps(method.fget)
|
|
103
87
|
def prop_wrapper(self: IterableKfinanceClass) -> Any:
|
|
104
88
|
assert method.fget is not None
|
|
105
|
-
return
|
|
89
|
+
return process_tasks_in_thread_pool_executor(
|
|
90
|
+
api_client=self.kfinance_api_client,
|
|
91
|
+
tasks=[
|
|
92
|
+
Task(func=method.fget, args=(obj,), result_key=obj) for obj in self
|
|
93
|
+
],
|
|
94
|
+
)
|
|
106
95
|
|
|
107
96
|
return prop_wrapper
|
|
108
97
|
|
|
@@ -113,6 +102,53 @@ def add_methods_of_singular_class_to_iterable_class(singular_cls: Type[T]) -> Ca
|
|
|
113
102
|
return decorator
|
|
114
103
|
|
|
115
104
|
|
|
105
|
+
@dataclass(kw_only=True)
|
|
106
|
+
class Task:
|
|
107
|
+
"""A task for batch processing.
|
|
108
|
+
|
|
109
|
+
- args and kwargs are intended to be passed into the func as func(*args, **kwargs)
|
|
110
|
+
- results from batch processing are returned as dicts. The result_key is usually
|
|
111
|
+
something that either is an id (e.g. company_id) or has an id (e.g. Company
|
|
112
|
+
or CompanyIdentifier), used to map from that key to the corresponding result.
|
|
113
|
+
- The future is used to store the batch processing future. It should not be modified
|
|
114
|
+
directly outside of process_tasks_in_thread_pool_executor.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
func: Callable
|
|
118
|
+
args: Any = field(default_factory=tuple)
|
|
119
|
+
kwargs: Any = field(default_factory=dict)
|
|
120
|
+
result_key: Hashable
|
|
121
|
+
future: Future | None = field(init=False, default=None)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def process_tasks_in_thread_pool_executor(api_client: KFinanceApiClient, tasks: list[Task]) -> dict:
|
|
125
|
+
"""Execute a list of tasks in the api client's thread pool executor and return the results.
|
|
126
|
+
|
|
127
|
+
Returns a dict mapping from each task's key to the corresponding result.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
# Update access if necessary before submitting batch job.
|
|
131
|
+
# If the batch job starts without a valid token, each thread may try to refresh it.
|
|
132
|
+
assert api_client.access_token
|
|
133
|
+
with api_client.batch_request_header(batch_size=len(tasks)):
|
|
134
|
+
for task in tasks:
|
|
135
|
+
# Acquire throttle before submitting the task
|
|
136
|
+
throttle.acquire()
|
|
137
|
+
future = api_client.thread_pool.submit(task.func, *task.args, **task.kwargs)
|
|
138
|
+
# On success or failure, release the throttle.
|
|
139
|
+
# This releases the throttle before the
|
|
140
|
+
# `resolve_future_with_error_handling` call.
|
|
141
|
+
future.add_done_callback(lambda f: throttle.release())
|
|
142
|
+
task.future = future
|
|
143
|
+
|
|
144
|
+
results = {}
|
|
145
|
+
for task in tasks:
|
|
146
|
+
assert task.future
|
|
147
|
+
results[task.result_key] = resolve_future_with_error_handling(task.future)
|
|
148
|
+
|
|
149
|
+
return results
|
|
150
|
+
|
|
151
|
+
|
|
116
152
|
def resolve_future_with_error_handling(future: Future) -> Any:
|
|
117
153
|
"""Return the result of a future with error handling for non-200 status codes.
|
|
118
154
|
|
|
@@ -7,19 +7,21 @@ from typing import Callable, Generator, Optional
|
|
|
7
7
|
from uuid import uuid4
|
|
8
8
|
|
|
9
9
|
import jwt
|
|
10
|
-
from pydantic import ValidationError
|
|
11
10
|
import requests
|
|
12
11
|
|
|
13
|
-
from kfinance.
|
|
14
|
-
from kfinance.models.
|
|
15
|
-
from kfinance.
|
|
16
|
-
from kfinance.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
from kfinance.
|
|
21
|
-
from kfinance.
|
|
22
|
-
from kfinance.
|
|
12
|
+
from kfinance.client.industry_models import IndustryClassification
|
|
13
|
+
from kfinance.client.models.date_and_period_models import Periodicity, PeriodType
|
|
14
|
+
from kfinance.client.permission_models import Permission
|
|
15
|
+
from kfinance.domains.business_relationships.business_relationship_models import (
|
|
16
|
+
BusinessRelationshipType,
|
|
17
|
+
RelationshipResponse,
|
|
18
|
+
)
|
|
19
|
+
from kfinance.domains.capitalizations.capitalization_models import Capitalizations
|
|
20
|
+
from kfinance.domains.companies.company_models import IdentificationTriple
|
|
21
|
+
from kfinance.domains.competitors.competitor_models import CompetitorResponse, CompetitorSource
|
|
22
|
+
from kfinance.domains.earnings.earning_models import EarningsCallResp
|
|
23
|
+
from kfinance.domains.prices.price_models import PriceHistory
|
|
24
|
+
from kfinance.domains.segments.segment_models import SegmentType
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
# version.py gets autogenerated by setuptools-scm and is not available
|
|
@@ -528,30 +530,20 @@ class KFinanceApiClient:
|
|
|
528
530
|
|
|
529
531
|
def fetch_companies_from_business_relationship(
|
|
530
532
|
self, company_id: int, relationship_type: BusinessRelationshipType
|
|
531
|
-
) -> RelationshipResponse
|
|
533
|
+
) -> RelationshipResponse:
|
|
532
534
|
"""Fetches a dictionary of current and previous company IDs and names associated with a given company ID based on the specified relationship type.
|
|
533
535
|
|
|
534
536
|
Example: fetch_companies_from_business_relationship(company_id=1234, relationship_type="distributor") returns a dictionary of company 1234's current and previous distributors.
|
|
535
537
|
|
|
536
|
-
As of 2024-05-28, we are changing the response on the backend from
|
|
537
|
-
RelationshipResponseNoName to RelationshipResponse. This function can handle both response
|
|
538
|
-
types.
|
|
539
|
-
|
|
540
538
|
:param company_id: The ID of the company for which associated companies are being fetched.
|
|
541
539
|
:type company_id: int
|
|
542
540
|
:param relationship_type: The type of relationship to filter by. Valid relationship types are defined in the BusinessRelationshipType class.
|
|
543
541
|
:type relationship_type: BusinessRelationshipType
|
|
544
|
-
:return: A dictionary containing lists of current and previous company IDs that have the specified relationship with the given company_id.
|
|
545
|
-
:rtype: RelationshipResponse
|
|
542
|
+
:return: A dictionary containing lists of current and previous company IDs and names that have the specified relationship with the given company_id.
|
|
543
|
+
:rtype: RelationshipResponse
|
|
546
544
|
"""
|
|
547
545
|
url = f"{self.url_base}relationship/{company_id}/{relationship_type}"
|
|
548
|
-
|
|
549
|
-
# Try to parse as the newer RelationshipResponse and fall back to
|
|
550
|
-
# RelationshipResponseNoName if that fails.
|
|
551
|
-
try:
|
|
552
|
-
return RelationshipResponse.model_validate(result)
|
|
553
|
-
except ValidationError:
|
|
554
|
-
return RelationshipResponseNoName.model_validate(result)
|
|
546
|
+
return RelationshipResponse.model_validate(self.fetch(url))
|
|
555
547
|
|
|
556
548
|
def fetch_ticker_from_industry_code(
|
|
557
549
|
self,
|
|
@@ -589,22 +581,24 @@ class KFinanceApiClient:
|
|
|
589
581
|
url = f"{self.url_base}company_groups/industry/{industry_classification}/{industry_code}"
|
|
590
582
|
return self.fetch(url)
|
|
591
583
|
|
|
592
|
-
def fetch_earnings(self, company_id: int) ->
|
|
584
|
+
def fetch_earnings(self, company_id: int) -> EarningsCallResp:
|
|
593
585
|
"""Get the earnings for a company."""
|
|
594
586
|
url = f"{self.url_base}earnings/{company_id}"
|
|
595
|
-
return self.fetch(url)
|
|
587
|
+
return EarningsCallResp.model_validate(self.fetch(url))
|
|
596
588
|
|
|
597
589
|
def fetch_transcript(self, key_dev_id: int) -> dict:
|
|
598
590
|
"""Get the transcript for an earnings item."""
|
|
599
591
|
url = f"{self.url_base}transcript/{key_dev_id}"
|
|
600
592
|
return self.fetch(url)
|
|
601
593
|
|
|
602
|
-
def fetch_competitors(
|
|
594
|
+
def fetch_competitors(
|
|
595
|
+
self, company_id: int, competitor_source: CompetitorSource
|
|
596
|
+
) -> CompetitorResponse:
|
|
603
597
|
"""Get the competitors for a company."""
|
|
604
598
|
url = f"{self.url_base}competitors/{company_id}"
|
|
605
599
|
if competitor_source is not CompetitorSource.all:
|
|
606
600
|
url = url + f"/{competitor_source}"
|
|
607
|
-
return self.fetch(url)
|
|
601
|
+
return CompetitorResponse.model_validate(self.fetch(url))
|
|
608
602
|
|
|
609
603
|
def fetch_mergers_for_company(
|
|
610
604
|
self,
|