Giter Club home page Giter Club logo

node-xrp-tax's Introduction

XRP Tax

This is a collection of scripts to prepare tax for crpyto (not necessarily XRP) sales. The majority of this project deals with XRP Ledger, so it is called "XRP Tax". The end product is a csv file that can be uploaded to http://www.easytxf.com.

Things to note

  • Terminology:
    • Symbol: The currency being traded.
    • Currency: The currency you paid/got when buying/selling Symbol.
  • USDT is considered USD.
  • The csv format (except that of the end product) is bitcoin.tax format1.
  • The Source column is overloaded. If Action is SEND, Source is actually destination.
  • Only LIFO (Last-In, First-Out) method is implemented.
  • LIFO method is universally applied for a Symbol no matter where the trade actually happened.
  • Like-kind exchange is not supported. If Currency is not USD, it will be converted into USD price.

Install dependencies

npm install -g bignumber.js csv dateformat fs lodash node-fetch ripple-lib yargs

Example

Suppose one guy has traded XRP on XRP Ledger, bitstamp and poloniex. He has transferred XRP back and forth between these exchanges. He wants to get a TXF file for the XRP trades he did in 2018 so that he can import it into TurboTax.

He has an addresses.json file which looks like:

{
  "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B": "~Bitstamp",
  "rpdADzXQJrnHKDJV9p7A4UwHsjT3rhm2cx": "~RippleTradeXRPBonus",
}

A hint.json file which looks like:

{
  "~RippleTradeXRPBonus": "Gift",
}

Bitstamp transaction history file:

bitstamp/Transactions.csv

Poloniex history files:

poloniex/depositHistory.csv
poloniex/tradeHistory.csv
poloniex/withdrawalHistory.csv

The following commands will generate a file that can uploaded to easytxf.com.

node XRPL/getTransactions.js --account $ACCOUNT --output transactions.json
node XRPL/exportTrades.js --account $ACCOUNT --input transactions.json --addresses addresses.json --cost_basis_hint hint.json  > xrpl.csv
# Find out the timestamp for all trades if it is a Gift or if Currency is not USD.
node XRPL/extractPricePoint.js --input xrpl.csv --output usd.json
# Fill usd.json with XRP price in USD. Some requests may fail due to rate-limiting. Retry as needed.
node XRPL/fillPricePoint.js --input usd.json
# Replace price with price in USD if Currency is not USD.
node XRPL/replacePrice.js --input xrpl.csv --price_file usd.json > xrpl_usd.csv
node bitstamp.js --symbol XRP --input bitstamp/Transactions.csv > bitstamp.csv
node poloniex.js --type deposit --input poloniex/depositHistory.csv  > poloniex.csv
node poloniex.js --type trade --input poloniex/tradeHistory.csv  >> poloniex.csv
node poloniex.js --type withdraw --input poloniex/withdrawalHistory.csv  >> poloniex.csv
cat bitstamp.csv poloniex.csv xrpl_usd.csv > unsorted.csv
sort -t, -k1,1 -k3,3r -k5,5 unsorted.csv > sorted.csv
# Merge a SEND with the immediate next RECEIVE if RECEIVE is equal to or slightly less than SEND.
node mergeSendReceive.js --input sorted.csv > xrp.csv
node profit.js --input xrp.csv --year 2018 --combine --easytxf > easytxf.csv

Upload the last file to easytxf.com to get a txf file XRP.txf. easytxf.com assumes the cost basis is either short-term covered or long-term covered. It needs to be changed with:

# Change short-term covered (321) to short-term noncovered (711)
# Change long-term covered (323) to long-term noncovered (713)
# They should have been short-term not reported (712) and long-term not reported (714)
# respectively. But somehow TurboTax (as of 2020) doesn't recognized them.
sed -i -e 's/N321/N711/' -e 's/N323/N713/' XRP.txf

1 The format doesn't really matter. I used to use bitcoin.tax, not anymore. โ†ฉ

node-xrp-tax's People

Contributors

r0bertz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.