How to handle stale results from getquote

105 views
Skip to first unread message

Craig Earls

unread,
Dec 8, 2011, 12:39:53 AM12/8/11
to ledge...@googlegroups.com
I am very close to completing reimplementation of quote downloading in ledger 3 (it works completely on my machine but doesn't report problems in any sane way).  I have addressed bugs 174 (configurable getquote path) and 411 (don't keep trying to download if you receive a stale price).  Right now I am adding some sanity checking to the options and working on error reporting.  I should be able to push this to git within the next few days.  I need some advice on how people would prefer to handle the following situations:

NOTE: ledger assumes the getquote script returns the latest available price.

1.  Stale results: If getquote returns a price that is stale (age exceeds the --price-exp) should ledger silently accept that as the latest price, accept it and generate a warning, or generate an error and quit? Right now I have it silently accepting the stale value.

2.  Valid Option combinations:  --download does nothing if -V isn't specified.  Should ledger silently accept this, warn about the missing -V  option or stop and report?
   
I had hoped to address bug 588 ('getquote' only queries one commodity at a time, which can be slow) but this requires some significant changes to the internal flow ledger takes (ledger deals with commodities immediately as they are parsed, grouping commodities for a batch download would require two passes through the journal files)


--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com

thierry

unread,
Dec 8, 2011, 5:21:03 AM12/8/11
to Ledger
On Dec 8, 6:39 am, Craig Earls <ender...@gmail.com> wrote:
> NOTE: ledger assumes the getquote script returns the latest available price.
>
> 1.  Stale results: If getquote returns a price that is stale (age exceeds
> the --price-exp) should ledger silently accept that as the latest price,
> accept it and generate a warning, or generate an error and quit? Right now
> I have it silently accepting the stale value.

My comprehension, is that if "age exceeds the --price-exp" is *set*,
then I expect that it is not downloaded. I --price-exp is *not set*, I
would accept whatever value, old or not.

> 2.  Valid Option combinations:  --download does nothing if -V isn't
> specified.  Should ledger silently accept this, warn about the missing -V
> option or stop and report?

an option "--download" that does nothing, is this an option ? ;-) For
me here, a warn message is expected. I do not think a stop is
required.

My 2 cents
Thierry

Craig Earls

unread,
Dec 8, 2011, 7:31:38 AM12/8/11
to ledge...@googlegroups.com
I agree about warnings if options don't make sense.  I thought about making --download imply --market since that is the only way info from downloaded quotes is used.

As far as stale prices I think you are saying that if getquote returns a stale price it should be rejected as if it it were never downloaded.  Is that correct?

thierry

unread,
Dec 8, 2011, 10:30:35 AM12/8/11
to Ledger

On Dec 8, 1:31 pm, Craig Earls <ender...@gmail.com> wrote:
> I agree about warnings if options don't make sense.  I thought about making
> --download imply --market since that is the only way info from downloaded
> quotes is used.

A warning is enough for me. About implying, my personal way of working
is to prefer the explicit way to the implicit way, so I would prefer
here to not imply --market if --download is used. On the other side,
is there a use case of using --download without --market ? I do not
think so...

> As far as stale prices I think you are saying that if getquote returns a
> stale price it should be rejected as if it it were never downloaded.  Is
> that correct?

My first thoughts are:
- If price-exp=20111201, and stale price is *before* expiry date, then
silently do *not* accept that stale price.
- If *no* price-exp=20111201, then any stale price *is* acceptable.

Thierry

Craig Earls

unread,
Dec 8, 2011, 12:08:14 PM12/8/11
to ledge...@googlegroups.com
The more I think about it, the more I think --download should imply --market. 
As you said, there is no use case for only --download, and it really does nothing
without --market (the code is never executed and the internet query is never
attempted).  So, stating that you want ledger to query for prices implies you are
interested in those prices and should use them if available, ergo --download implies --market.

ledger will error if --download is specified but not (--getquote and --price-exp ).  (--getquote "path"
is the new option to specify the location of the script)

As far as stale prices go, the internet is only queried if there is no price already known, or
that price's age in minutes exceeds --price-exp.  If the user-supplied price script
returns the latest value it can find and there was no price already known, that price
should be used.  If that price is older than the price already known, the newer price
should be used, and no more queries should be made during this run of ledger. 

If the age of the price returned from the script exceeds --price-exp, ledger should issue a
warning, but continue executing.

Are there cases where people want it to error (stop processing) on getting a stale price?

thierry

unread,
Dec 8, 2011, 4:12:14 PM12/8/11
to Ledger
sounds good for me
Reply all
Reply to author
Forward
0 new messages