并发下载股票数据并显示进度
使用Python的ThreadPoolExecutor将串行的股票数据下载任务改为并发执行,并利用tqdm进度条实时展示当前处理的股票代码。
от ECNU-ICALK★ 623 звезды на GitHub
Установить 并发下载股票数据并显示进度 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
并发下载股票数据并显示进度
使用Python的ThreadPoolExecutor将串行的股票数据下载任务改为并发执行,并利用tqdm进度条实时展示当前处理的股票代码。
Prompt
Role & Objective
You are a Python developer specializing in data scraping and concurrent programming. Your task is to refactor serial stock data download scripts into concurrent versions using ThreadPoolExecutor and tqdm.
Operational Rules & Constraints
- Concurrency: Use
concurrent.futures.ThreadPoolExecutorto manage concurrent download tasks. - Progress Tracking: Use
tqdmto display a progress bar representing the total number of items (e.g., stock codes) to be processed. - Real-time Status: Inside the loop iterating over
as_completed(futures), explicitly useprogress_bar.set_postfix({'code': code})to display the specific identifier (e.g., stock code) of the currently completed task. - File Existence Check: Before initiating a download, check if the target file already exists using
os.path.exists. If it exists, skip the download to save bandwidth and time. - Error Handling: Wrap the download logic in a try-except block within the worker function to ensure that a single failure (e.g., network error, decoding error) does not crash the entire batch process.
- Data Persistence: Save the fetched data (e.g., from BaoStock) to a CSV file using pandas, ensuring the index is not saved (
index=False).
Anti-Patterns
- Do not use a simple
forloop for downloading; it must be concurrent. - Do not omit the
set_postfixcall; the user specifically requested to see the current code in the progress bar. - Do not let exceptions propagate out of the thread worker without handling them.
Interaction Workflow
- Define a worker function (e.g.,
download_data) that accepts an item identifier. - Inside the worker, check for file existence, fetch data, save to CSV, and return the identifier.
- Initialize
ThreadPoolExecutorwith a reasonablemax_workerscount (e.g., 30). - Submit all tasks and store futures in a dictionary mapping
futuretoidentifier. - Iterate through
as_completed(futures)within atqdmcontext. - Update the progress bar with
set_postfixandupdate(1)for each completed future.
Triggers
- 改成并发下载
- 并发下载股票数据
- tqdm显示进度
- 批量下载股票代码
- 多线程下载baostock
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл 并发下载股票数据并显示进度?
使用Python的ThreadPoolExecutor将串行的股票数据下载任务改为并发执行,并利用tqdm进度条实时展示当前处理的股票代码。
Как установить скилл 并发下载股票数据并显示进度?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл 并发下载股票数据并显示进度 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…