Example #1
0
    def auto_reject(self):
        msg = '%s %s [%s] automatically rejected' % (
            self.pair.name, self.system.name.upper(), self.tf)
        logging.info(msg)
        sendMsg('logs', msg)

        self.reject()
Example #2
0
 def notify(self):
     log.info('Trade opened')
     obj = {
         'pair': self.signal.pair.name,
         'tf': self.signal.tf,
         'system': self.signal.system.name.upper(),
     }
     sendMail('NEW TRADE', render_to_string('mail/trade_open.html', obj))
     sendMsg('trades', render_to_string('chat/trade_open.txt', obj))
Example #3
0
 def notify_by_chat(self):
     sendMsg(
         'signals',
         render_to_string(
             'chat/signal.txt', {
                 'pair': self.pair.name,
                 'tf': self.tf,
                 'system': self.system.name.upper()
             }))
Example #4
0
    def be(self):
        self.status = 'BE'
        self.save()

        total = 0
        for trade in Trade.objects.filter(signal=self):
            total += trade.profit

        sendMail('PROFIT', 'BE | $%.2f' % total)
        sendMsg('trades', 'PROFIT')
Example #5
0
    def loss(self):
        self.status = 'LOSS'
        self.save()

        total = 0
        total_net = 0
        for trade in Trade.objects.filter(signal__id=self.id):
            total += trade.gross_profit
            total_net += trade.net_profit

            log.info('Trade %s (Signal %s) closed with profit (+$%.2f)' % (trade.id, self.id, trade.net_profit))

        log.info('Signal %s closed with loss (-$%.2f NET -$%.2f)' % (self.id, abs(total), abs(total_net)))
        obj = {
            'pair': self.pair.name,
            'tf': self.tf,
            'system': self.system.name.upper(),
            'total': total,
            'total_net': total_net,
        }
        sendMail('LOSS', render_to_string('mail/trade_close.html', obj))
        sendMsg('trades', render_to_string('chat/trade_close.txt', obj))
Example #6
0
 def notify_by_chat(self):
     sendMsg('signals', render_to_string('chat/signal.txt', {
         'pair': self.pair.name,
         'tf': self.tf,
         'system': self.system.name.upper()
     }))
Example #7
0
    def auto_reject(self):
        msg = '%s %s [%s] automatically rejected' % (self.pair.name, self.system.name.upper(), self.tf)
        logging.info(msg)
        sendMsg('logs', msg)

        self.reject()
Example #8
0
 def critical(self, msg, title='CRITICAL'):
     log.critical(msg)
     sendMsg('alerts', 'CRITICAL. %s.' % msg)
     sendMail(title, msg)
Example #9
0
 def error(self, msg, title='ERROR'):
     log.error(msg)
     sendMsg('alerts', 'ERROR. %s.' % msg)
     sendMail(title, msg)
Example #10
0
 def warning(self, msg, title='WARNING'):
     log.warn(msg)
     sendMsg('alerts', 'WARNING. %s.' % msg)
     sendMail(title, msg)
Example #11
0
 def info(self, msg, title='INFO'):
     log.info(msg)
     sendMsg('alerts', 'INFO. %s.' % msg)
     sendMail(title, msg)
Example #12
0
 def critical(self, msg, title='CRITICAL'):
     log.critical(msg)
     sendMsg('alerts', 'CRITICAL. %s.' % msg)
     sendMail(title, msg)
Example #13
0
 def error(self, msg, title='ERROR'):
     log.error(msg)
     sendMsg('alerts', 'ERROR. %s.' % msg)
     sendMail(title, msg)
Example #14
0
 def warning(self, msg, title='WARNING'):
     log.warn(msg)
     sendMsg('alerts', 'WARNING. %s.' % msg)
     sendMail(title, msg)
Example #15
0
 def info(self, msg, title='INFO'):
     log.info(msg)
     sendMsg('alerts', 'INFO. %s.' % msg)
     sendMail(title, msg)