We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
czsc/objects.py
# 当有新的开仓 event 发生,更新 last_event if op in [Operate.LO, Operate.SO]: self.last_event = {'dt': dt, 'bid': bid, 'price': price, 'op': op, 'op_desc': op_desc}
这段代码是否应该判断一下有无持仓,只要开仓之后last_event会一直更新,会导致下面判断止损的代码price 和 self.last_event['price']的值是一样的
# 多头止损 if price / self.last_event['price'] - 1 < -self.stop_loss / 10000: self.pos = 0 self.operates.append(__create_operate(Operate.LE, f"平多@{self.stop_loss}BP止损"))
The text was updated successfully, but these errors were encountered:
这里的止损不是以开仓价来计算的,而是以最后一次开仓事件的触发价格来计算。所以只要有新的开仓动作,就要更新 last_event。也就是会出现你下面说的那种情况,这是正常的
Sorry, something went wrong.
No branches or pull requests
czsc/objects.py
这段代码是否应该判断一下有无持仓,只要开仓之后last_event会一直更新,会导致下面判断止损的代码price 和 self.last_event['price']的值是一样的
The text was updated successfully, but these errors were encountered: