npm package: @phatpham9/crypto-portfolio-cli
Description: Cryptocurrency Portfolio CLI
Author: Phat Pham
Latest version: 0.0.4

<div align="center">
  <h1>crypto-portfolio-cli</h1>
  <p>Cryptocurrency Portfolio CLI</p>

  <p>
    <a href="https://www.conventionalcommits.org" aria-label="Commitizen Friendly">
      <img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square">
    </a>
    <a href="https://standardjs.com" aria-label="Standard - JavaScript Style Guide">
      <img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square">
    </a>
    <a href="https://github.com/phatpham9/crypto-portfolio-cli/actions/workflows/lint-build-test.yml" alt="lint-build-test status badge">
      <img src="https://github.com/phatpham9/crypto-portfolio-cli/actions/workflows/lint-build-test.yml/badge.svg">
    </a>
    <a href="https://www.npmjs.com/package/@phatpham9/crypto-portfolio-cli" aria-label="npm version">
      <img src="https://img.shields.io/npm/v/@phatpham9/crypto-portfolio-cli.svg?color=brightgreen&style=flat-square">
    </a>
    <a href="https://www.npmjs.com/package/@phatpham9/crypto-portfolio-cli" aria-label="npm downloads">
      <img src="https://img.shields.io/npm/dm/@phatpham9/crypto-portfolio-cli.svg?style=flat-square">
    </a>
    <a href="https://github.com/phatpham9/crypto-portfolio-cli/blob/master/LICENSE" aria-label="MIT License">
      <img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square">
    </a>
  </p>

  <img src="banner.png">
</div>

## Features

- [x] Read transactions data from comma-separated CSV file
- [x] Fetch token price in USD from [cryptocompare.com](https://cryptocompare.com)
- [x] Calculate portfolio value of a single or multiple tokens
- [x] Calculate portfolio value on a specific date in the history

## Techstack

- Language: [TypeScript](https://www.typescriptlang.org)
- CLI framework: [Commander.js](https://github.com/tj/commander.js)
- CLI utils: [Figlet](https://github.com/scottgonzalez/figlet-js) [cli-table](https://github.com/Automattic/cli-table)
- Testing framework: [Jest](https://github.com/facebook/jest) [cli-testing-library](https://github.com/gmrchk/cli-testing-library)
- CSV to JSON parser: [PapaParse](https://github.com/mholt/PapaParse)
- HTTP client: [Axios](https://github.com/axios/axios)
- Configuration: [node-config](https://github.com/node-config/node-config)
- CI/CD: [GitHub Actions](https://github.com/features/actions)
- Dev tools: [Standard](https://github.com/standard/standard) [commitlint](https://github.com/conventional-changelog/commitlint) [standard-version](https://github.com/conventional-changelog/standard-version) [lint-staged](https://github.com/okonet/lint-staged) [Husky](https://github.com/typicode/husky)

## Install

```sh
# run directly via npx
npx @phatpham9/crypto-portfolio-cli

# install as global module
npm install --global @phatpham9/crypto-portfolio-cli
```

## Usage

The CLI fetches price from [cryptocompare.com](https://cryptocompare.com). Please create an account and get your API key prior

```sh
# export cryptocompare API key
export CRYPTO_COMPARE_API_KEY=xxx

# read transactions data CSV file. by default it will look for ./data.csv in your current working directory
portfolio -f /path/to/csv/file

# portfolio of all tokens
portfolio

# portfolio of a BTC token
portfolio BTC

# portfolio of all tokens on 2023-01-01
portfolio -d 2023-01-01

# portfolio of a BTC token on 2023-01-01
portfolio -d 2023-01-01 BTC

# show help
portfolio -h
```

## Develop

Clone the repo in your local development, navigate to the project and run the following commands

```sh
# watch & rebuild changes
npm run build -- --watch

# run a command. e.g. show help
npm run start -- --help

# run test suite
npm run test

# lint code style
npm run lint

# lint & fix code style
npm run lint:fix

# release version
npm run release:as 1.0.0
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Authors

[Phat Pham](https://github.com/phatpham9)

## License

[MIT](https://github.com/phatpham9/crypto-portfolio-cli/blob/master/LICENSE)