Skip to content

Commit

Permalink
V-1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayal Chand Aichara committed Oct 30, 2019
1 parent c3fc2e7 commit 5b1ac7b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 57 deletions.
4 changes: 2 additions & 2 deletions PriceIndices.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Metadata-Version: 2.1
Name: PriceIndices
Version: 1.0.1
Version: 1.0.2
Summary: A python package to get historical market data of cryptocurrencies from CoinMarketCap, and calculate & plot different indicators.
Home-page: https://github.com/dc-aichara/Price-Indices
Author: Dayal Chand Aichara
Author-email: [email protected]
License: MIT
Download-URL: https://github.com/dc-aichara/PriceIndices/archive/v-1.0.1.tar.gz
Download-URL: https://github.com/dc-aichara/PriceIndices/archive/v-1.0.2.tar.gz
Description:


Expand Down
Binary file modified PriceIndices/__pycache__/price_indicators.cpython-36.pyc
Binary file not shown.
106 changes: 57 additions & 49 deletions PriceIndices/price_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ def get_rsi_graph(self, rsi_data):
plt.suptitle('Price and Relative Strength Index', color='red', fontsize=24)
plt.savefig('rsi.png', bbox_inches='tight', facecolor='orange')
return plt.show()

except Exception as e:
return e

def get_bollinger_bands(df, days=20):
def get_bollinger_bands(df, days=20, plot=None):
"""
Type:
Trend, volatility, momentum indicator
Expand Down Expand Up @@ -178,25 +179,27 @@ def get_bollinger_bands(df, days=20):
data['plus'] = data['SMA'] + data['SD']*2
data['minus'] = data['SMA'] - data['SMA']*2
data1 = data.sort_values(by='date', ascending=False).reset_index(drop=True)
fig, ax = plt.subplots(figsize=(16, 12))
plt.plot(data1['date'], data1['plus'], color='g')
plt.plot(data1['date'], data1['minus'], color='g')
plt.plot(data1['date'], data1['price'], color='orange')
plt.legend()
plt.xlabel('Time', color='b', fontsize=22)
plt.ylabel('Price', color='b', fontsize=22)
plt.title('Bollinger Bands', color='b', fontsize=27)
plt.tick_params(labelsize=17)
fig.set_facecolor('yellow')
plt.grid()
plt.savefig('bollinger_bands.png', bbox_inches='tight', facecolor='orange')
plt.show()
while plot:
fig, ax = plt.subplots(figsize=(16, 12))
plt.plot(data1['date'], data1['plus'], color='g')
plt.plot(data1['date'], data1['minus'], color='g')
plt.plot(data1['date'], data1['price'], color='orange')
plt.legend()
plt.xlabel('Time', color='b', fontsize=22)
plt.ylabel('Price', color='b', fontsize=22)
plt.title('Bollinger Bands', color='b', fontsize=27)
plt.tick_params(labelsize=17)
fig.set_facecolor('yellow')
plt.grid()
plt.savefig('bollinger_bands.png', bbox_inches='tight', facecolor='orange')
plt.show()
break
return data1

except Exception as e:
return e

def get_moving_average_convergence_divergence(df):
def get_moving_average_convergence_divergence(df, plot=None):
"""
Type
Trend and momentum indicator
Expand All @@ -220,23 +223,24 @@ def get_moving_average_convergence_divergence(df):
data['MACD'] = data['EMA_12'] - data['EMA_26']
data1 = data.dropna()

fig, ax = plt.subplots(figsize=(14, 9))
plt.plot(data1['date'], data1['price'], color='r', label='Price')
plt.plot(data1['date'], data1['MACD'], color='b', label='MACD')
plt.legend()
plt.title('Price and MACD Plot', fontsize=28, color='b')
plt.xlabel('Time', color='b', fontsize=19)
plt.ylabel('Price', color='b', fontsize=19)
plt.savefig('macd.png', bbox_inches='tight', facecolor='orange')
fig.set_facecolor('orange')
plt.show()

while plot:
fig, ax = plt.subplots(figsize=(14, 9))
plt.plot(data1['date'], data1['price'], color='r', label='Price')
plt.plot(data1['date'], data1['MACD'], color='b', label='MACD')
plt.legend()
plt.title('Price and MACD Plot', fontsize=28, color='b')
plt.xlabel('Time', color='b', fontsize=19)
plt.ylabel('Price', color='b', fontsize=19)
plt.savefig('macd.png', bbox_inches='tight', facecolor='orange')
fig.set_facecolor('orange')
plt.show()
break
return data1

except Exception as e:
return print('MACD Error - {}'.format(e))

