Record the user's buy and sell operations, and update positions and trade records.
How to Use
The user will tell you today's trading situation, possibly in the following forms:
- "Bought xxx today"
- "Sold xxx"
- "No operations today"
- "Added to position in xxx"
Execution Steps
Step 1: Confirm trade information
Confirm the following information with the user (if the user has not provided complete information):
- Ticker symbol and name
- Operation type (buy/sell/add to position/reduce position)
- Execution price
- Execution quantity
- Decision rationale (why this operation was made)
Step 2: Verify price authenticity (core step)
Must verify whether the price provided by the user is reasonable
Run the data retrieval script to get the real-time/latest price of the instrument:
cd "股市信息" && python3 scripts/fetch_market_data.py
Script output includes:
holdings: Current position quotes (if it is a trade for an existing position)- Can be used to verify the price provided by the user
Must strictly comply:
- Wait for the script execution to complete
- Use the price from the script JSON outputto verify
- The deviation between the execution price provided by the user and the current price should not exceed 5% (accounting for intraday fluctuations)
- If the deviation is too large, confirm with the user whether there is an input error
- If the script fails, inform the user; it does not affect the trade record (use the price provided by the user)
Step 3: Update trade record
Append the trade record to 股市信息/Records/trades.md, format:
### YYYY-MM-DD
#### 操作N:[操作类型][标的名称]
| 项目 | 内容 |
|------|------|
| 标的 | 代码 名称 |
| 操作 | **买入/卖出/加仓/减仓** |
| 成本/卖出价 | X.XX |
| 数量 | XXXX份/股 |
| 金额 | XXXX元 |
| 盈亏 | (卖出时填写)+/-XX% (约XXXX元) |
| **决策理由** | 用户说明的理由 |
| **当时建议** | 简报中的相关建议(如有) |
| 验证时点 | 30天后日期 / 90天后日期 |
| 验证标准 | 用什么标准判断这次操作对不对 |
Step 4: Update position details
Update according to the operation type 股市信息/Config/Holdings.md:
Buy/add to position:
- New instrument: add a new row
- Existing instrument: update cost price (weighted average), position quantity, position %
Sell/reduce position:
- Sell all: delete the row
- Partial sell: update position quantity, position % (cost price unchanged)
Cost price calculation formula (when adding to position):
新成本价 = (原成本价 × 原数量 + 新买入价 × 新数量) / (原数量 + 新数量)
Step 5: Link to briefing recommendations
Read the most recent briefing file (股市信息/Daily/), find the relevant operation recommendations, and record:
- Whether the briefing recommended this operation
- Whether the user executed according to the recommendation
- If the user did not execute according to the recommendation, record the user's independent judgment rationale
Step 6: Confirm and summarize
Confirm with the user:
- Trade record has been saved
- Position has been updated
- Display the updated position overview
- Remind of the verification time point
Step 7: Update user insights (Insight.md)
Read and update 股市信息/Config/Insight.md:
-
Check recommendation adoption status:
- Whether this trade corresponds to a previous briefing/investment committee recommendation
- If yes, record it in the "adoption record" table
- Update the adoption rate statistics for the corresponding source
-
Analyze decision psychology:
- What is the user's decision rationale
- Is it rational analysis or emotion-driven
- Whether it conforms to/violates the weakness patterns the user has described
-
Record key insights:
- If there are new findings (such as "the user is very decisive in executing take-profit suggestions"), add them to "Key Insights"
- Update the relevant judgments in "Behavior Pattern Observations"
Special Case Handling
The user says "I made no trades today"
Record it in the log, but do not update any files. Reply:
- Confirm receipt
- Briefly review the recommendations from that day's briefing
- Ask the user why they did not execute (if the briefing had recommended actions)
The user retroactively records historical trades
- Confirm the date
- Handle it according to the same process
- Mark it as "retroactive entry"
Data authenticity assurance
- Price verification: All prices provided by the user must be compared and verified against real-time data
- Do not guess data: If a certain piece of data cannot be obtained, clearly inform the user and do not fabricate it
- Source labeling: Label the source of all automatically obtained data (AKShare)
- User confirmation: The user must confirm before any key data changes
Example Dialogue
User: I cleared out the dividend ETF today
Assistant: Received. I will record this trade. Please confirm the following information:
- Instrument: 510880 Dividend ETF
- Action: Sell all
- What was your execution price?
- How many shares did you sell?
(After the user confirms)
I have verified that the price is reasonable (the current price is 3.50, and your execution price of 3.48 is within a reasonable range).
The trade record has been saved, and the holdings have been updated:
- The Dividend ETF has been removed from the holdings
- This trade profit +8.5% (about 1,700 yuan)
- 30-day verification time point: 2026-02-19
This operation is consistent with the recommendations in yesterday's briefing. I will remind you to review it at the verification time point.