def get_results(tickers=None):
    """
    Given a list of stock tickers, this print formatted results to the terminal.
    """
    if tickers == ['']:
        return

    stocks = QuarterlyReport.get_stocks(tickers)

    if verbose:
        string_header = '{:<10}'.format('Ticker') + '{:<17}'.format('Earnings Date')
        string_to_line = ''
        if peg_ratio:
            string_header += '{:<13}'.format('Peg Ratio')
        if rsi:
            string_header += '{:<13}'.format('RSI')
        if fifty_two:
            string_header += '{:<20}'.format('52Wk H&L')
        string_header += '{:<12}'.format('Price')
        print(string_header)
        for stock in stocks:
            string_to_line = '{:<10}'.format(stock.ticker) + '{:<17}'.format(stock.earnings_date)
            if peg_ratio:
                string_to_line += '{:<13}'.format(str(stock.peg_ratio))
            if rsi:
                string_to_line += '{:<13}'.format(str(stock.rsi))
            if fifty_two:
                string_to_line += '{:<20}'.format(str(stock.fifty_two))
            string_to_line += '{:<12}'.format(str(stock.price))
            print(string_to_line)
    return stocks
Beispiel #2
0
def send_email(tickers=None, to_addr='your_email_here@your_domain.com'):
    """
    Given a list of stock tickers, this will send an email report formatted as an HTML table to the designated address.
    """

    stocks = QuarterlyReport.get_stocks(tickers)

    if ('email_sender' and 'email_cred' and 'email_receiver' and 'port'
            and 'smtp') in globals():
        # Create a message summarizing the best deals.
        message = MIMEMultipart('alternative')

        message['Subject'] = 'TakeStock Report'
        message['From'] = email_sender
        html = ''
        if peg_ratio:
            html = """\
            <table border=1>
            <thead><tr><td>Stock Symbol</td><td>Earnings Date</td><td>PEG Ratio</td><td>Price</td></tr></thead>
            <tbody>
            """
        else:
            html = """\
            <table border=1>
            <thead><tr><td>Stock Symbol</td><td>Earnings Date</td><td>Price</td></tr></thead>
            <tbody>
            """

        for stock in stocks:
            if peg_ratio:
                html += "<tr>" + "<td>" + stock.ticker + "</td>" + "<td>" + stock.earnings_date + "</td>" + \
                        "<td>" + str(stock.peg_ratio) + "</td>" + "<td>" + str(stock.price) + "</td></tr>"
            else:
                html += "<tr>" + "<td>" + stock.ticker + "</td>" + "<td>" + stock.earnings_date + "</td>" + "<td>" + \
                        str(stock.price) + "</td></tr>"

        html += '</tbody></table>'

        text = MIMEText(html, 'html')
        message.attach(text)
        # Email the deals.
        message['To'] = email_receiver
        server = smtplib.SMTP(smtp + ":" + port)
        # server.ehlo()
        server.starttls()
        server.login(email_sender, email_cred)
        server.sendmail(email_sender, email_receiver, message.as_string())
        server.quit()
def send_email(tickers=None, to_addr='your_email_here@your_domain.com'):
    """
    Given a list of stock tickers, this will send an email report formatted as an HTML table to the designated address.
    """

    stocks = QuarterlyReport.get_stocks(tickers)

    if ('email_sender' and 'email_cred' and 'email_receiver' and 'port' and 'smtp') in globals():
        # Create a message summarizing the best deals.
        message = MIMEMultipart('alternative')

        message['Subject'] = 'TakeStock Report'
        message['From'] = email_sender
        html = ''
        if peg_ratio:
            html = """\
            <table border=1>
            <thead><tr><td>Stock Symbol</td><td>Earnings Date</td><td>PEG Ratio</td><td>Price</td></tr></thead>
            <tbody>
            """
        else:
            html = """\
            <table border=1>
            <thead><tr><td>Stock Symbol</td><td>Earnings Date</td><td>Price</td></tr></thead>
            <tbody>
            """

        for stock in stocks:
            if peg_ratio:
                html += "<tr>" + "<td>" + stock.ticker + "</td>" + "<td>" + stock.earnings_date + "</td>" + \
                        "<td>" + str(stock.peg_ratio) + "</td>" + "<td>" + str(stock.price) + "</td></tr>"
            else:
                html += "<tr>" + "<td>" + stock.ticker + "</td>" + "<td>" + stock.earnings_date + "</td>" + "<td>" + \
                        str(stock.price) + "</td></tr>"

        html += '</tbody></table>'

        text = MIMEText(html, 'html')
        message.attach(text)
        # Email the deals.
        message['To'] = email_receiver
        server = smtplib.SMTP(smtp + ":" + port)
        # server.ehlo()
        server.starttls()
        server.login(email_sender, email_cred)
        server.sendmail(email_sender, email_receiver, message.as_string())
        server.quit()
Beispiel #4
0
def get_results(tickers=None):
    """
    Given a list of stock tickers, this print formatted results to the terminal.
    """
    if tickers == ['']:
        return

    stocks = QuarterlyReport.get_stocks(tickers)

    if verbose:
        string_header = '{:<10}'.format('Ticker') + '{:<17}'.format(
            'Earnings Date')
        string_to_line = ''
        if peg_ratio:
            string_header += '{:<13}'.format('Peg Ratio')
        if pe_ratio:
            string_header += '{:<13}'.format('PE Ratio')
        if rsi:
            string_header += '{:<13}'.format('RSI')
        if fifty_two:
            string_header += '{:<20}'.format('52Wk H&L')
        string_header += '{:<12}'.format('Price')
        print(string_header)
        for stock in stocks:
            string_to_line = '{:<10}'.format(stock.ticker) + '{:<17}'.format(
                stock.earnings_date)
            if peg_ratio:
                string_to_line += '{:<13}'.format(str(stock.peg_ratio))
            if pe_ratio:
                string_to_line += '{:<13}'.format(str(stock.pe_ratio))
            if rsi:
                string_to_line += '{:<13}'.format(str(stock.rsi))
            if fifty_two:
                string_to_line += '{:<20}'.format(str(stock.fifty_two))
            string_to_line += '{:<12}'.format(str(stock.price))
            print(string_to_line)
    return stocks