Beispiel #1
0
 def populate_observations(cls, values, begin_date):
     dates = list()
     values = str(values)
     for val in values:
         dates.append(begin_date)
         InvestmentCycleObservationFactory.create(as_of=begin_date,
                                                  cycle=int(val))
         begin_date += datetime.timedelta(1)
     return dates
def populate_cycle_obs(days, asof=now().date()):
    # do not input less than 400 days, method might fail
    cycle = int(np.random.uniform(0, 6))
    prog = [0, 1, 2, 0, 3, 4]
    dt = asof - timedelta(days=days)
    while days:
        run = min(int(np.random.uniform(20, 50)), days)
        while run:
            InvestmentCycleObservationFactory.create(as_of=dt,
                                                     cycle=prog[cycle])
            dt += timedelta(days=1)
            run -= 1
            days -= 1
        cycle += 1
        cycle %= 6
 def populate_observations(self):
     # We need to have a full range of cycle plus at least one date behind.
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 1),
         cycle=InvestmentCycleObservation.Cycle.EQ_PIT.value)
     InvestmentCycleObservationFactory.create(
         as_of=self.last_cycle_start,
         cycle=InvestmentCycleObservation.Cycle.PIT_EQ.value)
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 7),
         cycle=InvestmentCycleObservation.Cycle.EQ.value)
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 11),
         cycle=InvestmentCycleObservation.Cycle.EQ_PK.value)
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 13),
         cycle=InvestmentCycleObservation.Cycle.PK_EQ.value)
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 15),
         cycle=InvestmentCycleObservation.Cycle.EQ.value)
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 18),
         cycle=InvestmentCycleObservation.Cycle.EQ_PIT.value)
     InvestmentCycleObservationFactory.create(
         as_of=date(2016, 1, 20),
         cycle=InvestmentCycleObservation.Cycle.PIT_EQ.value)