Re: beancount.prices.sources.iex.IEXError: Invalid response (403): Forbidden

2019-06-19 Thread Zhuoyun Wei
It seems that IEX stopped prividing non-IEX data:


https://iextrading.com/developer/docs/

https://iextrading.com/developer/#sunset-schedule

-- 
Zhuoyun Wei

On Tue, Jun 18, 2019, at 02:01, matthew.piz...@gmail.com wrote:
> I think something is wrong with the IEX asset pricing source.
> 
> Something like this:
> `
> 2018-09-15 commodity UBER
>  price: "USD:iex/UBER"
> `
> 
> Results in something like this:
> `
> 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 
> 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
> `
> 
> 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?
> 
>  -- 
>  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+unsubscr...@googlegroups.com.
>  To post to this group, send email to beancount@googlegroups.com.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beancount/33b31600-3304-405b-8eb1-9f983890caac%40googlegroups.com
>  
> .
>  For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/4a44cd23-e246-4cb5-b925-f16b22e3fca8%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.


Recent updates to yegle/fava docker image

2019-06-19 Thread yegle
Hi,

I guess I should send an email since the image has some non-trivial total
download count.

I've changed the image from build from head to build from released versions
to make the image more stable and reproducible. I've also started
versioning the images based on fava versions and will keep the last few
versions.

I changed the base image from alpine to debian and as of yesterday to
distroless. This is to 1) improve the image build time (alphine uses musl
libc and cannot use the prebuilt binary on PyPI), 2) reduce the total image
size (distroless is small with CA certificates and OpenSSL), and 3) reduce
the attack surface (less binary included in the image -> improved security).

I included the beancount binaries (bean-check etc) in the image and you can
use them like this:

docker run --rm -it --entrypoint=bean-check yegle/fava

Please let me know if you have any questions at
https://github.com/yegle/fava-docker.

-- 
Yuchen Ying
https://about.me/yegle

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAFL5w3Ua9nOqUxWk5c4HuCi_gRZyHyTsj%2Bd_6fzfqPVWPvR7og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: beancount.prices.sources.iex.IEXError: Invalid response (403): Forbidden

2019-06-19 Thread 'Patrick Ruckstuhl' via Beancount

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

On 19.06.2019 01:56, matthew.piz...@gmail.com wrote:
I don't see that in `beancount.prices.sources`. I only see `iex`, 
`oanda`, `quandl`, and `yahoo`. I'm on 2.2.1.


On Monday, June 17, 2019 at 2:10:03 PM UTC-4, Patrick Ruckstuhl wrote:

Hi,

On 17.06.2019 19:20, matthe...@gmail.com  wrote:
>
> 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?


I'm using https://www.alphavantage.co/ they have a free offering
and has
also data from different countries.


Regards,

Patrick


--
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+unsubscr...@googlegroups.com 
.
To post to this group, send email to beancount@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/807e2284-fc44-4531-a4fd-5c0999d29b18%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/158c0a6b-5fec-54e6-2ae5-7672ad08ee29%40ch.tario.org.
For more options, visit https://groups.google.com/d/optout.


Re: beancount.prices.sources.iex.IEXError: Invalid response (403): Forbidden

2019-06-19 Thread Justus Pendleton
On Tuesday, June 18, 2019 at 12:20:00 AM UTC+7, matthe...@gmail.com wrote:

> 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?
>

Yahoo works fine. 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/94255b4b-ffe7-45eb-89ed-3adef242d9cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.