bulk load of historical commodity prices

Stuart McGraw smcg4191 at frii.com
Sat Mar 24 16:38:54 EDT 2012


On 03/24/2012 09:19 AM, John Ralls wrote:
> 
> On Mar 23, 2012, at 10:13 PM, Stuart McGraw wrote:
> 
>> I have some questions about commodity prices in Gnucash...
>> 
>> I would like to do a bulk load of historical prices for several
>> stocks and mutual funds.  I am using a Postgresql database and
>> looking at the price and commodity tables in there, it seems like
>> it should be pretty straight forward.
>> 
>> First, I know mucking with the database is highly dis-recommended
>> so rather than asking if I can do this, I'll ask if there are any
>> specific known reasons why it will break something?
> Not in the price tables, no.
>> 
>> Secondly, I am wondering about the "value_num" and "value_denom"
>> columns in the "prices" table.  Is it necessary to reduce them 
>> to reduced fraction form (as they appear to be stored; that is,
>> $6.22 is stored as value_num=311, value_denom=50), or can I just 
>> store price*100 in "value_num" and 100 in "value_denom"?  (Just 
>> out of curiosity, why isn't the value stored as a integer multiple 
>> of the commodity's "fraction" value?)
> 
> Yes, you can store 6.22 as {622, 100}.  The GncNumeric class automatically reduces fractions when it does calculations because that guarantees the best chance of maintaining precision (fewer bits -> less chance of an overflow), but you needn't worry about it for input.
> 
>> 
>> Finally, is the "prices.source" value (which contains strings like
>> "Finance::Quote" and "user:price-editor") used for anything other
>> than display?  I.e., can I write "user:bulk-load" or similar in 
>> there?
> 
> As far as I know, yes.

Thanks, exactly what I'd hoped for!


More information about the gnucash-user mailing list