https://developers.coinbase.com/api/v2#get-historic-prices
427631
def get_historic_prices(self, **params):
        """"""
        if 'currency_pair' in params:
            currency_pair = params['currency_pair']
        else:
            currency_pair = 'BTC-USD'
        response = self._get('v2', 'prices', currency_pair, 'historic', params=params)
        return self._make_api_object(response, APIObject)
1147718
def get_historical_price(self, crypto, fiat, at_time):
        
        # represents the 'width' of the quandl data returned (one day)
        # if quandl ever supports data hourly or something, this can be changed
        interval = datetime.timedelta(hours=48)
        crypto = crypto.lower()
        fiat = fiat.lower()

        at_time = arrow.get(at_time).datetime

        data = crypto_data[crypto]
        name, date_created = data['name'], data['genesis_date']

        if date_created.replace(tzinfo=pytz.utc) > at_time:
            raise Exception("%s (%s) did not exist on %s" % (name, crypto, at_time))

        if crypto == 'btc':
            # Bitcoin to fiat
            if fiat == 'usd':
                if at_time < datetime.datetime(2013, 2, 1, tzinfo=pytz.utc):
                    exchange = 'MtGox'
                else:
                    exchange = "Bitstamp"
            else:
                exchange = quandl_exchange_btc_to_fiat[fiat.upper()]

            source = "BITCOIN/%s%s" % (exchange.upper(), fiat.upper())
            price_index = 1
        else:
            # some altcoin to bitcoin
            if fiat != 'btc':
                raise Exception("Altcoins are only available via BTC base fiat")
            if crypto == 'ltc':
                source, price_index = ['BTCE/BTCLTC', 4]
            else:
                source, price_index = ['CRYPTOCHART/' + crypto.upper(), 1]

        url = "https://www.quandl.com/api/v1/datasets/%s.json" % source
        trim = "?trim_start={0:%Y-%m-%d}&trim_end={1:%Y-%m-%d}".format(
            at_time - interval, at_time + interval
        )

        response = self.get_url(url + trim).json()
        closest_distance = interval

        best_price = None
        for line in response['data']:
            date = line[0]
            price = line[price_index]
            tick_date = arrow.get(date).datetime
            distance = at_time - tick_date

            if distance.total_seconds() == 0:
                return price, source, tick_date

            if distance < closest_distance:
                closest_distance = distance
                best_price = price
                best_date = tick_date

        if not best_price:
            msg = "Quandl's data source is incomplete. Could not get best price for %s/%s on %s." % (
                crypto, fiat, at_time
            )
            raise NoData(msg)

        return best_price, source, best_date
710163
def ticker
      ticker = get('/api/1/BTCUSD/ticker')
      Ticker.instance.buy         = value_currency ticker['buy']
      Ticker.instance.high        = value_currency ticker['high']
      Ticker.instance.price       = value_currency ticker['last_all']
      Ticker.instance.low         = value_currency ticker['low']
      Ticker.instance.sell        = value_currency ticker['sell']
      Ticker.instance.volume      = value_bitcoin ticker['vol']
      Ticker.instance.vwap        = value_currency ticker['vwap']
      Ticker.instance.avg         = value_currency ticker['avg']
      Ticker.instance.last_local  = value_currency ticker['last_local']
      Ticker.instance
    end
295048
def get_historical_info(self, symbol,items=None, startDate=None, endDate=None, limit=None):
        
        startDate, endDate = self.__get_time_range(startDate, endDate)
        response = self.select('yahoo.finance.historicaldata',items,limit).where(['symbol','=',symbol],['startDate','=',startDate],['endDate','=',endDate])
        return response
399439
def get_blockchain_fee_estimates(coin_symbol='btc', api_key=None):
    
    overview = get_blockchain_overview(coin_symbol=coin_symbol, api_key=api_key)
    return {
            'high_fee_per_kb': overview['high_fee_per_kb'],
            'medium_fee_per_kb': overview['medium_fee_per_kb'],
            'low_fee_per_kb': overview['low_fee_per_kb'],
            }
43301
def get_currencies(self, **params):
        """"""
        response = self._get('v2', 'currencies', params=params)
        return self._make_api_object(response, APIObject)
501553
def get_card_prices(ctx, currency):
    
    appid = ctx.obj['appid']

    detailed = True

    appids = [appid]
    if ',' in appid:
        appids = [appid.strip() for appid in appid.split(',')]
        detailed = False

    for appid in appids:
        print_card_prices(appid, currency, detailed=detailed)
        click.echo('')
