Table of Contents
Command line tool that takes transactions in csv file and token cryptocurrency type and date, then it returns portfolio value depends on given arguments.
- chalk display colorful text in the console
- dotenv used to externalize private constants like API keys
- nanospinner used to create spinners in async actions
- node-fetch contains fetch to do http calls
- yargs used to handle command line arguments and options
Here are some examples how you can use the command line localy:
To see command line options and usage you can just specify --help
option:
portfoliogen --help
Usage: portfoliogen [option=...]
Options:
-p, --file-path Set csv file path to process [required]
-t, --token Set target token [choices: "BTC", "ETH", "XRP"]
-d, --date Set target date, date should be in yyyy-mm-dd format
--help Show help
As you see --file-path
option is required to specify csv file path but the other options are optional.
Lastly this is an example if you provide all options:
portfoliogen --file-path=./res/transactions.csv --token=BTC --date=2019-10-25
nanospinner will be animated until you get the result:
⠹ processing transactions.csv ...
this is result:
✔ latest portfolio value for BTC : 218826.640407
Sample from the csv file :
timestamp,transaction_type,token,amount
1571967208,DEPOSIT,BTC,0.298660
1571967200,DEPOSIT,ETH,0.683640
1571967189,WITHDRAWAL,ETH,0.493839
The csv file should have following columns
- timestamp: Integer number of seconds since the Epoch
- transaction_type: Either a DEPOSIT or a WITHDRAWAL
- token: The token symbol
- amount: The amount transacted
You can get csv file transactions.csv
used in the example from transactions.csv