Coder Social home page Coder Social logo

prikhi / hledger-stockquotes Goto Github PK

View Code? Open in Web Editor NEW
19.0 6.0 3.0 111 KB

Generate an HLedger Journal Containing Daily Stock & Crypto Quotes for your Commodities

Home Page: https://hackage.haskell.org/package/hledger-stockquotes

License: BSD 3-Clause "New" or "Revised" License

Haskell 100.00%
hledger stock-prices alpha-vantage stock-quotes api-client ledger-cli finance quotes cryptocurrencies crypto-prices

hledger-stockquotes's People

Contributors

prikhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hledger-stockquotes's Issues

Make Output File Name Optional

Default it to something like prices.journal if not passed as an argument.
Or something like <input-filename>.prices.journal

Allowing Passing Commodities to Fetch OR Commodites to Exclude?

From @simonmichael:

I wondered how it would be to handle args like:

hledger-stockquotes [ COMM ... | not:COMM ... ]

where no args means all the commodities in the journal (except AUTO, for now); negative args (beginning with not:) excludes those commodities; positive args selects only those commodities; and a mix of positives and negatives is an error.

Add Flag to Set Start/End Dates to Earliest/Latest Day of Year

Currently, the start/end dates are based on the entry dates in the journal file. Start is the earliest entry's date, end is the last entry's date.

Add a new flag to set the start/end dates to the first day of the earliest year and the last day of the latest year, respectively.

needs examples / more informative errors ?

Hi @prikhi, thanks for this nice command. I'd like to list it with the other third-party addons (iadd, interest) and have hledger-install.sh install it. To make it more user ready, I'll file a few wishlist issues here if that's ok ?

Some examples, as complete and reproducible as possible, will be a big help for users getting started. I had some trouble getting it to work when run as hledger stockquotes; hledger-stockquotes is working better. My biggest question at the moment is which commodities can be fetched. Could you explain the failures below - unsupported commodities, wrong symbols, rate limit exceeded, flaky api, or... ?

~/src/hledger$ cat commodities.journal 
commodity USD 0.00
commodity EUR 0.00
commodity GBP 0.00

commodity AAPL 0.00
commodity TSLA 0.00

commodity ADA 0.000000
commodity BTC 0.00000000
commodity ETH 0.000000
~/src/hledger$ hledger-stockquotes -f commodities.journal -n
Error Fetching Symbol `ADA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `BTC`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `EUR`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `GBP`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `TSLA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"

I tried it again respecting the rate limit (pretty slow!). This time it fetched TSLA:

~/src/hledger$ hledger-stockquotes -f commodities.journal 
Error Fetching Symbol `GBP`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Waiting 60 seconds to respect API rate limits.
Error Fetching Symbol `ADA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `BTC`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `EUR`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"

I commented out all but AAPL and TSLA and saw intermittent failures:

~/src/hledger$ hledger-stockquotes -f commodities.journal 
~/src/hledger$ hledger-stockquotes -f commodities.journal 
~/src/hledger$ hledger-stockquotes -f commodities.journal 
Error Fetching Symbol `TSLA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
~/src/hledger$ hledger-stockquotes -f commodities.journal 
Error Fetching Symbol `AAPL`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `TSLA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
~/src/hledger$ hledger-stockquotes -f commodities.journal 
Error Fetching Symbol `AAPL`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `TSLA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
~/src/hledger$ hledger-stockquotes -f commodities.journal 
Error Fetching Symbol `AAPL`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `TSLA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
~/src/hledger$ hledger-stockquotes -f commodities.journal 
Error Fetching Symbol `AAPL`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
Error Fetching Symbol `TSLA`: JsonHttpException "Error in $: key \"Time Series (Daily)\" not found"
~/src/hledger$ hledger-stockquotes -f commodities.journal 
~/src/hledger$ hledger-stockquotes -f commodities.journal 

Is their rate limiting really strict, is yours not entirely effective, or is it not a rate limit issue ? Might there be more error details that could be reported ?

Allow Aliasing Commodity Symbols

From @simonmichael:

Some way to alias commodity symbols, since we don't all use the standard ticker symbols.

Maybe for when the config file is done(#6):

commodity-aliases:
  <journal-commodity>: <ticker-symbol>

E.g.,:

commodity-aliases:
  RETIRE: VFFVX

Add CLI & Env Variable Support for Aliases

#14 added aliases to the config file, we should also figure out a format for passing them in as CLI options & through environmental variables.

Maybe allow multiple CLI flags like --some-flag JOURNAL_CURRENCY:ALPHAVANTAGE_TICKER to assemble the list, maybe a similar alias format deliminated with semicolons for the env var like SOME_VAR="JCUR1:ATICKER1;JCUR2:ATICKER2"

Add Flag to Set API Requests Per Minute

Instead of a binary on/off value for limiting the API requests, replace the -n flag with a flag that lets you set the requests per minute(with a default value of 5).

Add Additional Ways to Pass Input File & API Key

Support reading of the LEDGER_FILE env var for the input file, and an ALPHAVANTAGE_KEY var for the API key.

Support reading a config file at ~/.config/stockquotes/config.yml or something for specifying the default values.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.