Skip to content

Instantly share code, notes, and snippets.

@saleh-old
Created June 9, 2020 07:57
Show Gist options
  • Save saleh-old/e95d21104b765247a576766a6be4357b to your computer and use it in GitHub Desktop.
Save saleh-old/e95d21104b765247a576766a6be4357b to your computer and use it in GitHub Desktop.
def update_position(self):
# the RSI logic is intended for the second half of the trade
if self.is_reduced:
rsi = ta.rsi(self.candles)
if self.is_long and rsi > 80:
# self.liquidate() closes the position with a market order
self.liquidate()
elif self.is_short and rsi < 20:
self.liquidate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment