Skip to content

Main#20

Open
zhangxt8113 wants to merge 2 commits intokhscience:mainfrom
zhangxt8113:main
Open

Main#20
zhangxt8113 wants to merge 2 commits intokhscience:mainfrom
zhangxt8113:main

Conversation

@zhangxt8113
Copy link

当前策略已经去掉 MACD 过滤,只剩下“趋势 + 无持仓”两个条件:
从 60 根历史 K 线里计算 MA20、MA60,要求最新价 price > MA60 且 MA20 > MA60,确认处于上升趋势。
khHas(data, code) 返回 False(上一交易日收盘时没有这只股票)。
满足后 _calc_buy_ratio 按“现金×95%,但单只股票不超过账户 5%”计算买入比例,并通过 generate_signal(..., "buy") 下单。
没有其他指标过滤,买点完全由均线趋势 + 空仓判断决定

只有拖尾止损这一条:

每个持仓都记录自买入以来的最高价 highest,并计算两条保护线:highest × (1 − TRAIL_DROP_PCT) 与 highest − TRAIL_ATR_MULT × ATR,取更高者作为动态止损价。
只要当前价跌破这条拖尾线,就触发卖出。首次触发只减半仓(PARTIAL_STOP_RATIO = 0.5),若已经减半或再次触发,则把剩余仓位全部卖出。
Copy link
Author

@zhangxt8113 zhangxt8113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

获取最新代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant