2018-09-15 commodity UBER
price: "USD:iex/UBER"
Traceback (most recent call last):
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/shelve.py", line 111, in __getitem__
value = self.cache[key]
KeyError: '5f40c1783265eb0919e27627aed4d146'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/site-packages/beancount/prices/price.py", line 84, in fetch_cached_price
timestamp_created, result_naive = _CACHE[key]
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/shelve.py", line 113, in __getitem__
f = BytesIO(self.dict[key.encode(self.keyencoding)])
KeyError: b'5f40c1783265eb0919e27627aed4d146'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/h5bpd5swkwcgxhz05aaj430qja3v04js-python3.7-beancount-2.2.1/bin/.bean-price-wrapped", line 5, in <module>
from beancount.prices.price import main; main()
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/site-packages/beancount/prices/price.py", line 369, in main
price_entries = sorted(price_entries, key=lambda e: e.currency)
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/concurrent/futures/_base.py", line 586, in result_iterator
yield fs.pop().result()
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/site-packages/beancount/prices/price.py", line 159, in fetch_price
srcprice = fetch_cached_price(source, psource.symbol, dprice.date)
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/site-packages/beancount/prices/price.py", line 100, in fetch_cached_price
if time is None else
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/site-packages/beancount/prices/sources/iex.py", line 49, in get_latest_price
return fetch_quote(ticker)
File "/nix/store/bmq1vsmckm7vrfg4z0yyqb9jpddv6p6p-python3-3.7.3-env/lib/python3.7/site-packages/beancount/prices/sources/iex.py", line 30, in fetch_quote
response.text))
beancount.prices.sources.iex.IEXError: Invalid response (403): Forbidden
Hi,
Hi,
sorry, I was not clear on this. I created my own plugin, it
depends on an environment variable ALPHAVANTAGE_API_KEY and only
supports latest price
from beancount.prices import source
import datetime
from dateutil import tz
from dateutil.parser import parse
from beancount.core.number import D
import requests
from os import environ
from time import sleep
class Source(source.Source):
def get_latest_price(self, ticker):
params = {
'function': 'GLOBAL_QUOTE',
'symbol': ticker,
'apikey': environ['ALPHAVANTAGE_API_KEY'],
}
resp =
requests.get(url='https://www.alphavantage.co/query',
params=params)
data = resp.json()
if 'Note' in data:
sleep(60)
resp =
requests.get(url='https://www.alphavantage.co/query',
params=params)
data = resp.json()
priceData = data['Global Quote']
price = D(priceData['05. price'])
date = parse(priceData['07. latest trading day'])
us_timezone = tz.gettz("Europe/Zurich")
time = date.astimezone(us_timezone)
return source.SourcePrice(price, time, 'USD')
def get_historical_price(self, ticker, time):
return None
--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/807e2284-fc44-4531-a4fd-5c0999d29b18%40googlegroups.com.
What's the go-to price sources these days? I'm guessing that Yahoo and Google sources don't work anymore. What should I migrate to?