1464
def get_dividendhistory(self, symbol, startDate, endDate, items=None):
        
        startDate, endDate = self.__get_time_range(startDate, endDate)
        response = self.select('yahoo.finance.dividendhistory', items).where(['symbol', '=', symbol], ['startDate', '=', startDate], ['endDate', '=', endDate])
        return response
378867
def get_prev_block_hash(block_representation, coin_symbol='btc', api_key=None):
    '''
    
    '''
    return get_block_overview(block_representation=block_representation,
            coin_symbol=coin_symbol, txn_limit=1, api_key=api_key)['prev_block']
1168917
def get_buy_price(self, **params):
        """"""
        currency_pair = params.get('currency_pair', 'BTC-USD')
        response = self._get('v2', 'prices', currency_pair, 'buy', params=params)
        return self._make_api_object(response, APIObject)
484294
def get_amount_in_base_currency(self, currency: str, amount: Decimal) -> Decimal:
        
        assert isinstance(amount, Decimal)

        # If this is already the base currency, do nothing.
        if currency == self.get_default_currency().mnemonic:
            return amount

        agg = self.get_currency_aggregate_by_symbol(currency)
        if not agg:
            raise ValueError(f"Currency not found: {currency}!")

        # TODO use pricedb for the price.
        rate_to_base = agg.get_latest_price()
        if not rate_to_base:
            raise ValueError(f"Latest price not found for {currency}!")
        assert isinstance(rate_to_base.value, Decimal)

        result = amount * rate_to_base.value
        return result
1014954
@Override
  public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {

    CoinsuperTradeHistoryParams coinsuperTradeHistoryParams = (CoinsuperTradeHistoryParams) params;
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("orderNoList", coinsuperTradeHistoryParams.getOrderNoList());

    CoinsuperResponse<List<OrderDetail>> orderDetails = orderDetails(parameters);
    // System.out.println(data);

    // CoinsuperUserTransaction[] coinsuperUserTransaction = null;

    return CoinsuperAdapters.adaptTradeHistory(orderDetails);
  }
854920
def convert_btc_to_cur(self, coins, currency):
        
        if isinstance(coins, Decimal):
            use_decimal = True
        else:
            use_decimal = self._force_decimal

        url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(currency)
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            price = data.get('bpi').get(currency, {}).get('rate_float', None)
            if price:
                if use_decimal:
                    price = Decimal(price)
                try:
                    converted_amount = coins * price
                    return converted_amount
                except TypeError:
                    raise DecimalFloatMismatchError("convert_btc_to_cur requires coins parameter is of type Decimal when force_decimal=True")
        raise RatesNotAvailableError("BitCoin Rates Source Not Ready For Given date")
1166701
def get_onchain_exchange_rates(deposit_crypto=None, withdraw_crypto=None, **modes):
    
    from moneywagon.onchain_exchange import ALL_SERVICES

    rates = []
    for Service in ALL_SERVICES:
        srv = Service(verbose=modes.get('verbose', False))
        rates.extend(srv.onchain_exchange_rates())

    if deposit_crypto:
        rates = [x for x in rates if x['deposit_currency']['code'] == deposit_crypto.upper()]

    if withdraw_crypto:
        rates = [x for x in rates if x['withdraw_currency']['code'] == withdraw_crypto.upper()]

    if modes.get('best', False):
        return max(rates, key=lambda x: float(x['rate']))

    return rates
255647
def get_ratefactor(self, base, code):
        
        raise RuntimeError("%s Deprecated: API withdrawn in February 2018" % self.name)
        try:
            rate = self.get_rate(code)
        except RuntimeError:
            # fallback
            return self.get_singlerate(base, code)

        self.check_ratebase(rate)
        ratefactor = Decimal(rate['price'])

        if base == self.base:
            return ratefactor
        else:
            return self.ratechangebase(ratefactor, self.base, base)
969777
def get_price(ctx, currency):
    """"""
    appid = ctx.obj['appid']
    title = ctx.obj['title']

    item_ = Item(appid, title)
    item_.get_price_data(currency)

    click.secho('Lowest price: %s %s' % (item_.price_lowest, item_.price_currency), fg='green')
1312177
def getTotalPrice(self):
        
        price = self.getPrice()
        price = Decimal(price or '0.00')
        vat = Decimal(self.getVAT())
        vat = vat and vat / 100 or 0
        price = price + (price * vat)
        return price.quantize(Decimal('0.00'))