This commit is contained in:
vn.py 2019-09-17 23:11:17 +08:00
parent cf2a7ad2f7
commit 1356aac894

View File

@ -78,7 +78,12 @@ class TurtleSignalStrategy(CtaTemplate):
if not self.am.inited: if not self.am.inited:
return return
self.entry_up, self.entry_down = self.am.donchian(self.entry_window) # Only calculates new entry channel when no position holding
if not self.pos:
self.entry_up, self.entry_down = self.am.donchian(
self.entry_window
)
self.exit_up, self.exit_down = self.am.donchian(self.exit_window) self.exit_up, self.exit_down = self.am.donchian(self.exit_window)
if not self.pos: if not self.pos:
@ -92,13 +97,13 @@ class TurtleSignalStrategy(CtaTemplate):
self.send_buy_orders(self.entry_up) self.send_buy_orders(self.entry_up)
self.send_short_orders(self.entry_down) self.send_short_orders(self.entry_down)
elif self.pos > 0: elif self.pos > 0:
self.send_buy_orders(self.long_entry) self.send_buy_orders(self.entry_up)
sell_price = max(self.long_stop, self.exit_down) sell_price = max(self.long_stop, self.exit_down)
self.sell(sell_price, abs(self.pos), True) self.sell(sell_price, abs(self.pos), True)
elif self.pos < 0: elif self.pos < 0:
self.send_short_orders(self.short_entry) self.send_short_orders(self.entry_down)
cover_price = min(self.short_stop, self.exit_up) cover_price = min(self.short_stop, self.exit_up)
self.cover(cover_price, abs(self.pos), True) self.cover(cover_price, abs(self.pos), True)