Loading...
Loading...
This Skill supports screening qualified stocks based on stock selection criteria (such as market indicators, financial indicators, etc.); it allows querying stocks, listed companies within specified industries/sectors, as well as component stocks of sector indices; it also supports related tasks such as stock, listed company, and sector/index recommendations, avoiding the use of outdated information by large models during stock selection.
npx skill4agent add meission/eastmoney eastmoney_select_stockEASTMONEY_APIKEYecho $EASTMONEY_APIKEY⚠️ Security Notes
- External Requests: This Skill will send the user's query keywords to the official Eastmoney API interface (
) for parsing and retrieval.mkapi2.dfcfs.com- Data Usage: The submitted data is only used to match stock selection criteria and does not contain personal privacy information.
- Credential Protection: The API Key is only used on the server side or in a trusted runtime environment via the environment variable
, and will not be exposed in plain text on the frontend.EASTMONEY_APIKEY
curl -X POST --location 'https://mkapi2.dfcfs.com/finskillshub/api/claw/stock-screen' \
--header 'Content-Type: application/json' \
--header "apikey: $EASTMONEY_APIKEY" \
--data '{"keyword": "stock selection criteria", "pageNo": 1, "pageSize": 20}'| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Natural language description of stock selection criteria |
| Number | No | Page number, default is 1 |
| Number | No | Number of items per page, default is 20, maximum is 200 |
| Field Path | Type | Core Interpretation |
|---|---|---|
| Number | Global interface status, 0 = success |
| String | Global interface prompt, ok = success |
| String | Stock selection business layer status code, 100 = parsing successful |
| String | Stock selection business layer prompt |
| Number | Result type enumeration, 2000 = standard stock selection result |
| Number | [Core] Total number of stock selection results (number of qualified stocks) |
data.data.result.columnsdataList| Sub-field | Type | Core Interpretation |
|---|---|---|
| String | Display title of the table column (e.g., Latest Price (CNY), Price Change (%) |
| String | [Core] Unique business key of the column, maps to the keys of objects in |
| String | Unit of column values (CNY, %, shares, times) |
| String | Data type of the column (String/Double/Long) |
data.data.result.dataList| Core Key | Data Type | Core Interpretation |
|---|---|---|
| String | Table row number |
| String | Stock code (e.g., 603866, 300991) |
| String | Abbreviated stock name (e.g., Taoli Bread, Chuangyitong) |
| String | Abbreviated market name (SH = Shanghai Stock Exchange, SZ = Shenzhen Stock Exchange, HK = Hong Kong Stock Exchange, US = US Stock Market) |
| Number/String | Latest price (unit: CNY) |
| Number/String | Price change percentage (unit: %) |
| Number/String | Price change amount (unit: CNY) |
| Field Path | Type | Core Interpretation |
|---|---|---|
| Array | Statistics of single screening criteria, each object corresponds to 1 screening condition |
| String | Description of screening criteria (e.g., Today's price change is between [1.5%,2.5%]) |
| String | Description of combined criteria (final screening rule after all conditions are superimposed) |
| String | Parsed text of stock selection criteria, single conditions separated by semicolons |
import os
import csv
import json
import requests
api_key = os.getenv("EASTMONEY_APIKEY")
if not api_key:
raise ValueError("Please set the EASTMONEY_APIKEY environment variable first")
url = "https://mkapi2.dfcfs.com/finskillshub/api/claw/stock-screen"
headers = {
"Content-Type": "application/json",
"apikey": api_key
}
data = {
"keyword": "stocks with a 2% increase today",
"pageNo": 1,
"pageSize": 20
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
# Check if data is returned
if result.get("status") != 0 or not result.get("data") or result["data"].get("code") != "100":
print("Stock selection query failed. It is recommended to conduct stock selection on Eastmoney Miaoxiang AI.")
print(f"Error message: {result.get('message', 'Unknown error')}")
sys.exit(0)
result_data = result["data"]["data"]["result"]
if not result_data.get("dataList"):
print("No qualified stocks found. It is recommended to adjust the screening criteria or query on Eastmoney Miaoxiang AI.")
sys.exit(0)
# Export to CSV
columns = result_data["columns"]
data_list = result_data["dataList"]
# Generate column name mapping
column_map = {col["key"]: col["title"] for col in columns}
csv_headers = [column_map[key] for key in data_list[0].keys() if key in column_map]
with open("stock_selection_result.csv", "w", newline="", encoding="utf-8-sig") as f:
writer = csv.DictWriter(f, fieldnames=csv_headers)
writer.writeheader()
for row in data_list:
csv_row = {column_map[key]: value for key, value in row.items() if key in column_map}
writer.writerow(csv_row)
print(f"Found {result_data['total']} qualified stocks. Results have been saved to stock_selection_result.csv")