def get_simple_moving_average(df, days=15):
def get_simple_moving_average(df, days=15, plot=None):
"""
Simple moving average of given days
:param price_data: pandas DataFrame
Expand All @@ -249,22 +253,24 @@ def get_simple_moving_average(df, days=15):
data['SMA'] = data['price'].rolling(days).mean()
data1 = data.dropna()
data1 = data1.sort_values(by='date', ascending=False).reset_index(drop=True)
fig, ax = plt.subplots(figsize=(14, 9))
plt.plot(data1['date'], data1['price'], color='r', label='Price')
plt.plot(data1['date'], data1['SMA'], color='b', label='SMA')
plt.legend()
plt.title('Price and SMA Plot', fontsize=28, color='b')
plt.xlabel('Time', color='b', fontsize=19)
plt.ylabel('Price', color='b', fontsize=19)
plt.savefig('sma.png', bbox_inches='tight', facecolor='orange')
fig.set_facecolor('orange')
plt.show()
while plot:
fig, ax = plt.subplots(figsize=(14, 9))
plt.plot(data1['date'], data1['price'], color='r', label='Price')
plt.plot(data1['date'], data1['SMA'], color='b', label='SMA')
plt.legend()
plt.title('Price and SMA Plot', fontsize=28, color='b')
plt.xlabel('Time', color='b', fontsize=19)
plt.ylabel('Price', color='b', fontsize=19)
plt.savefig('sma.png', bbox_inches='tight', facecolor='orange')
fig.set_facecolor('orange')
plt.show()
break
return data1

except Exception as e:
return print('SMA Error - {}'.format(e))

def get_exponential_moving_average(df, periods=[20]):
def get_exponential_moving_average(df, periods=[20], plot=None):
"""
The EMA is a moving average that places a greater weight and significance on the most recent data points.
Like all moving averages, this technical indicator is used to produce buy and sell signals based on crossovers and divergences from the historical average.
Expand All @@ -280,17 +286,19 @@ def get_exponential_moving_average(df, periods=[20]):
data['EMA_{}'.format(period)] = data['price'].ewm(span=period, adjust=False).mean()
data = data.dropna()
data1 = data
fig, ax = plt.subplots(figsize=(14, 9))
plt.plot(data1['date'], data1['price'], color='r', label='Price')
for period in periods:
plt.plot(data1['date'], data1['EMA_{}'.format(period)], label='EMA_{}'.format(period))
plt.legend()
plt.title('Price and EMA Plot', fontsize=28, color='b')
plt.xlabel('Time', color='b', fontsize=19)
plt.ylabel('Price/EMA', color='b', fontsize=19)
plt.savefig('ema.png', bbox_inches='tight', facecolor='orange')
fig.set_facecolor('orange')
plt.show()
while plot:
fig, ax = plt.subplots(figsize=(14, 9))
plt.plot(data1['date'], data1['price'], color='r', label='Price')
for period in periods:
plt.plot(data1['date'], data1['EMA_{}'.format(period)], label='EMA_{}'.format(period))
plt.legend()
plt.title('Price and EMA Plot', fontsize=28, color='b')
plt.xlabel('Time', color='b', fontsize=19)
plt.ylabel('Price/EMA', color='b', fontsize=19)
plt.savefig('ema.png', bbox_inches='tight', facecolor='orange')
fig.set_facecolor('orange')
plt.show()
break
return data1

except Exception as e:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ This will return a plot of RSI against time and also save RSI plot in your worki
- #### Get Bollinger Bands and its plot

```python
>>> df_bb = Indices.get_bollinger_bands(price_data , 20)
>>> 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
Expand All @@ -136,7 +136,7 @@ This will also save Bollingers bands plot in your working directory as 'bollinge

```python

>>> df_macd = Indices.get_moving_average_convergence_divergence(price_data)
>>> 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()
Expand All @@ -154,7 +154,7 @@ This will also save Bollingers bands plot in your working directory as 'bollinge
- #### Get Simple Moving Average (SMA) and its plot

```python
>>> df_sma = Indices.get_simple_moving_average(price_data, 20)
>>> 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()
Expand All @@ -172,7 +172,7 @@ This will also save Bollingers bands plot in your working directory as 'bollinge
- ### Get Exponential Moving Average (EMA) and its plot

```python
>>> df_ema = Indices.get_exponential_moving_average(price_data, [20,70])
>>> 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.
""""

Expand Down
Binary file added dist/PriceIndices-1.0.2-py3-none-any.whl
Binary file not shown.
Binary file added dist/PriceIndices-1.0.2.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
setuptools.setup(
name='PriceIndices',
packages=['PriceIndices'],
version='1.0.1',
version='1.0.2',
license='MIT',
description='A python package to get historical market data of cryptocurrencies from CoinMarketCap, and calculate & plot different indicators.',
author='Dayal Chand Aichara',
author_email='[email protected]',
url='https://github.com/dc-aichara/Price-Indices',
download_url='https://github.com/dc-aichara/PriceIndices/archive/v-1.0.1.tar.gz',
download_url='https://github.com/dc-aichara/PriceIndices/archive/v-1.0.2.tar.gz',
keywords=['Volatility', 'blockchain', 'cryptocurrency', 'Price', 'trading', 'CoinMarketCap', 'Indices', 'Indicators'],
install_requires=['requests', 'pandas', 'numpy', 'matplotlib'],
classifiers=[
Expand Down

0 comments on commit 5b1ac7b

Please sign in to comment.