cryptfolio/README.md

32 lines
3 KiB
Markdown
Raw Permalink Normal View History

2024-05-09 10:00:56 -07:00
# Crypto Portfolio
2024-05-09 09:35:34 -07:00
2024-05-09 10:00:56 -07:00
This is a basic script to use `bash | jq` to process the contents of a `.json` "configuration" file and deliver the current status of a portfolio of crypto-currencies based on data retrieved from the [Kucoin API](https://www.kucoin.com/api) (which *requires no key*).
Results are delivered via an encoded [itty.bitty](https://about.bitty.site) url and can be downloaded as `csv` records.
[**Here is an example.**](https://itty.bitty.site/#Portfolio/XQAAAAT//////////wAeCEUG0O+oKBdZ2an16qclP3ZWSMUzhiDsEZ6qy1sgvhIq6Hr2L4YPd7IJhqr4o8AZqF9O9RftB9GDuVd2SlkYO7UY2awqwmBdB6MalZZnLcYV3O8NcFqO7TrHGf5CHNaQh3RY3FDPWDwhpMAQixOrVtPbWsnuwOKfsQtPTVqBibnT3EgSReJIx+p7vNOMDKV5s29g6OWtMkpuKgGXpwYnQtx3+8VrHAbsKHgM2MYHKk8sL6rdDCIPZQUWOW19GSrBC629KYV3J6BNWjcXhgW+B64age7uWmielfhcrbFdHJTt9P8PjQuYsHoLt6CELj/qKkzaaGn7ellVvKKm3VMSQx0zI0SGg328iuW6yDF0FNeS3S6sw8PovseMmn6nIg0M31y2WnvDylZVIVVjEXrEsV27XyVWpXiOGeLhmg5aYUqPlrqxBjiKbKUWpEwyoGIYLRXT1Tf2HYQQjXXICXACt69bI8+kHFkG3qyGlVXlZhKqcfa9gDUY9d3aB4OciyuZcy3cJTHZ0jQxqF9xO/Oqrg9RbSYTLsQQYdPyZpj9YprCNak7WcS+AwlyaMuEoNSE+/kq7vlKu9wcC7GRnirrFD12ydrvasGdHPsMFndVWuuKFq4jO7GCSrK6KzPi1yAkZYMsbhm132fgiCY4rBlEQFTwOqHn0TSqgpVFsfGCm7SwUldSHy3zzv0fLRsC9BTTEtbBU2ODylCMKVufr5EcHey76YvhumCd3YCqXf5zXpzPbFRLvi2HkL8Q8nb6Se4mfa5WYyh5hNaQLtyPb3X55iyvvnJmttyjTEhosbW5ucUCzYzb55n7kcImt+srD+YnjDEaERccGLNiFXJT0UUCo5LdUrViU1DbJTFpEEuA+5avLmw3KVmsR1jOdncSmYJ9oeBFpPp2h+Pl1zCDy4igbzKzsC+WJ0A2HM5ODjxfb/Sq5ULPxi+qZg51gmuLldJUofxYxekYESgEIwcL3zH5nqG5DcSlIX0Jtn1OD+7Xgp/NeT0rO97KTVy0yeeEpDytv8hUAkd8exAWtXOS/AfTAxrltVNPwx0ljsmBfWvLFaf+/Cl8jw==)
## How It Works
### Update Portfolio
Update the `wallet.json` file with an array of objects each containing the **token ID**, **amount you have invested**, and **balance** for each of your currencies.
> Make sure your token IDs match what is expected by the API. ([https://api.kucoin.com/api/v3/currencies](https://www.kucoin.com/docs/rest/spot-trading/market-data/get-currency-list))
### Execute Script
Simply run `portfolio.sh` manually or via `cron` as you like.
The script will read `wallet.json` for the tokens it needs to check and then make calls to the Kucoin API to determine prices, comparing that to your indicated balances and evaluating whether or not you are profiting.
The results are inserted into `template.html` using placeholders (via `sed`), which is then [encoded in itty.bitty](https://github.com/alcor/itty-bitty/wiki/#generating-links-programmatically) to be generated as a unique but constant webpage.
> You can bookmark the link, or click the "Download CSV" button (which uses some light JavaScript) to save the results.
## ntfy Alerts
While one can simply click on the generated link (or have it delivered any way, really), the `portfolio.sh` script comes pre-built with the functionality to deliver the results via a [ntfy](https://ntfy.sh) service.
The `wallet.json` file contains configuration options to specify the server and topic for delivery, and a message will be sent making the notification clickable, taking you directly to the results page.