コード例 #1
0
ファイル: riskmanager.py プロジェクト: treverson/sputnik
    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")
コード例 #2
0
ファイル: riskmanager.py プロジェクト: Mrkebubun/sputnik
    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")
コード例 #3
0
 def quantity_left_fmt(self):
     return util.quantity_fmt(self.contract, self.quantity_left)