aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO4
-rw-r--r--LICENSE4
-rw-r--r--PKGBUILD4
-rw-r--r--README.md29
-rw-r--r--api.c28
-rw-r--r--api.h3
-rw-r--r--tick.137
7 files changed, 79 insertions, 30 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 34970d2819ed..f6cad1408103 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = tick
- pkgdesc = Command line stock tracker
- pkgver = 1.2.0
+ pkgdesc = Command line stock and cryptocurrency portfolio tracker.
+ pkgver = 1.3.0
pkgrel = 1
url = https://github.com/aokellermann/tick
arch = x86_64
diff --git a/LICENSE b/LICENSE
index 5f26801b3da7..7d8375fd42af 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8,4 +8,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Data provided for free by IEX. Please read IEX's license: https://iextrading.com/api-exhibit-a
-Data provided for free by Alpha Vantage. https://www.alphavantage.co \ No newline at end of file
+Data provided for free by Alpha Vantage. https://www.alphavantage.co
+
+Data provided for free by Coinmarketcap. https://coinmarketcap.com/ \ No newline at end of file
diff --git a/PKGBUILD b/PKGBUILD
index 8eb8bab9b94e..f60f2c5e7bd0 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,9 +1,9 @@
# Maintainer: Antony Kellermann <aokellermann@gmail.com>
pkgname=tick
-pkgver=1.2.0
+pkgver=1.3.0
pkgrel=1
-pkgdesc="Command line stock tracker"
+pkgdesc="Command line stock and cryptocurrency portfolio tracker."
arch=("x86_64")
url="https://github.com/aokellermann/${pkgname}"
license=('MIT')
diff --git a/README.md b/README.md
index 5119e4927b6e..2e7bed843bcd 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
-### Command line stock price tracker. Information is taken from IEX and Alpha Vantage's web API.
-##### How to install:
+## Command line stock and cryptocurrency portfolio tracker.
+##### Information is taken from IEX, Alpha Vantage, web API.
+#### How to install:
```bash
$ git clone https://github.com/aokellermann/tick.git
$ cd tick
@@ -10,11 +11,11 @@ If you are an Arch user, you can install from the AUR.
```bash
$ yaourt -S tick
```
-##### Usage
+#### Usage
To update your portfolio, use the options add, rm, or set. You may use the
special string "USD$" to add US Dollars to your portfolio.
```bash
-$ tick [add/rm/set] [symbol/USD$] [quantity of shares] [USD spent]
+$ tick [add/rm/set] [symbol/crypto_id/USD$] [quantity of shares] [USD spent]
```
For example, to add 3 shares of Tesla bought for $918.12 total, run
```bash
@@ -23,21 +24,27 @@ $ tick add tsla 3 918.12
The parameter "add" will add your input to the current portfolio, "rm" will
subtract from your current portfolio, and "set" will set your portfolio to
the input, discarding any existing data about that security. Trading costs/fees
-should be factored into your USD spent.
+should be factored into your USD spent. When adding a cryptocurrency to your
+portfolio, you must use the cryptocurrency's name. For instance, to add Ripple,
+you must use "ripple" instead of "xrp". This is due to some cryptocurrency
+tickers also being listed on the stock market, such as ETH.
To get info about your current holdings, run
```bash
-$ tick check [symbol/all]
+$ tick check [symbol/crypto_id/all]
```
+The string "all" will list your entire portfolio, as well as produce a grand
+total.
+
Please be aware that printing information for mutual funds and over-the-counter
securities may take up to 10 seconds each. This is due to Alpha Vantage's
-relatively slow API. Regular NYSE and NASDAQ listed stocks and ETFs should
-take less than one second to print each.
+relatively slow API. NYSE and NASDAQ listed stocks and ETFs, as well as cryptocurrencies
+should take less than one second to print each.
-Once installed, you may read the man page for more information.
+Once installed, you may read the man page for more information. Prices are
+taken from IEX, Alpha Vantage, and Coinmarketcap's web APIs.
-##### Future Ideas
-* Merge with getcrypt for crypto support
+#### Future Ideas
* Command to get info about a security
* More robust information in "check"
* Historical support -- 24h/7d profits \ No newline at end of file
diff --git a/api.c b/api.c
index 2a4b72cfaac3..620ef83f0acd 100644
--- a/api.c
+++ b/api.c
@@ -56,6 +56,9 @@ double api_get_current_price(char* ticker_name_string) {
val = alphavantage_get_current_price(ticker_name_string);
if (val != -1)
return val;
+ val = coinmarketcap_get_current_price(ticker_name_string);
+ if (val != -1)
+ return val;
return -1;
}
@@ -112,6 +115,31 @@ double alphavantage_get_current_price(char* ticker_name_string) {
return ret;
}
+double coinmarketcap_get_current_price(char* ticker_name_string) {
+ char* cmc_str = "https://api.coinmarketcap.com/v1/ticker/";
+ char* coinmarketcap_api_string = calloc(64, sizeof(char));
+ memcpy(coinmarketcap_api_string, cmc_str, 40);
+ memcpy(&coinmarketcap_api_string[40], ticker_name_string, 20);
+ String* pString = api_curl_data(coinmarketcap_api_string);
+ if (pString->data[0] == '{'){
+ free(coinmarketcap_api_string);
+ api_string_destroy(&pString);
+ return -1;
+ }
+ int i = 0;
+ for (int j = 0; j < 19; i++, j++)
+ while (pString->data[i] != '"')
+ i++;
+ char* price_string = (char*)calloc(16, 1);
+ for (int j = 0; pString->data[i] != '"'; i++, j++)
+ price_string[j] = pString->data[i];
+ free(coinmarketcap_api_string);
+ double ret = strtod(price_string, NULL);
+ free(price_string);
+ api_string_destroy(&pString);
+ return ret;
+}
+
void api_string_destroy(String** phString) {
String* pString = *phString;
free(pString->data);
diff --git a/api.h b/api.h
index 07650528f41f..268568fafd21 100644
--- a/api.h
+++ b/api.h
@@ -66,6 +66,9 @@ double iex_get_current_price(char* ticker_name_string);
*/
double alphavantage_get_current_price(char* ticker_name_string);
+
+double coinmarketcap_get_current_price(char* ticker_name_string);
+
/**
* Destroys STRING object and frees memory
* @param phString the String to destroy
diff --git a/tick.1 b/tick.1
index 5c4534679309..0c5e2def2c13 100644
--- a/tick.1
+++ b/tick.1
@@ -1,30 +1,32 @@
-.TH TICK "1" "January 2018" "Tick 1.2.0" "User Commands"
+.TH TICK "1" "January 2018" "Tick 1.3.0" "User Commands"
.SH NAME
-Tick - Command line stock price tracker.
+Tick - Command line stock and cryptocurrency portfolio tracker.
.SH SYNOPSIS
tick [OPTION]...
.SH DESCRIPTION
-Create your portfolio by adding your current holdings. Then, you can use the built in functions to get information on the current price. Stock information taken from IEX and Alpha Vantage's free API.
+Create your portfolio by adding your current holdings. Then, use the option "check" to get information on the current price.
.SS
Portfolio:
.TP
-[add/rm/set] [symbol/USD$] [quantity of shares] [USD spent]
-Either adds, removes, or sets the amount of the given stock with respect to the given values. The parameter add will add your
-input to the current portfolio, rm will subtract from your current portfolio, and set will set your portfolio to the input,
-discarding any existing data about that stock. Trading fees should be factored into "USD SPENT". "Symbol" may also be input
-as "USD$" for US Dollars. This is good for keeping track of how much money is unallocated in your brokerage account. Typically,
-your initial amount of USD can be added as "tick add USD$ [amount] [amount]", where [amount] is the same number. When you are
-paid dividends or capital gains that are not reinvested into a specific security, you should update your portfolio with
-"tick add USD$ [dividend/capital gain amount] 0".
+[add/rm/set] [symbol/crypto_id/USD$] [quantity of shares] [USD spent]
+Either adds, removes, or sets the amount of the given stock with respect to the given values. The parameter "add" will add
+your input to the current portfolio, "rm" will subtract from your current portfolio, and "set" will set your portfolio to
+the input, discarding any existing data about that security. Trading fees should be factored into "USD SPENT". As an exception,
+cryptocurrencies must be specified by their name (e.g. "ripple", instead of "xrp"), due to duplicate tickers in both the
+US stock market and the cryptocurrency market. You may also input as "usd$" for US Dollars. This is helpful for keeping
+track of how much money is unallocated in your brokerage account. Typically, your initial amount of USD can be added as
+"tick add USD$ [amount] [amount]", where [amount] is the same number. When you are paid dividends or capital gains that
+are not reinvested into a specific security, you should update your portfolio with "tick add USD$ [dividend/capital gain amount] 0".
.TP
-[check] [currency name/all]
-Prints information about your current portfolio holdings. Either a symbol or the keyword 'all' can be used. The keyword 'all' will print information about all your current holdings, as well as a grand total.
+[check] [currency name/crypto_id/all]
+Prints information about your current portfolio holdings. Either a symbol or the keyword 'all' can be used. The keyword "all"
+will print information about all your current holdings, as well as a grand total.
.SH FILES
.I ~/.tick_portfolio
@@ -35,4 +37,11 @@ Portfolio file.
Please report any bugs using the GitHub issue tracker: https://github.com/aokellermann/tick/issues
.SH AUTHORS
-Antony Kellermann -- https://github.com/aokellermann \ No newline at end of file
+Antony Kellermann -- https://github.com/aokellermann
+
+.SH LICENSE
+MIT License
+
+Stock information is taken from IEX's free API. Mutual fund and over-the-counter information is taken from Alpha Vantage's
+free API. Cryptocurrency information is taken from Coinmarketcap's free API. Please do not abuse the APIs by repeatedly requesting
+information. Read the provided license for more information. \ No newline at end of file