Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Cryptocurrency API Route #11

Open
prikhi opened this issue Jan 23, 2021 · 2 comments
Open

Add Support for Cryptocurrency API Route #11

prikhi opened this issue Jan 23, 2021 · 2 comments

Comments

@prikhi
Copy link
Owner

prikhi commented Jan 23, 2021

Need some way to specify the cryptomarket & which currencies should hit this route instead of the stock route.

https://www.alphavantage.co/documentation/#currency-daily

@the-solipsist
Copy link

the-solipsist commented Jan 30, 2021

Alphavantage provides two lists CSV files of of the currencies they handle, which I've used thusly in a bash script for myself:

curl -s https://www.alphavantage.co/physical_currency_list/ | \
  awk -F',' '{print $1}' > /tmp/currency-list

curl -s https://www.alphavantage.co/digital_currency_list/ | \
  awk -F',' '{print $1}' >> /tmp/currency-list

hledger -f $all_file -f $foreign_file stats | \
  grep -E '^Commodities' | grep -w -o -f /tmp/currency-list > /tmp/valid-currencies

readarray -t foreign_currencies < /tmp/valid-currencies

So, you could similarly checking commodity names and aliases against those two lists.

prikhi added a commit that referenced this issue May 29, 2021
Add a getDailyCryptoPrices function to the AlphaVantage module for
fetching prices for a cryptocurrency.

Have the fetchPrices function take a list of cryptocurrencies in
addition to the CommoditySymbols from a ledger file. It will split the
commodities into equities & cryptos and hit the appropriate AlphaVantage
route to get the prices.

Add a `cryptocurrencies` configuration option and `-c`/`--crypto` flags
to the exe, allowing users to specify the cryptocurrencies to fetch
prices for.

Eventually, we should ditch manual specification & use AlphaVantage's
supported Digital Currency list:
https://www.alphavantage.co/digital_currency_list/

Refs #11
@prikhi
Copy link
Owner Author

prikhi commented May 29, 2021

Latest master has cryptocurrency support but it requires manual specification w/ cli flags or configuration options(see README or --help).

Eventually it'd be cool to use that digital_currency_list CSV that alphavantage provides. Maybe something like:

  1. fetch CSV, save in $XDG_CACHE_DIR
  2. write current time to $XDG_CACHE_DIR, use to bust cached CSV file daily/weekly
  3. In fetchPrices, fetch/read CSV file & use to split commodities into equites & cryptos.

I'll leave this open until I implement that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants