Example usage

To use cryptocurrencyeda in a project:

Imports

from cryptocurrencyeda.retrieve_data import retrieve_data
from cryptocurrencyeda.plot_price import plot_price
from cryptocurrencyeda.avg_daily_return import avg_daily_return
from cryptocurrencyeda.daily_growth_rate import daily_growth_rate 

Retrieve price data and store it in a data frame

price_df = retrieve_data(symbol="BTC-USDT",
                  time_period="1day",
                  start_date="2018-01-01",
                  end_date="2022-01-10",
                 )

We can take a look at the head of the data frame.

price_df.head()
Symbol Date Close
0 BTC-USDT 2022-01-10 41816.3
1 BTC-USDT 2022-01-09 41877.6
2 BTC-USDT 2022-01-08 41680.5
3 BTC-USDT 2022-01-07 41561.4
4 BTC-USDT 2022-01-06 43086.1

Plot the price data

plot_price(price_df)

Calculate the daily growth rate

daily_growth_rate(price_df, "Close")
Symbol Date Close daily_growth_rate(%)
0 BTC-USDT 2022-01-10 41816.300000 NaN
1 BTC-USDT 2022-01-09 41877.600000 0.146594
2 BTC-USDT 2022-01-08 41680.500000 -0.470657
3 BTC-USDT 2022-01-07 41561.400000 -0.285745
4 BTC-USDT 2022-01-06 43086.100000 3.668548
... ... ... ... ...
1465 BTC-USDT 2018-01-06 16850.000001 3.990116
1466 BTC-USDT 2018-01-05 17266.663939 2.472783
1467 BTC-USDT 2018-01-04 15194.999997 -11.998056
1468 BTC-USDT 2018-01-03 15380.011104 1.217579
1469 BTC-USDT 2018-01-02 14100.000000 -8.322563

1470 rows × 4 columns

Calculate the average daily return

avg_daily_return(price_df["Close"])
-18.867460857726357