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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kensho-kfinance
3
- Version: 1.2.0
3
+ Version: 1.2.2
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
@@ -12,23 +12,25 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  License-File: AUTHORS.md
15
- Requires-Dist: python-dateutil<2.9,>=2.8.2
16
- Requires-Dist: requests<3,>=2.22.0
17
- Requires-Dist: urllib3>=1.21.1
18
- Requires-Dist: pyjwt>=2.8.0
15
+ Requires-Dist: langchain-core>=0.3.15
19
16
  Requires-Dist: numpy>=1.22.4
20
17
  Requires-Dist: pandas>=2.0.0
21
- Requires-Dist: types-requests<3,>=2.22.0
22
18
  Requires-Dist: pillow>=10
23
- Requires-Dist: langchain-core>=0.3.15
19
+ Requires-Dist: pydantic<3,>=2.10.0
20
+ Requires-Dist: pyjwt>=2.8.0
21
+ Requires-Dist: python-dateutil<2.9,>=2.8.2
24
22
  Requires-Dist: strenum>=0.4.15
23
+ Requires-Dist: tabulate>=0.9.0
24
+ Requires-Dist: types-requests<3,>=2.22.0
25
+ Requires-Dist: requests<3,>=2.22.0
26
+ Requires-Dist: urllib3>=1.21.1
25
27
  Provides-Extra: dev
26
28
  Requires-Dist: coverage<8,>=7.6.10; extra == "dev"
27
29
  Requires-Dist: mypy<2,>=1.15.0; extra == "dev"
28
30
  Requires-Dist: pytest<7,>=6.1.2; extra == "dev"
29
31
  Requires-Dist: pytest-cov<7,>=6.0.0; extra == "dev"
30
- Requires-Dist: ruff<1,>=0.9.4; extra == "dev"
31
32
  Requires-Dist: requests_mock<1.2,>=1.1; extra == "dev"
33
+ Requires-Dist: ruff<1,>=0.9.4; extra == "dev"
32
34
  Dynamic: license-file
33
35
 
34
36
  # kFinance
@@ -1,10 +1,10 @@
1
- kensho_kfinance-1.2.0.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
- kensho_kfinance-1.2.0.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
- kfinance/CHANGELOG.md,sha256=rPeMYaICQiwXrL3vPgLjanjulnxVyovt27dLFqqZ_RA,443
1
+ kensho_kfinance-1.2.2.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
+ kensho_kfinance-1.2.2.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
+ kfinance/CHANGELOG.md,sha256=2s4rnko1N6MDMK38Bn0OUvhHSygSGb2XGQgM1kKEUtc,580
4
4
  kfinance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  kfinance/batch_request_handling.py,sha256=s0uXRY4CC-GnShI0i8PLPgLddRdqLyQ8jnqDKdmaZzs,5531
6
- kfinance/constants.py,sha256=SJfI3K2gS0N-M3-rHIMizcxjyTz_iWBc7UYtauUOjDg,47338
7
- kfinance/fetch.py,sha256=tDPFQQSPMAAnH8gFlT1dgERaHRfQjkW2zcUYcRFbXEY,18130
6
+ kfinance/constants.py,sha256=uopijPmpAU97l9OA_mllG2UvGHP9-zeq0UqkA7Yrk-w,47553
7
+ kfinance/fetch.py,sha256=XrkOC_5RsiI_ycRiaBbhrs1ND-gqBOknWmfIOpDSLRI,20114
8
8
  kfinance/kfinance.py,sha256=PGJzfq_AdX7IZsY4BpNuni90R6SGa6nrNLicJi_QEec,45643
9
9
  kfinance/llm_tools.py,sha256=t3i-5y34AzeFujjwOJVWY7OFI5aOAWG8rt-9KgR_0-E,30683
10
10
  kfinance/meta_classes.py,sha256=ryncusGDe48gG31a-Ldx1ApJ-ZPRFJvjC18jry7TOVE,15980
@@ -12,12 +12,12 @@ kfinance/prompt.py,sha256=PtVB8c_FcSlVdyGgByAnIFGzuUuBaEjciCqnBJl1hSQ,25133
12
12
  kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  kfinance/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdtLgA,2574
14
14
  kfinance/tool_schemas.py,sha256=JrFSbb6i2lOQaI24QqnhGhZ3e-pWLhjNqZloY9WGlnM,5643
