def email_user(self, user, cash_position, low_margin, high_margin, severe): """ :param user: :type user: User :param cash_position: :type cash_position: int :param low_margin: :type low_margin: int :param high_margin: :type high_margin: int :param severe: :type severe: bool """ template_file = "margin_call.{locale}.email" if severe else "low_margin.{locale}.email" t = util.get_locale_template(user.locale, self.jinja_env, template_file) content = t.render( cash_position=util.quantity_fmt(self.BTC, cash_position), low_margin=util.quantity_fmt(self.BTC, low_margin), high_margin=util.quantity_fmt(self.BTC, high_margin), user=user).encode('utf-8') # Now send the mail log.msg("Sending mail: %s" % content) self.sendmail.send_mail( content, to_address=user.email, subject="Margin Call" if severe else "Margin Warning")
def email_user(self, user, cash_position, low_margin, high_margin, severe): """ :param user: :type user: User :param cash_position: :type cash_position: int :param low_margin: :type low_margin: int :param high_margin: :type high_margin: int :param severe: :type severe: bool """ template_file = "margin_call.{locale}.email" if severe else "low_margin.{locale}.email" t = util.get_locale_template(user.locale, self.jinja_env, template_file) content = t.render(cash_position=util.quantity_fmt(self.BTC, cash_position), low_margin=util.quantity_fmt(self.BTC, low_margin), high_margin=util.quantity_fmt(self.BTC, high_margin), user=user).encode('utf-8') # Now send the mail log.msg("Sending mail: %s" % content) self.sendmail.send_mail(content, to_address=user.email, subject="Margin Call" if severe else "Margin Warning")
def quantity_left_fmt(self): return util.quantity_fmt(self.contract, self.quantity_left)