npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

crypto-trans

v0.1.6

Published

CLI program to help crypto investors query their portfolio data from a csv file

Downloads

16

Readme

crypto-trans CLI

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

crypto-trans CLI Video Demo

https://user-images.githubusercontent.com/48621790/182963152-168ea935-7366-4b98-93b1-fcbed3028fef.mov

Table of Contents

  1. CLI Usage
  2. CLI Help Info
  3. Usage
  4. Design
    1. /index.js
    2. /utils
    3. /lib
    4. /lib/index.js
    5. /lib/portfolio
    6. /lib/portfolio/csv
    7. /lib/portfolio/index.js
    8. /lib/portfolio/portfolioBalance.js
    9. /lib/service
    10. /lib/api
    11. /lib/validation
  5. Cache key standard
  6. More Details about crypto-trans
  7. Upcoming features

CLI Usage

  crypto-trans help                      Print help
  crypto-trans                           get all portfolio balances for each token
  crypto-trans -d 25-10-2019 -t ETH      query portfolio by date and token
  crypto-trans -d 25-10-2019             query portfolio by date
  crypto-trans -t BTC                    query portfolio by token

CLI Help Info

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

Repo Usage

  • Clone/download the repo.
  • npm i
  • npm link (this will allow you to use the crypto-trans command to run any cli commands in the repo from your terminal).
  • Design

    Architectural and Design patterns.
    • /index.js

      this is the main CLI root file.
    • /utils

      here we have all the helpers stored in seperate files to be used in anywhere in the lib DIR.
    • /lib

      here we store all the main logic for the cli program seperated in folders for scalability and maintainability.
    • /lib/index.js

      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 the readCsvTransStream 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 the checkCmnd function that will then send it to the portfolioBalanceSummary function in the /lib/portfolio/portfolioBalance.js file that will then show the user portfolio summary in the terminal.
    • /lib/portfolio

      here we store the main logic for portfolio related actions and csv file data.
    • /lib/portfolio/csv

      here we store all the user csv transaction files to read from it later on in /lib/portfolio/index.js.
    • /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.
    • /lib/portfolio/portfolioBalance.js

      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.
    • /lib/service

      here we have the initial node-cache setup and we can include any business logic here later on.
    • /lib/api

      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.
    • /lib/validation

      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.

Cache Key Naming Conventions

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 be token_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 be date_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.

More Details about crypto-trans

  • Checkout crypto-trans for further more details about crypto-trans CLI and upcoming releases.

Upcoming features

  • 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.