Package: cad-capgains
Canadian Capital Gains CLI ToolCalculating your capital gains and tracking your adjusted cost base (ACB) manually, or using an Excel document, often proves to be a laborious process. This CLI tool calculates your capital gains and ACB for you, and just requires a CSV file with basic information about your transactions. The idea with this tool is that you are able to more or less cut-and-copy the output that it genarates and copy it into whatever tax filing software you end up using.Features:Supports transactions with multiple different stock tickers in the same CSV file, and outputs them in separate tables.Currently supports transactions done in both USD and CAD. For USD transactions, the daily exchange rate will be automatically fetched from the Bank of Canada.Will automatically applysuperficial capital lossrules when calculating your capital gains and ACB. This tool only supports full superficial capital losses, and does not support partial superficial losses. In sales with a superficial capital loss, the capital loss will be carried forward as perscribed by the CRA. A sale with a capital loss will be treated as superficial if it satisifies the following:Shares with the same ticker were bought in the 61 day window (30 days before or 30 days after the sale)There is a non-zero balance of shares sharing the same ticker at the end of the 61 day window (30 days after the sale)Outputs the running adjusted cost base (ACB) for every transaction with a non-superficial capital gain/lossInstallation# To get the latest releasepipinstallcad-capgainsCSV File RequirementsTo start, create a CSV file that will contain all of your transactions. In the CSV file, each line will represent aBUYorSELLtransaction.  Your transactionsmust be in order, with the oldest transactions coming first, followed by newer transactions coming later. The format is as follows:<yyyy-mm-dd>,<description>,<stock_ticker>,<action(BUY/SELL)>,<quantity>,<price>,<commission>,<currency>Here is a sample CSV file:# sample.csv
2017-2-15,ESPP PURCHASE,GOOG,BUY,100,50.00,10.00,USD
2017-5-20,RSU VEST,GOOG,SELL,50,45.00,0.00,CADNOTE: This tool only supports calculating ACB and capital gains with transactions
dating from May 1, 2007 and onwards.UsageTo show the CSV file in a nice tabular format you can run:$capgainsshowsample.csv
+------------+---------------+----------+----------+-------+---------+--------------+------------+|date|description|ticker|action|qty|price|commission|currency||------------+---------------+----------+----------+-------+---------+--------------+------------||2017-02-15|ESPPPURCHASE|GOOG|BUY|100|50.00|10.00|USD||2017-05-20|RSUVEST|GOOG|SELL|50|45.00|0.00|CAD|+------------+---------------+----------+----------+-------+---------+--------------+------------+To calculate the capital gains you can run:$capgainscalcsample.csv2017GOOG-2017[TotalGains=-1,028.54]+------------+---------------+----------+-------+------------+----------+-----------+---------------------+|date|description|ticker|qty|proceeds|ACB|outlays|capitalgain/loss||------------+---------------+----------+-------+------------+----------+-----------+---------------------||2017-05-20|RSUVEST|GOOG|50|2,250.00|3,278.54|0.00|-1,028.54|+------------+---------------+----------+-------+------------+----------+-----------+---------------------+Your CSV file can contain transactions spanning across multiple different tickers. You can filter the above commands by running the following:$capgainscalcsample.csv2017-tGOOG
...

$capgainsshowsample.csv-tGOOG
...For additional commands and options, run one of the following:$capgains--help

$capgains<command>--helpYou can take this output and plug it into your favourite tax software (Simpletax, StudioTax, etc) and verify that the capital gains/losses that the tax software reports lines up with what the output of this command says.Finding issuesIf you find issues using this tool, please create an Issue using theGithub issue trackerand one of us will try to fix it.ContributingIf you would like to contribute, please read theCONTRIBUTING.mdpage