Crypto-trans is an open source CLI program to help crypto investors query their portfolio data from large csv file.
Try the npm package out in your terminal npm i crypto-trans -g
Screen.Recording.2022-08-05.at.1.22.30.AM.mov
- CLI Usage
- CLI Help Info
- Usage
- Design
- Cache key standard
- More Details about crypto-trans
- Upcoming features
crypto-trans help Print help
crypto-trans get all portfolio balances for each token
crypto-trans -d 2019-10-25 -t ETH query portfolio by date and token
crypto-trans -d 2019-10-25 query portfolio by date
crypto-trans -t BTC query portfolio by token
crypto-trans <command> [option]
help Print help info
--token, -t query portfolio by token
--date, -d query portfolio by date
----------------------------------------- ---------------------------------------
EX: crypto-trans get all portfolio balances for each token
EX: crypto-trans -d 2019-10-25 -t ETH query portfolio by date and token
EX: crypto-trans -d 2019-10-25 query portfolio by date
EX: crypto-trans -t BTC query portfolio by token
-d, --date Transaction date value, format: YYYY-MM-DD
-t, --token Token symbol value, Ex: BTC
-c, --clear Clear the console Default: true
--noClear Don't clear the console Default: false
-debug, --debug Print debug info Default: false
-v, --version Print CLI version Default: false
- Clone/download the repo.
npm i
npm link
(this will allow you to use thecrypto-trans
command to run any cli commands in the repo from your terminal). Or, run the CLI using node with project open on the same DIR as the root file /index.jsnode index.js <command> [option]
-
Architectural and Design patterns.
- this is the main CLI root file.
- here we have all the helpers stored in seperate files to be used in anywhere in the lib DIR.
- here we store all the main logic for the cli program seperated in folders for scalability and maintainability.
-
here we have the main logic and starting point, as the user writes a command, the
checkCmnd
function will be called by the root /index.js file that sends along the flag args. And from here, we make the appropriate actions based on the user query input. First thing, we check the user query types along with query data validations. Second, we then check if the query data is already available in cache with the unique cached key to send it right away, otherwise we send the query data to thereadCsvTransStream
function in the /lib/portfolio/index.js file to read the csv file in chunks, and from here we send back the returned data to this file in thecheckCmnd
function that will then send it to theportfolioBalanceSummary
function in the /lib/portfolio/portfolioBalance.js file that will then show the user portfolio summary in the terminal. - here we store the main logic for portfolio related actions and csv file data.
- here we store all the user csv transaction files to read from it later on in /lib/portfolio/index.js.
- here we have we receive the potential query data, and read the large csv file using readStreams in chunks along with the calculations based on many factors like Deposit or Withdraw and then we also use this file to save the query data to the cache using node-cache.
- here we reach the final step in the process where the data is read and passed to this file to display the profile summary data in a table format. Also, we use the cryptocompare API from here /lib/api to get the token price for the portfolio calculations.
- here we have the initial node-cache setup and we can include any business logic here later on.
- here we use the cryptocompare API to get info about any cryptocurrency. For example, we used the API here to get the current USD price for the given token dynamically.
- here we have all the user input validations, like checking whether or not the user typed in a valid date or token before reading the csv file. incase of invalid input or missing query data, the CLI willl send feedback to the user.
As the CSV file can be quite large in size, the best way to store the data after readstream would be to save it in memory cache for easy access for later on when the user uses the same query command again to be retrieved from the cache instead of reading the large file. Please follow the cache key naming conventions below:
- For no query input, the cached key should be
tokens
. - For only token query input, the cached key should be dynamic. For example, if the user added BTC as the token query, then the cached key should be
token_BTC
. Where as, if the user query was ETH, then the cached key should betoken_ETH
. - For only date query input, the cached key should be dynamic. For example, if the user added 24-10-2019 as the date query, then the cached key should be
date_24-10-2019
. Where as, if the user query was 10-11-2018, then the cached key should bedate_10-11-2018
. - For date and token query input, the cached key should be dynamic. For example, if the user added 24-10-2019 as the date query and BTC for the token query, then the cached key should be
token_BTC_date_24-10-2019
.
- Checkout crypto-trans for further more details about crypto-trans CLI and upcoming releases.
- Allowing the user to type a path to a csv from the terminal (new flag
-csv [csv file path]
) hence, the code can read and query from any file the user wants.