Use this skill to create or improve a sanitized Python wrapper around Eastmoney web trading. Prioritize safety, reproducibility, and public-release hygiene: credentials must come from environment variables, order submission must default to dry-run, and logs/docs must not expose account IDs, cookies, validatekeys, or passwords.
Order objects; callers decide whether to submit.Use this structure for a clean public project:
dddd-trade-api/
├── .env.example
├── .gitignore
├── LICENSE
├── README.md
├── pyproject.toml
├── examples/
│ └── basic_usage.py
├── src/
│ └── eastmoney_trade_api/
│ ├── __init__.py
│ ├── cli.py
│ ├── client.py
│ ├── models.py
│ ├── settings.py
│ └── strategy.py
└── tests/
└── test_models.py
Keep the Python import package as eastmoney_trade_api even when the repository or distribution name is dddd-trade-api; the import name is clearer for users.
.env or environment variables only..env, logs, exported holdings, Excel/CSV files, and browser profiles to .gitignore.mask_secret() and mask_cookie_header().dry_run=True by default in constructors, CLI examples, tests, and README snippets.--live-trade before calling the real SubmitTradeV2 endpoint.Implement browser-backed login with DrissionPage, then capture validatekey and cookies from the position query request. Use them only for the current runtime session.
Core methods:
start() opens https://jywg.18.cn/.login() fills account/password, handles captcha, and detects login success.query_positions() listens for Com/queryAssetAndPositionV1?validatekey, returns a DataFrame, and stores an AuthSession.submit_order(order) returns payload when dry-run is enabled; otherwise POSTs to Trade/SubmitTradeV2?validatekey=....Use Eastmoney payload fields:
{
"stockCode": "510300",
"price": "3.5",
"amount": "100",
"tradeType": "B",
"zqmc": "沪深300ETF",
"market": "HA",
}
When converting a private trading strategy:
client.py.models.py.strategy.py..[strategy].For convertible-bond or ETF strategies, normalize raw Eastmoney position rows first, classify security types by code prefix, then generate Order objects.
README should include:
.env.example usage.When including proof screenshots, ensure all money amounts, account names, IDs, and personal details are masked.
Before publishing or pushing:
rg -n --hidden -g '!.git' 'password|passwd|cookie|token|secret|validatekey|资金账号|交易密码|手机号|用户名|密码' .
rg -n --hidden -g '!.git' '[0-9]{11,}|[0-9]{6}' .
git grep -n -I -E 'password|cookie|token|secret|validatekey|资金账号|交易密码' HEAD
Review all hits manually. Field names and placeholders are acceptable; real values are not.
Read references/release-checklist.md when preparing a repository for public GitHub release or SkillHub upload.
共 1 个版本