Skip to main content

A python package to get historical market data of cryptocurrencies from CoinMarketCap, and calculate & plot different indicators.

Project description

Installation

pip

pip install PriceIndics

From Source (Github)

git clone https://github.com/dc-aichara/Price-Indices.git

cd Price-Indices

python3 setup.py install

Usages

from PriceIndices import MarketHistory, Indices

Examples

  • Get market history and closing price

>>> history = MarketHistory()

# Get Market History 

>>> df_history = history.get_history('bitcoin', '20130428', '20190624')  
>>> df_history.head()
        Date     Open*      High       Low   Close**       Volume    Market Cap
0 2019-06-23  10696.69  11246.14  10556.10  10855.37  20998326502  192970090355
1 2019-06-22  10175.92  11157.35  10107.04  10701.69  29995204861  190214124824
2 2019-06-21   9525.07  10144.56   9525.07  10144.56  20624008643  180293241528
3 2019-06-20   9273.06   9594.42   9232.48   9527.16  17846823784  169304784791
4 2019-06-19   9078.73   9299.62   9070.40   9273.52  15546809946  164780855869

# Get closing price

>>> price_data  =  history.get_price('bitcoin', '20130428', '20190624')  

>>> price_data .head()
        date     price
0 2019-06-23  10855.37
1 2019-06-22  10701.69
2 2019-06-21  10144.56
3 2019-06-20   9527.16
4 2019-06-19   9273.52
  • Calculate Volatility Index

>>> df_bvol = Indices.get_bvol_index(price_data )  
>>> df_bvol.head()
        date     price  BVOL_Index
0 2019-06-22  10701.69    0.636482
1 2019-06-21  10144.56    0.636414
2 2019-06-20   9527.16    0.619886
3 2019-06-19   9273.52    0.608403
4 2019-06-18   9081.76    0.604174
  • Plot Volatility Index

>>> Indices.get_bvol_graph(df_bvol)   

"""
This will return a plot of BVOL index against time also save volatility index plot in your working directory as 'bvol_index.png'
"""
  • Calculate Relative Strength Index (RSI)

>>> df_rsi = Indices.get_rsi(price_data)   

>>> print(df_rsi.tail())
           date   price  price_change   gain   loss  gain_average  loss_average        RS      RSI_1  RS_Smooth      RSI_2
2217 2013-05-02  105.21          7.46   7.46   0.00      1.532143      2.500000  0.612857  37.998229   0.561117  35.943306
2218 2013-05-01  116.99         11.78  11.78   0.00      2.373571      2.175714  1.090939  52.174596   0.975319  49.375257
2219 2013-04-30  139.00         22.01  22.01   0.00      3.945714      1.981429  1.991348  66.570258   1.869110  65.145981
2220 2013-04-29  144.54          5.54   5.54   0.00      3.878571      1.981429  1.957462  66.187226   2.206422  68.812592
2221 2013-04-28  134.21        -10.33   0.00  10.33      3.878571      2.506429  1.547449  60.745050   1.397158  58.283931
  • Plot RSI

>>> Indices.get_rsi_graph(df_rsi)  

"""
This will return a plot of RSI against time and also save RSI plot in your working directory as 'rsi.png'
"""
  • Get Bollinger Bands and its plot

>>> df_bb = Indices.get_bollinger_bands(price_data , 20, plot=True) 
>>> df_bb.tail()
           date   price       SMA         SD       pluse     minus
2243 2013-05-02  105.21  115.2345   6.339257  127.913013 -115.2345
2244 2013-05-01  116.99  114.9400   6.097587  127.135174 -114.9400
2245 2013-04-30  139.00  115.7900   8.016499  131.822998 -115.7900
2246 2013-04-29  144.54  116.9175  10.217936  137.353372 -116.9175
2247 2013-04-28  134.21  117.4530  10.842616  139.138233 -117.4530

"""
This will also save Bollingers bands plot in your working directory as 'bollinger_bands.png'
"""
  • Get Moving Average Convergence Divergence (MACD) and its plot

>>> df_macd = Indices.get_moving_average_convergence_divergence(price_data, plot=True)
"""This will return a pandas DataFrame and save EMA plot as 'macd.png' in working directory. 
""""
>>> df_macd.head()
         date    price      EMA_12        EMA_26        MACD
19 2019-06-18  9081.76    10415.979340  10886.327599 -470.348259
20 2019-06-17  9320.35    10247.420980  10770.329259 -522.908279
21 2019-06-16  8994.49    10054.662368  10638.785610 -584.123242
22 2019-06-15  8838.38    9867.542004   10505.422231 -637.880228
23 2019-06-14  8693.83    9686.970926   10371.230214 -684.259288
  • Get Simple Moving Average (SMA) and its plot

>>> df_sma = Indices.get_simple_moving_average(price_data, 20, plot=True) 
"""This will return a pandas DataFrame and save EMA plot as 'sma.png' in working directory. 
""""
>>> df_sma.head()
         date    price         SMA
19 2019-06-18  9081.76  10998.4180
20 2019-06-17  9320.35  10891.8930
21 2019-06-16  8994.49  10781.1900
22 2019-06-15  8838.38  10674.1860
23 2019-06-14  8693.83  10548.1055
  • Get Exponential Moving Average (EMA) and its plot

>>> df_ema = Indices.get_exponential_moving_average(price_data, [20,70], plot=True)
"""This will return a pandas DataFrame and save EMA plot as 'ema.png' in working directory. 
""""

>>> df_ema.head()
        date     price        EMA_20        EMA_70
0 2019-07-07  11450.85  11450.850000  11450.850000
1 2019-07-06  11208.55  11427.773810  11444.024648
2 2019-07-05  10978.46  11384.982018  11430.910151
3 2019-07-04  11215.44  11368.835159  11424.840569
4 2019-07-03  11961.27  11425.257525  11439.951257

License

MIT © Dayal Chand Aichara

Check out webpage of PriceIndices package.

Disclaimer:

All content provided here, is for educational purpose and your general information only, procured  from third party sources.
I make no warranties of any kind in relation to this content, including but  not limited to accuracy
and updatedness. No part of the content that I provide  constitutes  financial  advice, legal advice 
or any other form of advice meant for your specific reliance for any purpose. Any use or reliance on
my content is solely at your own risk  and  discretion. You should conduct your own research, review, 
analyse and  verify my content  before relying  on them. Trading is a highly risky activity that can 
lead to  major  losses, please  therefore  consult your financial advisor before making any decision.
No content on this Site is meant to be a solicitation or offer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PriceIndices-1.0.3.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

PriceIndices-1.0.3-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page