15
- kfinance/version.py,sha256=V2bJXGFUmn_IdFy3HF4zr3V9woAW6i1X0GXwu8-ZCDs,511
15
+ kfinance/version.py,sha256=o0zEAUXpMoJZCULVYplCdjcZuIQ-3sIIZKyfNu_loQE,511
16
16
  kfinance/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  kfinance/tests/test_batch_requests.py,sha256=NsldoZqjjQpv0QKM2th80F1nru2tIF4LJeXU-RamQvA,9836
18
- kfinance/tests/test_fetch.py,sha256=gYSYDSsMUHpwwMODN0_g7kQQAEWq_jsucIRiqhBjAcA,12981
18
+ kfinance/tests/test_fetch.py,sha256=6au-TrsLbLoyvgd1vZSMlxOtXrau8ptM4tcS7vPXIzA,12088
19
19
  kfinance/tests/test_objects.py,sha256=egXkhfoK2MepZdXtrBxzWxWni7f-zVCefUbnyDnWDOE,22554
20
- kensho_kfinance-1.2.0.dist-info/METADATA,sha256=ACI6Utx34JrW1rSNX97cMyDlHq8L_rsQAh7SH9PXWB8,2869
21
- kensho_kfinance-1.2.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
22
- kensho_kfinance-1.2.0.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
23
- kensho_kfinance-1.2.0.dist-info/RECORD,,
20
+ kensho_kfinance-1.2.2.dist-info/METADATA,sha256=1OzzFZCWvGJEYcKJGURgJjgZ_awy66sdEKqxSpfpuGE,2935
21
+ kensho_kfinance-1.2.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
22
+ kensho_kfinance-1.2.2.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
23
+ kensho_kfinance-1.2.2.dist-info/RECORD,,
kfinance/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
  # Changelog
2
+
3
+ ## v1.2.2
4
+ - Add tabulate and pydantic as dependencies
5
+
6
+ ## v1.2.1
7
+ - Add fetch for industry_code, industry_classification and gics_code.
8
+
2
9
  ## v1.2.0
3
10
  - Add batch requests for iterable classes
4
11
 
kfinance/constants.py CHANGED
@@ -76,6 +76,17 @@ class LatestPeriods(TypedDict):
76
76
  now: CurrentPeriod
77
77
 
78
78
 
79
+ class IndustryClassification(StrEnum):
80
+ sic = "sic"
81
+ naics = "naics"
82
+ nace = "nace"
83
+ anzsic = "anzsic"
84
+ spcapiqetf = "spcapiqetf"
85
+ spratings = "spratings"
86
+ gics = "gics"
87
+ simple = "simple"
88
+
89
+
79
90
  # all of these values must be lower case keys
