Record variables at the end of each day.
189180
def my_record_vars(context, data):
    

    # Record our variables.
    record(leverage=context.account.leverage)
    record(positions=len(context.portfolio.positions))
    if 0 < len(context.age):
        MaxAge = context.age[max(
            list(context.age.keys()), key=(lambda k: context.age[k]))]
        print(MaxAge)
        record(MaxAge=MaxAge)
    record(LowestPrice=context.LowestPrice)
923664
def day_of_week(self, abbr: bool = False) -> str:
        
        key = 'abbr' if abbr else 'name'
        days = self._data['day'].get(key)
        return self.random.choice(days)
1288992
def _write_values(kwargs, variables):
    """"""
    writeto = []
    for var_name, value in kwargs.items():
        var = variables[var_name]
        var.notify_will_write()
        var.write(value)
        writeto.append(var)
    return _notify_reader_writes(writeto)
241927
private Date addDays(final Date date, final int days) {
        final Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.DATE, days); //minus number would decrement the days
        return cal.getTime();
    }
176114
def record_leaving(self, time, code, frame_key, parent_stats):
        """"""
        try:
            stats = parent_stats.get_child(code)
            time_entered = self._times_entered.pop((code, frame_key))
        except KeyError:
            return
        time_elapsed = time - time_entered
        stats.deep_time += max(0, time_elapsed)
1306817
def offset(self, date, n_days):
        '''
        
        '''
#CONSIDER: raise an exception if a date is not in self
        index = self.index(date) + n_days
        if index < 0:
            index = 0
        if index > len(self) - 1:
            index = len(self) - 1
        return self[index]
291173
async def on_date(self, date: datetime.date) -> dict:
        """"""
        return await self._request(
            'get', 'dailystats/{0}'.format(date.strftime('%Y-%m-%d')))
538961
def end_of_day(val):
    
    if type(val) == date:
        val = datetime.fromordinal(val.toordinal())
    return start_of_day(val) + timedelta(days=1, microseconds=-1)
569541
async def log(
            self,
            date: datetime.date = None,
            days: int = None,
            details: bool = False) -> list:
        """"""
        endpoint = 'watering/log'
        if details:
            endpoint += '/details'

        if date and days:
            endpoint = '{0}/{1}/{2}'.format(
                endpoint, date.strftime('%Y-%m-%d'), days)

        data = await self._request('get', endpoint)
        return data['waterLog']['days']
298443
def generate_schedule(today=None):
    """"""
    # We create a list of slots and schedule items
    schedule_days = {}
    seen_items = {}
    for slot in Slot.objects.all().order_by('end_time', 'start_time', 'day'):
        day = slot.get_day()
        if today and day != today:
            # Restrict ourselves to only today
            continue
        schedule_day = schedule_days.get(day)
        if schedule_day is None:
            schedule_day = schedule_days[day] = ScheduleDay(day)
        row = make_schedule_row(schedule_day, slot, seen_items)
        schedule_day.rows.append(row)
    return sorted(schedule_days.values(), key=lambda x: x.day.date)
396540
public function same_day() {
    if (!$this->values || ($this->start && !$this->end)) {
      return true;
    }

    if ($this->start->format('Y-m-d') == $this->end->format('Y-m-d')) {
      return true;
    }
    return false;
  }
97783
def _close_open_date_ranges(self, record):
        """"""
        date_ranges = (('beginDate', 'endDate'),)
        for begin, end in date_ranges:
            if begin in record and end in record:
                return
            elif begin in record:
                record[end] = record[begin]
            elif end in record:
                record[begin] = record[end]
448033
def set_day(self, day: int) -> datetime:
        
        self.value = self.value.replace(day=day)
        return self.value
458053
def _days(cls, start, end):
        
        days = []
        # datetime
        start_day, end_day = dt.strptime(start, cls.DATE_FORMAT), dt.strptime(end, cls.DATE_FORMAT)
        delta = end_day - start_day

        for day in range(delta.days+1):
            days.append(start_day + timedelta(days=day))
        return days
1125291
protected function defaultIntervalVariables()
    {
        $this->interval  = '* * * * *';
        $this->minute    = '*';
        $this->hour      = '*';
        $this->dayNumber = '*';
        $this->month     = '*';
        $this->day       = '*';
    }
10683
function record(name, num, statistics, aggregations, timestamp, callback) {
        timestamp = timestamp || Date.now();
        function recordStats(key) {
            statistics && statistics.forEach(function(stat) {
                    if(stat == 'sum') {
                        multi.hincrby(key, 'sum', num)
                    } else if(scripts[stat]){
                        evalScript(multi, stat, [key, num],[],function(err, result) {
                                if(err) throw err;
                                if(result && result.indexOf('ERR') == 0) {
                                    // console.log(scripts[stat]);
                                    throw new Error(result);
                                }
                        })
                    }
            });
        }
        if(!statistics) statistics = ['sum'];
        if(num == undefined) num = 1;

        var multi = redis.multi();

        granularities.forEach(function(gran) {
                var key = getGranKey(name, gran, timestamp);
                recordStats(key);
                var unitPeriod = gran[0];
                multi.expire(key, points * unitPeriod / 1000);
        });

        if(aggregations) for(var i = 0; i < aggregations.length; i++) {
            var aggr = aggregations[i];
            var key = getAggrKey(name, aggr, timestamp);
            recordStats(key);
        }

        multi.exec(callback || log);
    }
270309
def daterange(start, end, delta=timedelta(days=1), lower=Interval.CLOSED, upper=Interval.OPEN):
    """"""
    date_interval = Interval(lower=lower, lower_value=start, upper_value=end, upper=upper)
    current = start if start in date_interval else start + delta
    while current in date_interval:
        yield current
        current = current + delta