Created
June 8, 2017 00:12
-
-
Save BlinkyStitt/2ebc8b542529bbc50d4e161b84e704a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Click script to handle exports from the crypto-only exchange, Poloniex.""" | |
| import csv | |
| import click | |
| @click.command() | |
| @click.argument( | |
| 'loan_export', | |
| type=click.File('rt'), | |
| ) | |
| @click.argument( | |
| 'taxes_export', | |
| type=click.File('wt'), | |
| ) | |
| def loans2taxes(loan_export, taxes_export): | |
| """Convert Poloniex export to bitcoin.tax compatible csv.""" | |
| loan_reader = csv.DictReader(loan_export) | |
| tax_writer = csv.writer( | |
| taxes_export, | |
| ) | |
| tax_writer.writerow(['Date', 'Action', 'Memo', 'Source', 'Symbol', 'Volume']) | |
| for row in loan_reader: | |
| tax_writer.writerow([ | |
| row['Close'], | |
| 'INCOME', | |
| '{volume} {symbol} @ {rate:.2f}% on {date}'.format( | |
| volume=row['Amount'], | |
| symbol=row['Currency'], | |
| rate=float(row['Rate']) * 100, | |
| date=row['Open'], | |
| ), | |
| 'Poloniex Lending', | |
| row['Currency'], | |
| row['Earned'], # TODO: eventually smartlend will take a fee | |
| ]) | |
| if __name__ == '__main__': | |
| loans2taxes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment