Exemple #1
0
 def event_days_ago(self):
     if not self.event_dates:
         return {}
     resp = {}
     for source, date_list in self.event_dates.iteritems():
         resp[source] = [days_ago(event_date_string) for event_date_string in date_list]
     return resp
 def event_days_ago(self):
     if not self.event_dates:
         return {}
     resp = {}
     for source, date_list in self.event_dates.iteritems():
         resp[source] = [days_ago(event_date_string) for event_date_string in date_list]
     return resp
 def events_last_week_count(self):
     events_last_week_count = 0
     for my_product in self.products:
         if my_product.event_dates and self.source_name in my_product.event_dates:
             date_list = my_product.event_dates[self.source_name]
             events = [days_ago(event_date_string) for event_date_string in date_list]
             events_last_week = [e for e in events if e <= 7]
             events_last_week_count += len(events_last_week)
     return events_last_week_count
Exemple #4
0
 def events_last_week_count(self):
     events_last_week_count = 0
     for my_product in self.products:
         if self.source_name in my_product.event_dates:
             date_list = my_product.event_dates[self.source_name]
             events = [days_ago(event_date_string) for event_date_string in date_list]
             events_last_week = [e for e in events if e <= 7]
             events_last_week_count += len(events_last_week)
     return events_last_week_count
Exemple #5
0
 def decide_if_assigned(self, person):
     streak = True
     streak_length = 0
     all_event_days_ago = [days_ago(e) for e in person.get_event_dates()]
     for month in range(0, 10*12):  # do up to 10 years
         streak_length += 1
         relevant_days = [month*30 + day for day in range(0, 30)]
         matching_days_count = len([d for d in all_event_days_ago if d in relevant_days])
         if matching_days_count <= 0:
             # print "broke the streak"
             break
     if streak_length > 1:
         self.assigned = True
         self.candidate_badge.value = streak_length
Exemple #6
0
    def set_event_counts(self):
        self.monthly_event_count = 0
        self.weekly_event_count = 0

        event_dates = self.get_event_dates()
        if not event_dates:
            return

        for event_date in event_dates:
            event_days_ago = days_ago(event_date)
            if event_days_ago <= 7:
                self.weekly_event_count += 1
            if event_days_ago <= 30:
                self.monthly_event_count += 1
Exemple #7
0
 def decide_if_assigned_threshold(self, person, threshold):
     streak = True
     streak_length = 0
     all_event_days_ago = [days_ago(e) for e in person.get_event_dates()]
     for month in range(0, 10*12):  # do up to 10 years
         streak_length += 1
         relevant_days = [month*30 + day for day in range(0, 30)]
         matching_days_count = len([d for d in all_event_days_ago if d in relevant_days])
         if matching_days_count <= 0:
             # print "broke the streak"
             break
     if streak_length > 1:
         self.assigned = True
         self.candidate_badge.value = streak_length
    def get_initial_liq_portfolio(self):
        stock_sym = self.stock_liq_mat.columns
        startdate = self.start_date.strftime("%Y-%m-%d")
        earlier_date = util.days_ago(28, self.start_date).strftime("%Y-%m-%d")
        sub_mat = self.stock_liq_mat.loc[earlier_date:startdate].values
        mon_grow = (sub_mat[-1, :] - sub_mat[0, :]) / sub_mat[0, :]
        rank = np.argsort(-mon_grow)
        return_list = []
        for i in range(5):
            col = rank[i]
            price = sub_mat[-1, col]
            return_list.append([
                stock_sym[col], price, mon_grow[col],
                self.asset_value / 5 / price
            ])
        self.current_port = return_list

        my_df = pd.DataFrame(return_list)
        my_df.to_csv('current_holding.csv', index=False, header=False)
    def set_consistency(self):
        self.consistency = None

        if self.first_publishing_date:
            first_pub_or_2012 = max(self.first_publishing_date.isoformat(),
                                    "2012-01-01T01:00:00")

            months_since_first_pub_or_2012 = days_ago(first_pub_or_2012) / 30
            months_with_event = {}
            for event_date in self.get_event_dates():
                if event_date >= first_pub_or_2012:
                    month_string = event_date[0:7]
                    months_with_event[month_string] = True
            count_months_with_event = len(months_with_event)

            if months_since_first_pub_or_2012:
                self.consistency = count_months_with_event / float(
                    months_since_first_pub_or_2012)

        return self.consistency