[GNC] Importing stock splits via csv

Marcus Pemer marcus at pemer.com
Fri Oct 28 07:14:23 EDT 2022


Hi Geoff

After running a few tests based on your working example, I can confirm that:


1.  Your example format works for me too - when manually formatting a CSV file according to your example and importing it, GnuCash correctly recognizes the transaction as a stock split.
2.  After fiddling with the test import file, it became clear that the imported transaction is recognized by GnuCash as a stock split transaction if and only if the first transaction split contains the account currency field with a valid currency.
3.  The currency provided in the first transaction split line in the file must be a valid currency from the GnuCash file, but it can be any one of the currencies defined - it does NOT have to match the currency of the account.
4.  The fact that GnuCash recognizes the transaction as a stock split is not affected neither by playing with the quantity/amount numbers for the two splits, nor by the price column. In fact I can omit the price altogether and the transaction will still be recognized as a stock split, as long as I have populated the currency field with a valid/defined currency in the first transaction split.


My initial attempts did not include any currency field (including it seemed unnecessary to me, since the stock split transaction only deals with the commodity, no fiat currency). In my case the account currency is "USD". Once I included a column for currency in the import file, and populated at least the first split line with "USD" in that column, the transaction was recognized as a stock split upon import. In my tests I also tried using "EUR" and "SEK" for import currencies and the results were the same as when I used "USD". In interest of being tidy I chose to use the account currency in my import conversion code, so in this particular example I will be using "USD".

As mentioned in my initial note I had been unable to find any mention of this behavior in the documentation, and my initial attempts to find the answer in the code repository had come up fruitless (albeit I did not spend much time on that track).
I would have been stuck if it weren't for your working example, so thank you again for the help - much appreciated.

Cheers,
Marcus Pemer
PGP: CC9E1BAA


------- Original Message -------
On Thursday, October 27th, 2022 at 21:17, Marcus Pemer <marcus at pemer.com> wrote:


> Thank you Geoff, a working example helps. I will try it and ideally if I can fiddle with the information I might be able to find out what causes the split to "take". Either way I will report back here when done.
> 

> Thanks again,
> Marcus Pemer
> 

> 

> PGP: CC9E1BAA
> 

> 

> 

> 

> 

> -------- Original Message --------
> On Oct 27, 2022, 13:17, Geoff < cleanoutmyshed at gmail.com> wrote:
> 

> > 

> > Hi Marcus This example works for me:- Date,Description,Commodity/Currency,Action,Full Account Name,Amount,Price 27-10-2022,NVIDIA 3 for 1 Stock Split,CURRENCY::AUD,Split,Assets:Investments:Broker Account:NVDA,-300,102.000000 ,,,,Assets:Investments:Broker Account:NVDA,900,34.000000 See attached screenshot and sample CSV file. Now I am not an accountant, but I believe that you need to supply valid prices with a stock split transaction - the "sell" price should be your accumulated cost base, and the "buy" price should be your new cost base after the split. If you do not do this you are likely to run into problems with capital gains (and imbalances as you experienced). Hope this helps! Regards Geoff ===== On 26/10/2022 8:40 pm, Marcus Pemer wrote: > Hello everyone! > > I have recently run into a conundrum that I hope someone would be able to help me with. > > I am importing transactions from a CSV file into a brokerage account. The CSV data containing the split looks like this: > > date,transactionid,description,account,credit,debit,action, price2022-08-25,44689940965,STOCK SPLIT (TSLA),tda_2061:TSLA,203,0,Split, 0.0 > ,44689940965,,Trading:Tradeables:TSLA,0,203,, 0.0 > > In other words, I have formatted the data as a multi-line split file for the importer. I am setting the action to Split and attempting to set the commodity price to 0.0 in both split lines. > > I have modeled the above import data based on what I see gets created if I manually create a stock split in GnuCash. Using the Stock Split tool in its simplest version creates a transaction with two splits: the first has action set to "Split" and the second split goes to the trading account. Prices are empty/null when the tool is used. > > I have turned off all Bayesian matching for the importer, if that matters. > > The problem I am facing is that when imported, the above transaction is not recognized as a stock split by the importer. Rather, the commodity price is overridden to 1.0 USD for both splits and my "Trading:Tradeables:TSLA: account gets switched out for "Imbalance-TSLA". > > Would anyone know how I should format the CSV import data so that the stock split gets recognized? Is it even possible/supported? I have so far not been able to find answers in the official documentation. > > > Thank you! > Marcus Pemer > PGP: CC9E1BAA > > > _______________________________________________ > gnucash-user mailing list > gnucash-user at gnucash.org > To update your subscription preferences or to unsubscribe: > https://lists.gnucash.org/mailman/listinfo/gnucash-user > ----- > Please remember to CC this list on all your replies. > You can do this by using Reply-To-List or Reply-All.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 855 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20221028/027f6c4d/attachment.sig>


More information about the gnucash-user mailing list