GithubHelp home page GithubHelp logo

mbrukman / csv2txf Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 5.0 45 KB

Convert stock sales from CSV to TXF for easy import into TurboTax

License: Apache License 2.0

Makefile 3.59% Python 85.12% Shell 11.29%
csv txf vanguard interactive-brokers taxes turbotax tdameritrade td-ameritrade

csv2txf's Introduction

csv2txf

Build Status

Overview

This package implements a simple converter from CSV files produced by brokers which include buy/sell transactions to the TXF format for import into tax software such as TurboTax.

Usage:

./csv2txf.py -f testdata/vanguard.csv --broker vanguard --year 2010

The converter internally converts broker-specific CSV format to a broker-independent internal representation, and then pretty-prints the data in TXF format, thus making it easy to add support for additional brokers.

Currently-supported brokers are:

  • Interactive Brokers
  • TD Ameritrade
  • Vanguard

Caveats

  1. This code is being provided as-is, in the hope that it will be useful, but without guarantees of correctness, so please be sure to verify that the output (and imported contents into your tax software) match your expectations.

    Verifying the correctness of the data entered should be easier and less tedious than manually entering it.

  2. This code was originally written in 2012 and has not been tested or updated since; if the non-standardized CSV format for any of the brokers has changed since then, you'll need to update it (and please add tests!).

  3. You may need to pre-process the CSV manually, or in your broker-specific importer to handle reconciliation and lot match-ups, which leads to the requirement that buy/sell pairs are consecutive and must match in security and number of shares.

    For a simple example, consider this sequence of transactions:

    BUY 100 shares ABC
    BUY 100 shares XYZ
    SELL 100 shares ABC
    SELL 100 shares XYZ
    

    You might say (correctly) that this is unambiguous and that having them listed consecutively is just extra work:

    BUY 100 shares ABC
    SELL 100 shares ABC
    BUY 100 shares XYZ
    SELL 100 shares XYZ
    

    but look at what happens when the situation is just slightly more complex:

    BUY 100 shares ABC @150 2002/10/10
    BUY 100 shares ABC @100 2002/10/15
    SELL 100 shares ABC @100 2003/10/10
    SELL 100 shares ABC @200 2003/10/11
    

    Here, by matching in FIFO mode, you'll come up with a different result than if you meant to do SpecId, with different long-term vs. short-term gains.

    This is further complicated if you buy larger lots and sell piece-wise, e.g.:

    BUY 200 shares ABC @150 2002/10/10
    SELL 100 shares ABC @100 2003/10/10
    SELL 100 shares ABC @200 2003/10/11
    

    which is why you need to do the pre-processing yourself to identify the lots, their cost basis, and the proceeds, and let the TXF printer just output what you have decided to use as your cost basis format.

    Unfortunately, CSV formats are not standardized amongst the brokers and may change at any time, so some custom (re-)formatting may be required for your broker's output.

Contributing

See CONTRIBUTING.md for details.

License

Apache 2.0; see LICENSE for details.

Disclaimer

This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.

csv2txf's People

Contributors

mbrukman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

csv2txf's Issues

Replace optparse with argparse

According to https://docs.python.org/2/library/optparse.html:

Deprecated since version 2.7: The optparse module is deprecated and will not be developed further; development will continue with the argparse module.

Since argparse is also available starting in Python 2.7, we aren't losing any compatibility with Python 2.x by switching to it, and we'll become forward-compatible with Python 3.x and beyond as optparse will likely be removed from Python stdlib at some point.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.