Skip to content

Instantly share code, notes, and snippets.

@saleh-old
Last active June 28, 2020 09:08
Show Gist options
  • Save saleh-old/27f5567c3442a2ecff5d85075b537cb9 to your computer and use it in GitHub Desktop.
Save saleh-old/27f5567c3442a2ecff5d85075b537cb9 to your computer and use it in GitHub Desktop.
def go_long(self):
entry = self.price
stop = entry - 3*self.atr
qty = utils.risk_to_qty(self.capital, 3, entry, stop, fee_rate=self.fee_rate)
profit_target = entry + 5*self.atr
self.buy = qty, entry
self.stop_loss = qty, stop
self.take_profit = qty, profit_target
def go_short(self):
entry = self.price
stop = entry + 3 * self.atr
qty = utils.risk_to_qty(self.capital, 3, entry, stop, fee_rate=self.fee_rate)
profit_target = entry - 5 * self.atr.
self.sell = qty, entry
self.stop_loss = qty, stop
self.take_profit = qty, profit_target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment