Asset Allocations

David Boyce boycey3 at googlemail.com
Sun Aug 21 17:13:08 EDT 2016


(apologies hit send by accident rather than paste!)

I was wondering if anyone could offer me any advice on getting a stock
valuation out of GNUCash via SQL.

I'm looking to create a spreadsheet in Excel that gets data out of the
GNUCash database.  I'm looking to have a spreadsheet in excel that sets
each account type according to my own classification (cash, stock, bonds,
gold, fixed asset) etc and then be able to produce a report that says I
have X percentage saved as bonds etc.  I know perhaps I should do this
within GNUCash but the problem is some funds are weighted X across several
asset classes so I need to allocate them when producing the report).

I've got some code that gets a balance out for a cash account...

  Sql = "        SELECT "
  Sql = Sql & "    SUM(s.value_num / s.value_denom) as 'Value' "
  Sql = Sql & "  FROM "
  Sql = Sql & "    transactions As t "
  Sql = Sql & "    inner Join "
  Sql = Sql & "    splits As s "
  Sql = Sql & "    inner Join "
  Sql = Sql & "    accounts as a ON t.guid = s.tx_guid "
  Sql = Sql & "    && s.account_guid = a.guid "
  Sql = Sql & "  WHERE "
  Sql = Sql & "    a.guid = '" & thisGuid & "' AND "
  Sql = Sql & "    a.guid = '" & thisGuid & "' AND t.post_date <=
CURRENT_DATE() "

but for stock valuations I'm guessing I'll need something that takes each
buy/sell into consideration and the price.  If anyone would have any
advice, or have some code it would much appreciated,

best regards,

David


On Sun, Aug 21, 2016 at 10:09 PM, David Boyce <boycey3 at googlemail.com>
wrote:

> I was wondering if anyone could offer me any advice on getting a stock
> valuation out of GNUCash via SQL.
>
> I'm looking to create a spreadsheet in Excel that gets data out of the
> GNUCash database.  I'm looking to have a spreadsheet in excel that sets
> each account type (cash, stock, bonds, fixed asset) etc and then be able to
> produce a report that says I have X percentage saved as bonds etc.  I know
> perhaps I should do this within GNUCash but the problem is some funds are
> weighted X across several asset classes.
>
> I've got some code that gets a balance out for a cash account...
>
>


More information about the gnucash-user mailing list