Get List of prices between two dates
355826
def get_previous_price_list(self, currency, start_date, end_date):
        
        start = start_date.strftime('%Y-%m-%d')
        end = end_date.strftime('%Y-%m-%d')
        url = (
            'https://api.coindesk.com/v1/bpi/historical/close.json'
            '?start={}&end={}&currency={}'.format(
                   start, end, currency
               )
        )
        response = requests.get(url)
        if response.status_code == 200:
            data = self._decode_rates(response)
            price_dict = data.get('bpi', {})
            return price_dict
        return {}
462184
def get_upcoming_event_lists_for_the_remainder_of_the_month(self, year = None, month = None):
        ''''''

        events = []
        if year == None and month == None:
            now = datetime.now(tz=self.timezone) # timezone?
        else:
            now = datetime(year=year, month=month, day=1, hour=0, minute=0, second=0, tzinfo=self.timezone)

        # Get today's events, including past events
        start_time = datetime(year=now.year, month=now.month, day=now.day, hour=0, minute=0, second=0, tzinfo=self.timezone)
        end_time = datetime(year = start_time.year, month = start_time.month, day = start_time.day, hour=23, minute=59, second=59, tzinfo=self.timezone)
        events.append(self.get_events(start_time.isoformat(), end_time.isoformat()))

        # Get this week's events
        if now.weekday() < 6:
            start_time = datetime(year=now.year, month=now.month, day=now.day + 1, hour=0, minute=0, second=0, tzinfo=self.timezone)
            end_time = start_time + timedelta(days = 6 - now.weekday())
            # We do still want to return events in the next month if they fall within this week. Otherwise
            #if end_time.month != now.month:
            #    end_time = end_time - timedelta(days = end_time.day)
            #    end_time = datetime(year = end_time.year, month = end_time.month, day = end_time.day, hour=23, minute=59, second=59, tzinfo=self.timezone)
            #else:
            end_time = end_time + timedelta(seconds = -1)
            #end_time = datetime(year = end_time.year, month = end_time.month, day = end_time.day - 1, hour=23, minute=59, second=59, tzinfo=self.timezone)
            events.append(self.get_events(start_time.isoformat(), end_time.isoformat()))
        else:
            events.append([])

        # Get this remaining events in the month
        start_time = end_time + timedelta(seconds = 1)
        if start_time.month == now.month:
            if now.month == 12:
                end_time = datetime(year = start_time.year, month = 12, day = 31, hour=23, minute=59, second=59, tzinfo=self.timezone)
            else:
                end_time = datetime(year = start_time.year, month = start_time.month + 1, day = 1, hour=0, minute=0, second=0, tzinfo=self.timezone)
                end_time = end_time - timedelta(seconds = 1)
            events.append(self.get_events(start_time.isoformat(), end_time.isoformat()))
        else:
            events.append([])

        return events
441359
def _get_price(self, data, market, field):
        
        for m in data:
            if m["symbol"] == market:
                return m[field]
713179
def get_estimates_without_scope_in_month(self, customer):
        
        estimates = self.get_price_estimates_for_customer(customer)
        if not estimates:
            return []

        tables = {model: collections.defaultdict(list)
                  for model in self.get_estimated_models()}

        dates = set()
        for estimate in estimates:
            date = (estimate.year, estimate.month)
            dates.add(date)

            cls = estimate.content_type.model_class()
            for model, table in tables.items():
                if issubclass(cls, model):
                    table[date].append(estimate)
                    break

        invalid_estimates = []
        for date in dates:
            if any(map(lambda table: len(table[date]) == 0, tables.values())):
                for table in tables.values():
                    invalid_estimates.extend(table[date])
        print(invalid_estimates)
        return invalid_estimates
244517
def prepare_query(self, symbol,  start_date, end_date):
        """"""
        query = \
            'select * from yahoo.finance.historicaldata where symbol = "%s" and startDate = "%s" and endDate = "%s"' \
            % (symbol, start_date, end_date)

        return query
1245
def get_today_all(output='pd'):
    

    data = []
    today = str(datetime.date.today())
    codes = QA_fetch_get_stock_list('stock').code.tolist()
    bestip = select_best_ip()['stock']
    for code in codes:
        try:
            l = QA_fetch_get_stock_day(
                code, today, today, '00', ip=bestip)
        except:
            bestip = select_best_ip()['stock']
            l = QA_fetch_get_stock_day(
                code, today, today, '00', ip=bestip)
        if l is not None:
            data.append(l)

    res = pd.concat(data)
    if output in ['pd']:
        return res
    elif output in ['QAD']:
        return QA_DataStruct_Stock_day(res.set_index(['date', 'code'], drop=False))
417781
def GetCalendarDatesFieldValuesTuples(self):
    """"""
    result = []
    for date_tuple in self.GenerateCalendarDatesFieldValuesTuples():
      result.append(date_tuple)
    result.sort()  # helps with __eq__
    return result
