示例#1
0
    def format_institutional(self, filing):
        alert = {'type': '/13F/', 'cik': int(filing['cik']),
                 'original': filing['url']}
        company = truncator(filing['name'], 40)

        if filing['amendment'] == 'A':
            amended_wording = 'an amended 13F'
        elif filing['amendment'] == 'R':
            amended_wording = 'a replacement 13F'
        else:
            amended_wording = 'a 13F'

        date_filed = self.format_date_filed(filing['date_filed'])
        period_of_report = pretty_date(filing['period_of_report'])
        positions = format_number(filing['positions'])
        aum = format_aum(filing['aum'])
        alert['subject'] = '%s filed %s for %s' % \
                    (company, amended_wording, period_of_report)

        """Create the text body"""
        alert['text'] = [alert['subject']]
        alert['text'].append(date_filed)
        alert['text'].append('Period: ' + period_of_report)
        alert['text'].append('Positions: ' + positions + ' (%s)' % aum)

        """Create the tweet"""
        if float(filing['aum']) > 100000 and filing['amendment'] == 'O':
            alert['tweet'] = [alert['subject']]
            alert['tweet'].append(positions + ' positions ' + '(' + aum + ')')
        self.raw_alerts.append(alert)
示例#2
0
    def format_econ(self, series):
        alert = {'type': '/econ/', 'id': series['id']}
        title = truncator(series['name'], 25)
        units = truncator(series['units_short'], 15)

        alert['subject'] = '%s (%s, %s) ' % (title, units, series['seasonal'])
        alert['subject'] += pretty_date(series['latest_date']) + ': '
        alert['subject'] += series['latest'] + ', '
        alert['subject'] += series['sequential_change'] + ' vs. '
        alert['subject'] += prior_wording(series['frequency']) + ' and '
        alert['subject'] += series['yoy_change'] + ' YoY'

        """Create the text body"""
        """Will implement when we get econ watchlists setup"""
        alert['text'] = [alert['subject']]

        """Create the tweet"""
        if series['popularity'] > 50:
            alert['tweet'] = [alert['subject']]
        self.raw_alerts.append(alert)
示例#3
0
    def format_insiders(self, filing):
        alert = {'type': '/insiders/', 'cik': int(filing['cik']),
                 'original': filing['url']}
        date_filed = self.format_date_filed(filing['date_filed'])
        insider = truncator(filing['insider_name'], 40)
        company = truncator(filing['name'], 40)
        net_value = filing['option_value'] - filing['value']
        bought_sold = 'sold a net'
        if filing['shares'] > 0:
            bought_sold = 'bought a net'

        alert['subject'] = '%s %s %s in %s' % (insider, bought_sold, \
                            format_value(abs(net_value)), company)
        """Create the text body"""
        alert['text'] = [alert['subject']]
        alert['text'].append(insider_position(filing))
        alert['text'].append(date_filed)
        alert['ticker'] = filing['ticker']

        """Create the tweet"""
        if filing['ticker'] != None and abs(net_value) > 0:
            tweet = '$' + filing['ticker'] + ': '
            alert['tweet'] = [tweet + alert['subject']]
        self.raw_alerts.append(alert)
示例#4
0
 def test_truncator(self):
     raw = 'abcdefghijklmnopqrstuvwxyz'
     truncated = truncator(raw, 11)
     self.failUnless(len(truncated) == 11 + 3)