80
91
  LINE_ITEMS: list[LineItemType] = [
81
92
  {
kfinance/fetch.py CHANGED
@@ -7,7 +7,7 @@ from uuid import uuid4
7
7
  import jwt
8
8
  import requests
9
9
 
10
- from .constants import BusinessRelationshipType, IdentificationTriple
10
+ from .constants import BusinessRelationshipType, IdentificationTriple, IndustryClassification
11
11
 
12
12
 
13
13
  # version.py gets autogenerated by setuptools-scm and is not available
@@ -368,26 +368,6 @@ class KFinanceApiClient:
368
368
  country_iso_code=country_iso_code, state_iso_code=state_iso_code, fetch_ticker=False
369
369
  )
370
370
 
371
- def fetch_simple_industry_groups(
372
- self, simple_industry: str, fetch_ticker: bool = True
373
- ) -> dict[str, list]:
374
- """Fetch simple industry groups"""
375
- url = f"{self.url_base}{'ticker_groups' if fetch_ticker else 'company_groups'}/industry/simple/{simple_industry}"
376
- return self.fetch(url)
377
-
378
- def fetch_ticker_simple_industry_groups(
379
- self, simple_industry: str
380
- ) -> dict[str, list[IdentificationTriple]]:
381
- """Fetch ticker simple industry groups"""
382
- return self.fetch_simple_industry_groups(simple_industry=simple_industry, fetch_ticker=True)
383
-
384
- def fetch_company_simple_industry_groups(self, simple_industry: str) -> dict[str, list[int]]:
385
- """Fetch company simple industry groups"""
386
- return self.fetch_simple_industry_groups(
387
- simple_industry=simple_industry,
388
- fetch_ticker=False,
389
- )
390
-
391
371
  def fetch_exchange_groups(
392
372
  self, exchange_code: str, fetch_ticker: bool = True
393
373
  ) -> dict[str, list]:
@@ -456,3 +436,56 @@ class KFinanceApiClient:
456
436
  """
457
437
  url = f"{self.url_base}relationship/{company_id}/{relationship_type}"
458
438
  return self.fetch(url)
439
+
440
+ def fetch_from_industry_code(
441
+ self,
442
+ industry_code: str,
443
+ industry_classification: IndustryClassification,
444
+ fetch_ticker: bool = True,
445
+ ) -> dict[str, list]:
446
+ """Fetches a list of companies or identification triples that are classified in the given industry_code and industry_classification."""
447
+
448
+ url = f"{self.url_base}{'ticker_groups' if fetch_ticker else 'company_groups'}/industry/{industry_classification}/{industry_code}"
449
+ return self.fetch(url)
450
+
451
+ def fetch_ticker_from_industry_code(
452
+ self,
453
+ industry_code: str,
454
+ industry_classification: IndustryClassification,
455
+ ) -> dict[str, list[IdentificationTriple]]:
456
+ """Fetches a list of identification triples that are classified in the given industry_code and industry_classification.
457
+
458
+ Returns a dictionary of shape {"tickers": List[{“company_id”: <company_id>, “security_id”: <security_id>, “trading_item_id”: <trading_item_id>}]}.
459
+ :param industry_code: The industry_code to filter on. The industry_code is a string corresponding to the Industry classifications ontology.
460
+ :type industry_code: str
461
+ :param industry_classification: The type of industry_classification to filter on.
462
+ :type industry_classification: IndustryClassification
463
+ :return: A dictionary containing the list of identification triple [company_id, security_id, trading_item_id] that are classified in the given industry_code and industry_classification.
464
+ :rtype: dict[str, list[IdentificationTriple]]
465
+ """
466
+ return self.fetch_from_industry_code(
467
+ industry_code=industry_code,
468
+ industry_classification=industry_classification,
469
+ fetch_ticker=True,
470
+ )
471
+
472
+ def fetch_company_from_industry_code(
473
+ self,
474
+ industry_code: str,
475
+ industry_classification: IndustryClassification,
476
+ ) -> dict[str, list[int]]:
477
+ """Fetches a list of companies that are classified in the given industry_code and industry_classification.
478
+
479
+ Returns a dictionary of shape {"companies": List[<company_id>]}.
480
+ :param industry_code: The industry_code to filter on. The industry_code is a string corresponding to the Industry classifications ontology.
481
+ :type industry_code: str
482
+ :param industry_classification: The type of industry_classification to filter on.
483
+ :type industry_classification: IndustryClassification
484
+ :return: A dictionary containing the list of companies that are classified in the given industry_code and industry_classification.
485
+ :rtype: dict[str, list[int]]
486
+ """
487
+ return self.fetch_from_industry_code(
488
+ industry_code=industry_code,
489
+ industry_classification=industry_classification,
490
+ fetch_ticker=False,
491
+ )
@@ -157,26 +157,6 @@ class TestFetchItem(TestCase):
157
157
  )
158
158
  self.kfinance_api_client.fetch.assert_called_with(expected_fetch_url)
159
159
 
160
- def test_fetch_ticker_industry_simple_groups(self) -> None:
161
- simple_industry = "media"
162
- expected_fetch_url = (
163
- f"{self.kfinance_api_client.url_base}ticker_groups/industry/simple/{simple_industry}"
164
- )
165
- self.kfinance_api_client.fetch_ticker_simple_industry_groups(
166
- simple_industry=simple_industry
167
- )
168
- self.kfinance_api_client.fetch.assert_called_once_with(expected_fetch_url)
169
-
170
- def test_fetch_company_industry_simple_groups(self) -> None:
171
- simple_industry = "media"
172
- expected_fetch_url = (
173
- f"{self.kfinance_api_client.url_base}company_groups/industry/simple/{simple_industry}"
174
- )
175
- self.kfinance_api_client.fetch_company_simple_industry_groups(
176
- simple_industry=simple_industry
177
- )
178
- self.kfinance_api_client.fetch.assert_called_once_with(expected_fetch_url)
179
-
180
160
  def test_fetch_ticker_exchange_groups(self) -> None:
181
161
  exchange_code = "NYSE"
182
162
  expected_fetch_url = (
kfinance/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.2.0'
21
- __version_tuple__ = version_tuple = (1, 2, 0)
20
+ __version__ = version = '1.2.2'
21
+ __version_tuple__ = version_tuple = (1, 2, 2)