33# pylint: disable=unused-argument
44
55from typing import Any , Dict , List , Optional
6- from datetime import date as dateType
6+ from datetime import ( date as dateType , datetime )
77
88from openbb_core .provider .abstract .fetcher import Fetcher
99from openbb_core .provider .standard_models .equity_info import (
@@ -29,10 +29,12 @@ class AKShareEquityProfileData(EquityInfoData):
2929 """AKShare Equity Profile Data."""
3030
3131 __alias_dict__ = {
32+ "公司名称" : "org_name_cn" ,
33+ "公司简介" : "org_cn_introduction" ,
34+ "主要范围" : "main_operation_business" ,
35+ "成立日期" : "established_date" ,
36+ "上市日期" : "listed_date" ,
3237 "name" : "org_name_en" ,
33- "org_short_name_cn" : "quoteType" ,
34- "short_description" : "main_operation_business" ,
35- "long_description" : "org_cn_introduction" ,
3638 "ceo" : "chairman" ,
3739 "company_url" : "org_website" ,
3840 "business_address" : "reg_address_cn" ,
@@ -43,9 +45,23 @@ class AKShareEquityProfileData(EquityInfoData):
4345 "employees" : "staff_num" ,
4446 "sector" : "affiliate_industry" ,
4547 "industry_category" : "operating_scope" ,
46- "first_stock_price_date" : "listed_date" ,
4748 }
4849
50+ 公司名称 : Optional [str ] = Field (
51+ description = "Alias of org_name_cn." ,
52+ default = None ,
53+ )
54+ 公司简介 : Optional [str ] = Field (
55+ description = "Alias of org_name_cn." ,
56+ default = None ,
57+ )
58+ 主要范围 : Optional [str ] = Field (
59+ description = "Alias of org_name_cn." ,
60+ default = None ,
61+ )
62+ 上市日期 : Optional [dateType | None ] = Field (
63+ default = None , description = "Date of the establishment."
64+ )
4965 org_name_cn : Optional [str ] = Field (
5066 description = "Chinese name of the asset." ,
5167 default = None ,
@@ -62,7 +78,7 @@ class AKShareEquityProfileData(EquityInfoData):
6278 description = "The number of listed shares outstanding." ,
6379 default = None ,
6480 )
65- established_date : Optional [dateType ] = Field (
81+ established_date : Optional [dateType | None ] = Field (
6682 default = None , description = "Date of the establishment."
6783 )
6884 actual_issue_vol : Optional [int ] = Field (
@@ -107,16 +123,20 @@ def validate_established_date(cls, v):
107123 # pylint: disable=import-outside-toplevel
108124 from datetime import timezone # noqa
109125 from openbb_core .provider .utils .helpers import safe_fromtimestamp # noqa
126+ if pd .isna (v ):
127+ return None
110128
111129 return safe_fromtimestamp (get_timestamp (v ), tz = timezone .utc ).date () if v else None
112130
113- @field_validator ("first_stock_price_date " , mode = "before" , check_fields = False )
131+ @field_validator ("上市日期 " , mode = "before" , check_fields = False )
114132 @classmethod
115133 def validate_first_trade_date (cls , v ):
116134 """Validate first stock price date."""
117135 # pylint: disable=import-outside-toplevel
118136 from datetime import timezone # noqa
119137 from openbb_core .provider .utils .helpers import safe_fromtimestamp # noqa
138+ if pd .isna (v ):
139+ return None
120140
121141 return safe_fromtimestamp (get_timestamp (v ), tz = timezone .utc ).date () if v else None
122142
@@ -144,24 +164,26 @@ async def aextract_data(
144164 from openbb_core .provider .utils .errors import EmptyDataError
145165 from warnings import warn
146166
167+ api_key = credentials .get ("akshare_api_key" ) if credentials else ""
168+
147169 symbols = query .symbol .split ("," )
148170 results = []
149171 messages : list = []
150172
151- async def get_one (symbol ):
173+ async def get_one (symbol , api_key : str , use_cache : bool = True ):
152174 from openbb_akshare .utils .fetch_equity_info import fetch_equity_info
153175 """Get the data for one ticker symbol."""
154176 try :
155177 result : dict = {}
156- result = fetch_equity_info (symbol ).to_dict (orient = "records" )[0 ]
178+ result = fetch_equity_info (symbol , api_key = api_key , use_cache = use_cache ).to_dict (orient = "records" )[0 ]
157179 if result :
158180 results .append (result )
159181 except Exception as e :
160182 messages .append (
161183 f"Error getting data for { symbol } -> { e .__class__ .__name__ } : { e } "
162184 )
163185
164- tasks = [get_one (symbol ) for symbol in symbols ]
186+ tasks = [get_one (symbol , api_key = api_key , use_cache = query . use_cache ) for symbol in symbols ]
165187
166188 await asyncio .gather (* tasks )
167189
0 commit comments