938681
def ActiveDates(self):
    """"""
    (earliest, latest) = self.GetDateRange()
    if earliest is None:
      return []
    dates = []
    date_it = util.DateStringToDateObject(earliest)
    date_end = util.DateStringToDateObject(latest)
    delta = datetime.timedelta(days=1)
    while date_it <= date_end:
      date_it_string = date_it.strftime("%Y%m%d")
      if self.IsActiveOn(date_it_string, date_it):
        dates.append(date_it_string)
      date_it = date_it + delta
    return dates
844947
def dates(self):
        ''' '''
        dates = []
        d = self.date_a
        while d < self.date_b:
            dates.append(d)
            d += datetime.timedelta(1)

        return dates
1123799
def get_headers(self, date_headers, from_date, to_date, trunc):
        """"""
        date_headers = list(date_headers)

        # Earliest date should be no earlier than from_date.
        if date_headers and date_headers[0] < from_date:
            date_headers[0] = from_date

        # When organizing by week or month, create a list of the range for
        # each date header.
        if date_headers and trunc != 'day':
            count = len(date_headers)
            range_headers = [0] * count
            for i in range(count - 1):
                range_headers[i] = (
                    date_headers[i], date_headers[i + 1] - relativedelta(days=1))
            range_headers[count - 1] = (date_headers[count - 1], to_date)
        else:
            range_headers = date_headers
        return date_headers, range_headers
160527
function getDataItems (items) {
  validate.requiredItems(items)

  const data = {}
  validate.vatIdNumber(items.dicPopl)
  data.dic_popl = items.dicPopl

  validate.businessPremisesId(items.idProvoz)
  data.id_provoz = items.idProvoz

  validate.cashRegisterId(items.idPokl)
  data.id_pokl = items.idPokl

  validate.receiptNumber(items.poradCis)
  data.porad_cis = items.poradCis

  validate.date(items.datTrzby)
  data.dat_trzby = formatDate(items.datTrzby)

  if (isDefinedAndNotNull(items.rezim)) {
    validate.regime(items.rezim)
    data.rezim = items.rezim
  } else {
    data.rezim = 0
  }

  if (isDefinedAndNotNull(items.dicPoverujiciho)) {
    validate.vatIdNumber(items.dicPoverujiciho)
    data.dic_poverujiciho = items.dicPoverujiciho
  }

  validate.financialNumber(items.celkTrzba)
  data.celk_trzba = formatNumber(items.celkTrzba)

  const map = {
    zaklNepodlDph: 'zakl_nepodl_dph',
    zaklDan1: 'zakl_dan1',
    dan1: 'dan1',
    zaklDan2: 'zakl_dan2',
    dan2: 'dan2',
    zaklDan3: 'zakl_dan3',
    dan3: 'dan3',
    cestSluz: 'cest_sluz',
    pouzitZboz1: 'pouzit_zboz1',
    pouzitZboz2: 'pouzit_zboz2',
    pouzitZboz3: 'pouzit_zboz3',
    urcenoCerpZuct: 'urceno_cerp_zuct',
    cerpZuct: 'cerp_zuct'
  }
  Object.keys(map)
  .filter(key => isDefinedAndNotNull(items[key]))
  .forEach(key => {
    validate.financialNumber(items[key])
    data[map[key]] = formatNumber(items[key])
  })

  return {
    attributes: data
  }
}
279336
def get_price_as_of(self, stock: Commodity, on_date: datetime):
        
        # return self.get_price_as_of_query(stock, on_date).first()
        prices = PriceDbApplication()
        prices.get_prices_on(on_date.date().isoformat(), stock.namespace, stock.mnemonic)
95478
def get_previous_price(self, currency, date_obj):
        
        start = date_obj.strftime('%Y-%m-%d')
        end = date_obj.strftime('%Y-%m-%d')
        url = (
            'https://api.coindesk.com/v1/bpi/historical/close.json'
            '?start={}&end={}&currency={}'.format(
                   start, end, currency
               )
        )
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            price = data.get('bpi', {}).get(start, None)
            if self._force_decimal:
                return Decimal(price)
            return price
        raise RatesNotAvailableError("BitCoin Rates Source Not Ready For Given date")
602205
def get_price(self):
        
        tick = self.get_ticks(lookback=1, as_dict=True)
        return None if tick is None else tick['last']
374401
def get_dates(self):
        """"""
        if 'dates' in self.xml:
            if isinstance(self.xml['dates']['date'], dict):
                return self.xml['dates']['date'].values()[0]
            return self.xml['dates']['date']
        return None
389600
function timestamp () {
  const date = new Date()

  return [
    zeropad(date.getHours()),
    zeropad(date.getMinutes()),
    zeropad(date.getSeconds())
  ].join(':')
}
735632
def complete_date_value
      options = []
      options << '"30 minutes ago"'
      options << '"1 hour ago"'
      options << '"2 hours ago"'
      options << 'Today'
      options << 'Yesterday'
      options << 'Tomorrow'
      options << 2.days.ago.strftime('%A')
      options << 3.days.ago.strftime('%A')
      options << 4.days.ago.strftime('%A')
      options << 5.days.ago.strftime('%A')
      options << '"6 days ago"'
      options << 7.days.ago.strftime('"%b %d,%Y"')
      options << '"2 weeks from now"'
      options
    end