Ejemplo n.º 1
0
 def btc_price(date_input):
     get_date = datetime.strptime(date_input, "%Y-%m-%d")
     # Create price object
     try:
         fx = fx_price_ondate('USD', current_app.fx['code'], get_date)
         price = price_ondate("BTC", get_date)['close'] * fx
     except Exception as e:
         logging.error("Not Found. Error: " + str(e))
         price = 0
     return (price)
Ejemplo n.º 2
0
def getprice_ondate():
    # Get the arguments and store
    if request.method == "GET":
        date_input = request.args.get("date")
        ticker = request.args.get("ticker")
        if (not ticker) or (not date_input):
            return 0
        ticker = ticker.upper()
        get_date = datetime.strptime(date_input, "%Y-%m-%d")
        # Create price object
        try:
            price = str(price_ondate(ticker, get_date).close)
        except Exception as e:
            price = "Not Found. Error: " + str(e)
        return price
Ejemplo n.º 3
0
 def test_price_ondate(self):
     dates = ['1/1/19']
     tickers = ['BTC', 'GBTC']
     for date in dates:
         for ticker in tickers:
             price_ondate(ticker, date)