eastmoney_select_stock

Original🇨🇳 Chinese
Translated
1 scriptsChecked / no sensitive code detected

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.

2installs
Added on

NPX Install

npx skill4agent add meission/eastmoney eastmoney_select_stock

SKILL.md Content (Chinese)

View Translation Comparison →

Eastmoney Intelligent Stock Selection Skill (eastmoney_select_stock)

Stock selection via natural language query (supported markets: A-shares, Hong Kong stocks, US stocks), returns a list of qualified stocks, which can be automatically exported as a CSV file.

Usage

  1. First check if the environment variable
    EASTMONEY_APIKEY
    exists:
    bash
    echo $EASTMONEY_APIKEY
    If it does not exist, prompt the user to obtain the apikey on the Eastmoney Skills page (https://marketing.dfcfs.com/views/finskillshub/indexuNdYscEA?appfenxiang=1) and set it as an environment variable.
    ⚠️ Security Notes
    • External Requests: This Skill will send the user's query keywords to the official Eastmoney API interface (
      mkapi2.dfcfs.com
      ) for parsing and retrieval.
    • 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
      EASTMONEY_APIKEY
      , and will not be exposed in plain text on the frontend.
  2. Call the interface using a POST request:
    bash
    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}'

Applicable Scenarios

Use this Skill when users query the following types of content:
  • Conditional stock selection: e.g., "stocks with a 2% increase today", "bank stocks with a price-to-earnings ratio below 10", "tech stocks that have risen for 3 consecutive days"
  • Sector/industry component stocks: e.g., "component stocks of the semiconductor sector", "listed companies in the new energy industry"
  • Index component stocks: e.g., "CSI 300 component stocks", "STAR Market 50 component stock list"
  • Stock recommendations: e.g., "recommendations for undervalued high-dividend stocks", "stocks with recent main capital inflow"
  • Market screening: e.g., "Hong Kong Stock Connect target stocks", "list of US-listed Chinese concept stocks"

Request Parameter Description

ParameterTypeRequiredDescription
keyword
StringYesNatural language description of stock selection criteria
pageNo
NumberNoPage number, default is 1
pageSize
NumberNoNumber of items per page, default is 20, maximum is 200

Interface Result Interpretation

1. Top-level Core Status/Statistics Fields

Field PathTypeCore Interpretation
status
NumberGlobal interface status, 0 = success
message
StringGlobal interface prompt, ok = success
data.code
StringStock selection business layer status code, 100 = parsing successful
data.msg
StringStock selection business layer prompt
data.data.resultType
NumberResult type enumeration, 2000 = standard stock selection result
data.data.result.total
Number[Core] Total number of stock selection results (number of qualified stocks)

2.1 Column Definition:
data.data.result.columns
(Array)

Core function: Defines the display rules for each column of the table, which maps one-to-one with the row data keys in
dataList
.
Sub-fieldTypeCore Interpretation
title
StringDisplay title of the table column (e.g., Latest Price (CNY), Price Change (%)
key
String[Core] Unique business key of the column, maps to the keys of objects in
dataList
unit
StringUnit of column values (CNY, %, shares, times)
dataType
StringData type of the column (String/Double/Long)

2.2 Row Data:
data.data.result.dataList
(Array)

Core function: Specific stock data of stock selection results, each object corresponds to one qualified stock.
Core KeyData TypeCore Interpretation
SERIAL
StringTable row number
SECURITY_CODE
StringStock code (e.g., 603866, 300991)
SECURITY_SHORT_NAME
StringAbbreviated stock name (e.g., Taoli Bread, Chuangyitong)
MARKET_SHORT_NAME
StringAbbreviated market name (SH = Shanghai Stock Exchange, SZ = Shenzhen Stock Exchange, HK = Hong Kong Stock Exchange, US = US Stock Market)
NEWEST_PRICE
Number/StringLatest price (unit: CNY)
CHG
Number/StringPrice change percentage (unit: %)
PCHG
Number/StringPrice change amount (unit: CNY)

3. Stock Selection Criteria Description

Field PathTypeCore Interpretation
data.data.responseConditionList
ArrayStatistics of single screening criteria, each object corresponds to 1 screening condition
data.data.responseConditionList[].describe
StringDescription of screening criteria (e.g., Today's price change is between [1.5%,2.5%])
data.data.totalCondition.describe
StringDescription of combined criteria (final screening rule after all conditions are superimposed)
data.data.parserText
StringParsed text of stock selection criteria, single conditions separated by semicolons

Example

python
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")

Exception Handling

  • If no data results are returned, prompt the user to conduct stock selection on Eastmoney Miaoxiang AI
  • If the request fails, check if the API Key is correct and if the network is normal
  • It is recommended that the pageSize for a single query does not exceed 200 to avoid excessive data volume