-
Notifications
You must be signed in to change notification settings - Fork 54.3k
Feature/init #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/init #1236
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,7 @@ def __init__(self, rate_limit_per_minute: int = 80): | |
| self._date_list_end: Optional[str] = None # 缓存对应的截止日期,用于跨日刷新 | ||
|
|
||
| # 尝试初始化 API | ||
| self.token = '' | ||
| self._init_api() | ||
|
|
||
| # 根据 API 初始化结果动态调整优先级 | ||
|
|
@@ -163,6 +164,9 @@ def _init_api(self) -> None: | |
| if not config.tushare_token: | ||
| logger.warning("Tushare Token 未配置,此数据源不可用") | ||
| return | ||
| else: | ||
| self.token = config.tushare_token | ||
| logger.info(f"Tushare Token 配置已生效: *****{config.tushare_token[-5:]}") | ||
|
|
||
| try: | ||
| self._api = self._build_api_client(config.tushare_token) | ||
|
|
@@ -616,7 +620,7 @@ def get_stock_name(self, stock_code: str) -> Optional[str]: | |
| return name | ||
|
|
||
| except Exception as e: | ||
| logger.warning(f"Tushare 获取股票名称失败 {stock_code}: {e}") | ||
| logger.warning(f"Tushare 获取股票名称失败 {stock_code}, token: {self._api.token[-5:]}: {e}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The exception handler dereferences Useful? React with 👍 / 👎. |
||
|
|
||
| return None | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This login call now embeds a specific
user_idandpassworddirectly in source, which both leaks a credential and forces every deployment to use a single external account. If that account is rotated, locked, or rate-limited, Baostock fetching will fail globally instead of using environment-specific/default authentication behavior.Useful? React with 👍 / 👎.