kensho-kfinance 2.9.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.9.0.dist-info → kensho_kfinance-3.0.0.dist-info}/METADATA +1 -1
- kensho_kfinance-3.0.0.dist-info/RECORD +110 -0
- kfinance/CHANGELOG.md +3 -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} +37 -33
- 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 +33 -29
- 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.9.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 -42
- 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 -69
- kfinance/tool_calling/get_mergers_from_identifier.py +0 -44
- 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.9.0.dist-info → kensho_kfinance-3.0.0.dist-info}/WHEEL +0 -0
- {kensho_kfinance-2.9.0.dist-info → kensho_kfinance-3.0.0.dist-info}/licenses/AUTHORS.md +0 -0
- {kensho_kfinance-2.9.0.dist-info → kensho_kfinance-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {kensho_kfinance-2.9.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
|
|
@@ -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,
|
|
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from collections.abc import Sequence
|
|
4
4
|
from concurrent.futures import ThreadPoolExecutor
|
|
5
|
-
from copy import deepcopy
|
|
6
5
|
from datetime import date, datetime, timezone
|
|
7
6
|
from io import BytesIO
|
|
8
7
|
import logging
|
|
@@ -18,29 +17,32 @@ from langchain_google_genai._function_utils import convert_to_genai_function_dec
|
|
|
18
17
|
import pandas as pd
|
|
19
18
|
from PIL.Image import Image, open as image_open
|
|
20
19
|
|
|
21
|
-
from kfinance.batch_request_handling import add_methods_of_singular_class_to_iterable_class
|
|
22
|
-
from kfinance.fetch import (
|
|
20
|
+
from kfinance.client.batch_request_handling import add_methods_of_singular_class_to_iterable_class
|
|
21
|
+
from kfinance.client.fetch import (
|
|
23
22
|
DEFAULT_API_HOST,
|
|
24
23
|
DEFAULT_API_VERSION,
|
|
25
24
|
DEFAULT_OKTA_AUTH_SERVER,
|
|
26
25
|
DEFAULT_OKTA_HOST,
|
|
27
26
|
KFinanceApiClient,
|
|
28
27
|
)
|
|
29
|
-
from kfinance.
|
|
28
|
+
from kfinance.client.industry_models import IndustryClassification
|
|
29
|
+
from kfinance.client.meta_classes import (
|
|
30
30
|
CompanyFunctionsMetaClass,
|
|
31
31
|
DelegatedCompanyFunctionsMetaClass,
|
|
32
32
|
)
|
|
33
|
-
from kfinance.models.date_and_period_models import
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
from kfinance.
|
|
39
|
-
from kfinance.
|
|
33
|
+
from kfinance.client.models.date_and_period_models import (
|
|
34
|
+
LatestPeriods,
|
|
35
|
+
Periodicity,
|
|
36
|
+
YearAndQuarter,
|
|
37
|
+
)
|
|
38
|
+
from kfinance.client.server_thread import ServerThread
|
|
39
|
+
from kfinance.domains.companies.company_models import IdentificationTriple
|
|
40
|
+
from kfinance.domains.earnings.earning_models import EarningsCall, TranscriptComponent
|
|
41
|
+
from kfinance.domains.prices.price_models import HistoryMetadata, PriceHistory
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
if TYPE_CHECKING:
|
|
43
|
-
from kfinance.tool_calling.
|
|
45
|
+
from kfinance.integrations.tool_calling.tool_calling_models import KfinanceTool
|
|
44
46
|
|
|
45
47
|
logger = logging.getLogger(__name__)
|
|
46
48
|
|
|
@@ -266,6 +268,19 @@ class Earnings:
|
|
|
266
268
|
self.key_dev_id = key_dev_id
|
|
267
269
|
self._transcript: Transcript | None = None
|
|
268
270
|
|
|
271
|
+
@classmethod
|
|
272
|
+
def from_earnings_call(
|
|
273
|
+
cls, earnings_call: EarningsCall, kfinance_api_client: KFinanceApiClient
|
|
274
|
+
) -> "Earnings":
|
|
275
|
+
"""Generate an Earnings object from an EarningsCall pydantic model."""
|
|
276
|
+
|
|
277
|
+
return Earnings(
|
|
278
|
+
name=earnings_call.name,
|
|
279
|
+
datetime=earnings_call.datetime,
|
|
280
|
+
key_dev_id=earnings_call.key_dev_id,
|
|
281
|
+
kfinance_api_client=kfinance_api_client,
|
|
282
|
+
)
|
|
283
|
+
|
|
269
284
|
def __str__(self) -> str:
|
|
270
285
|
"""String representation for the earnings object"""
|
|
271
286
|
return f"{type(self).__module__}.{type(self).__qualname__} of {self.key_dev_id}"
|
|
@@ -513,24 +528,13 @@ class Company(CompanyFunctionsMetaClass):
|
|
|
513
528
|
return self._all_earnings
|
|
514
529
|
|
|
515
530
|
earnings_data = self.kfinance_api_client.fetch_earnings(self.company_id)
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
earnings["key_dev_id"] = deepcopy(earnings["keydevid"])
|
|
521
|
-
del earnings["keydevid"]
|
|
522
|
-
earnings_datetime = datetime.fromisoformat(
|
|
523
|
-
earnings["datetime"].replace("Z", "+00:00")
|
|
524
|
-
).replace(tzinfo=timezone.utc)
|
|
525
|
-
|
|
526
|
-
self._all_earnings.append(
|
|
527
|
-
Earnings(
|
|
528
|
-
kfinance_api_client=self.kfinance_api_client,
|
|
529
|
-
name=earnings["name"],
|
|
530
|
-
datetime=earnings_datetime,
|
|
531
|
-
key_dev_id=earnings["key_dev_id"],
|
|
532
|
-
)
|
|
531
|
+
|
|
532
|
+
self._all_earnings = [
|
|
533
|
+
Earnings.from_earnings_call(
|
|
534
|
+
earnings_call=earnings_call, kfinance_api_client=self.kfinance_api_client
|
|
533
535
|
)
|
|
536
|
+
for earnings_call in earnings_data.earnings_calls
|
|
537
|
+
]
|
|
534
538
|
|
|
535
539
|
return self._all_earnings
|
|
536
540
|
|
|
@@ -1398,6 +1402,7 @@ class Securities(set):
|
|
|
1398
1402
|
:param security_ids: An iterable of S&P CIQ Security ids
|
|
1399
1403
|
:type security_ids: Iterable[int]
|
|
1400
1404
|
"""
|
|
1405
|
+
self.kfinance_api_client = kfinance_api_client
|
|
1401
1406
|
super().__init__(Security(kfinance_api_client, security_id) for security_id in security_ids)
|
|
1402
1407
|
|
|
1403
1408
|
|
|
@@ -1541,8 +1546,6 @@ class Client:
|
|
|
1541
1546
|
:type openai_tool_descriptions: list[dict]
|
|
1542
1547
|
"""
|
|
1543
1548
|
|
|
1544
|
-
prompt = PROMPT
|
|
1545
|
-
|
|
1546
1549
|
def __init__(
|
|
1547
1550
|
self,
|
|
1548
1551
|
refresh_token: Optional[str] = None,
|
|
@@ -1622,9 +1625,10 @@ class Client:
|
|
|
1622
1625
|
@property
|
|
1623
1626
|
def langchain_tools(self) -> list["KfinanceTool"]:
|
|
1624
1627
|
"""Return a list of all Kfinance tools for tool calling."""
|
|
1625
|
-
if self._tools is None:
|
|
1626
|
-
from kfinance.tool_calling import ALL_TOOLS
|
|
1627
1628
|
|
|
1629
|
+
from kfinance.integrations.tool_calling.all_tools import ALL_TOOLS
|
|
1630
|
+
|
|
1631
|
+
if self._tools is None:
|
|
1628
1632
|
self._tools = []
|
|
1629
1633
|
# Add tool to _tools if the user has permissions to use it.
|
|
1630
1634
|
for tool_cls in ALL_TOOLS:
|
|
@@ -7,14 +7,15 @@ from cachetools import LRUCache, cached
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import pandas as pd
|
|
9
9
|
|
|
10
|
-
from .fetch import KFinanceApiClient
|
|
11
|
-
from .models.
|
|
12
|
-
from .
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
from .
|
|
16
|
-
from .
|
|
17
|
-
from .
|
|
10
|
+
from kfinance.client.fetch import KFinanceApiClient
|
|
11
|
+
from kfinance.client.models.date_and_period_models import PeriodType
|
|
12
|
+
from kfinance.domains.business_relationships.business_relationship_models import (
|
|
13
|
+
BusinessRelationshipType,
|
|
14
|
+
)
|
|
15
|
+
from kfinance.domains.capitalizations.capitalization_models import Capitalization
|
|
16
|
+
from kfinance.domains.competitors.competitor_models import CompetitorSource
|
|
17
|
+
from kfinance.domains.line_items.line_item_models import LINE_ITEMS
|
|
18
|
+
from kfinance.domains.segments.segment_models import SegmentType
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
if TYPE_CHECKING:
|
|
@@ -234,28 +235,16 @@ class CompanyFunctionsMetaClass:
|
|
|
234
235
|
company_id=self.company_id,
|
|
235
236
|
relationship_type=relationship_type,
|
|
236
237
|
)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
)
|
|
248
|
-
else:
|
|
249
|
-
return BusinessRelationships(
|
|
250
|
-
current=Companies(
|
|
251
|
-
kfinance_api_client=self.kfinance_api_client,
|
|
252
|
-
company_ids=relationship_resp.current,
|
|
253
|
-
),
|
|
254
|
-
previous=Companies(
|
|
255
|
-
kfinance_api_client=self.kfinance_api_client,
|
|
256
|
-
company_ids=relationship_resp.previous,
|
|
257
|
-
),
|
|
258
|
-
)
|
|
238
|
+
return BusinessRelationships(
|
|
239
|
+
current=Companies(
|
|
240
|
+
kfinance_api_client=self.kfinance_api_client,
|
|
241
|
+
company_ids=[c.company_id for c in relationship_resp.current],
|
|
242
|
+
),
|
|
243
|
+
previous=Companies(
|
|
244
|
+
kfinance_api_client=self.kfinance_api_client,
|
|
245
|
+
company_ids=[c.company_id for c in relationship_resp.previous],
|
|
246
|
+
),
|
|
247
|
+
)
|
|
259
248
|
|
|
260
249
|
def market_cap(
|
|
261
250
|
self,
|
|
@@ -329,7 +318,9 @@ class CompanyFunctionsMetaClass:
|
|
|
329
318
|
capitalizations = self.kfinance_api_client.fetch_market_caps_tevs_and_shares_outstanding(
|
|
330
319
|
company_id=self.company_id, start_date=start_date, end_date=end_date
|
|
331
320
|
)
|
|
332
|
-
return capitalizations.
|
|
321
|
+
return capitalizations.model_dump_json_single_metric(
|
|
322
|
+
capitalization_metric=capitalization_to_extract
|
|
323
|
+
)
|
|
333
324
|
|
|
334
325
|
def _segments(
|
|
335
326
|
self,
|
|
@@ -437,16 +428,16 @@ class CompanyFunctionsMetaClass:
|
|
|
437
428
|
|
|
438
429
|
competitors_data = self.kfinance_api_client.fetch_competitors(
|
|
439
430
|
company_id=self.company_id, competitor_source=competitor_source
|
|
440
|
-
)
|
|
431
|
+
)
|
|
441
432
|
return Companies(
|
|
442
433
|
kfinance_api_client=self.kfinance_api_client,
|
|
443
434
|
companies=[
|
|
444
435
|
Company(
|
|
445
436
|
kfinance_api_client=self.kfinance_api_client,
|
|
446
|
-
company_id=company
|
|
447
|
-
company_name=company
|
|
437
|
+
company_id=company.company_id,
|
|
438
|
+
company_name=company.company_name,
|
|
448
439
|
)
|
|
449
|
-
for company in competitors_data
|
|
440
|
+
for company in competitors_data.competitors
|
|
450
441
|
],
|
|
451
442
|
)
|
|
452
443
|
|
|
@@ -5,7 +5,7 @@ from typing import Any
|
|
|
5
5
|
from pydantic import BaseModel, Field, model_validator
|
|
6
6
|
from typing_extensions import Self
|
|
7
7
|
|
|
8
|
-
from kfinance.models.currency_models import ISO_CODE_TO_CURRENCY
|
|
8
|
+
from kfinance.client.models.currency_models import ISO_CODE_TO_CURRENCY
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class DecimalWithUnit(BaseModel):
|
|
File without changes
|
|
@@ -9,16 +9,18 @@ import pytest
|
|
|
9
9
|
import requests
|
|
10
10
|
import requests_mock
|
|
11
11
|
|
|
12
|
-
from kfinance.batch_request_handling import MAX_WORKERS_CAP
|
|
13
|
-
from kfinance.
|
|
14
|
-
from kfinance.
|
|
15
|
-
from kfinance.
|
|
16
|
-
from kfinance.
|
|
12
|
+
from kfinance.client.batch_request_handling import MAX_WORKERS_CAP
|
|
13
|
+
from kfinance.client.fetch import KFinanceApiClient
|
|
14
|
+
from kfinance.client.kfinance import Companies, Company, Ticker, TradingItem, TradingItems
|
|
15
|
+
from kfinance.client.models.decimal_with_unit import Money, Shares
|
|
16
|
+
from kfinance.domains.prices.price_models import PriceHistory, Prices
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@pytest.fixture(autouse=True)
|
|
20
20
|
def mock_method():
|
|
21
|
-
with patch(
|
|
21
|
+
with patch(
|
|
22
|
+
"kfinance.client.fetch.KFinanceApiClient.access_token", return_value="fake_access_token"
|
|
23
|
+
):
|
|
22
24
|
yield
|
|
23
25
|
|
|
24
26
|
|