Skip to content

Commit 5b1ac7b

Browse files
author
Dayal Chand Aichara
committed
V-1.0.2
1 parent c3fc2e7 commit 5b1ac7b

File tree

7 files changed

+65
-57
lines changed

7 files changed

+65
-57
lines changed

PriceIndices.egg-info/PKG-INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Metadata-Version: 2.1
22
Name: PriceIndices
3-
Version: 1.0.1
3+
Version: 1.0.2
44
Summary: A python package to get historical market data of cryptocurrencies from CoinMarketCap, and calculate & plot different indicators.
55
Home-page: https://github.com/dc-aichara/Price-Indices
66
Author: Dayal Chand Aichara
77
Author-email: dc.aichara@gmail.com
88
License: MIT
9-
Download-URL: https://github.com/dc-aichara/PriceIndices/archive/v-1.0.1.tar.gz
9+
Download-URL: https://github.com/dc-aichara/PriceIndices/archive/v-1.0.2.tar.gz
1010
Description:
1111

1212

91 Bytes
Binary file not shown.

PriceIndices/price_indicators.py

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ def get_rsi_graph(self, rsi_data):
146146
plt.suptitle('Price and Relative Strength Index', color='red', fontsize=24)
147147
plt.savefig('rsi.png', bbox_inches='tight', facecolor='orange')
148148
return plt.show()
149+
149150
except Exception as e:
150151
return e
151152

152-
def get_bollinger_bands(df, days=20):
153+
def get_bollinger_bands(df, days=20, plot=None):
153154
"""
154155
Type:
155156
Trend, volatility, momentum indicator
@@ -178,25 +179,27 @@ def get_bollinger_bands(df, days=20):
178179
data['plus'] = data['SMA'] + data['SD']*2
179180
data['minus'] = data['SMA'] - data['SMA']*2
180181
data1 = data.sort_values(by='date', ascending=False).reset_index(drop=True)
181-
fig, ax = plt.subplots(figsize=(16, 12))
182-
plt.plot(data1['date'], data1['plus'], color='g')
183-
plt.plot(data1['date'], data1['minus'], color='g')
184-
plt.plot(data1['date'], data1['price'], color='orange')
185-
plt.legend()
186-
plt.xlabel('Time', color='b', fontsize=22)
187-
plt.ylabel('Price', color='b', fontsize=22)
188-
plt.title('Bollinger Bands', color='b', fontsize=27)
189-
plt.tick_params(labelsize=17)
190-
fig.set_facecolor('yellow')
191-
plt.grid()
192-
plt.savefig('bollinger_bands.png', bbox_inches='tight', facecolor='orange')
193-
plt.show()
182+
while plot:
183+
fig, ax = plt.subplots(figsize=(16, 12))
184+
plt.plot(data1['date'], data1['plus'], color='g')
185+
plt.plot(data1['date'], data1['minus'], color='g')
186+
plt.plot(data1['date'], data1['price'], color='orange')
187+
plt.legend()
188+
plt.xlabel('Time', color='b', fontsize=22)
189+
plt.ylabel('Price', color='b', fontsize=22)
190+
plt.title('Bollinger Bands', color='b', fontsize=27)
191+
plt.tick_params(labelsize=17)
192+
fig.set_facecolor('yellow')
193+
plt.grid()
194+
plt.savefig('bollinger_bands.png', bbox_inches='tight', facecolor='orange')
195+
plt.show()
196+
break
194197
return data1
195198

196199
except Exception as e:
197200
return e
198201

199-
def get_moving_average_convergence_divergence(df):
202+
def get_moving_average_convergence_divergence(df, plot=None):
200203
"""
201204
Type
202205
Trend and momentum indicator
@@ -220,23 +223,24 @@ def get_moving_average_convergence_divergence(df):
220223
data['MACD'] = data['EMA_12'] - data['EMA_26']
221224
data1 = data.dropna()
222225

223-
fig, ax = plt.subplots(figsize=(14, 9))
224-
plt.plot(data1['date'], data1['price'], color='r', label='Price')
225-
plt.plot(data1['date'], data1['MACD'], color='b', label='MACD')
226-
plt.legend()
227-
plt.title('Price and MACD Plot', fontsize=28, color='b')
228-
plt.xlabel('Time', color='b', fontsize=19)
229-
plt.ylabel('Price', color='b', fontsize=19)
230-
plt.savefig('macd.png', bbox_inches='tight', facecolor='orange')
231-
fig.set_facecolor('orange')
232-
plt.show()
233-
226+
while plot:
227+
fig, ax = plt.subplots(figsize=(14, 9))
228+
plt.plot(data1['date'], data1['price'], color='r', label='Price')
229+
plt.plot(data1['date'], data1['MACD'], color='b', label='MACD')
230+
plt.legend()
231+
plt.title('Price and MACD Plot', fontsize=28, color='b')
232+
plt.xlabel('Time', color='b', fontsize=19)
233+
plt.ylabel('Price', color='b', fontsize=19)
234+
plt.savefig('macd.png', bbox_inches='tight', facecolor='orange')
235+
fig.set_facecolor('orange')
236+
plt.show()
237+
break
234238
return data1
235239

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

239-
def get_simple_moving_average(df, days=15):
243+
def get_simple_moving_average(df, days=15, plot=None):
240244
"""
241245
Simple moving average of given days
242246
:param price_data: pandas DataFrame
@@ -249,22 +253,24 @@ def get_simple_moving_average(df, days=15):
249253
data['SMA'] = data['price'].rolling(days).mean()
250254
data1 = data.dropna()
251255
data1 = data1.sort_values(by='date', ascending=False).reset_index(drop=True)
252-
fig, ax = plt.subplots(figsize=(14, 9))
253-
plt.plot(data1['date'], data1['price'], color='r', label='Price')
254-
plt.plot(data1['date'], data1['SMA'], color='b', label='SMA')
255-
plt.legend()
256-
plt.title('Price and SMA Plot', fontsize=28, color='b')
257-
plt.xlabel('Time', color='b', fontsize=19)
258-
plt.ylabel('Price', color='b', fontsize=19)
259-
plt.savefig('sma.png', bbox_inches='tight', facecolor='orange')
260-
fig.set_facecolor('orange')
261-
plt.show()
256+
while plot:
257+
fig, ax = plt.subplots(figsize=(14, 9))
258+
plt.plot(data1['date'], data1['price'], color='r', label='Price')
259+
plt.plot(data1['date'], data1['SMA'], color='b', label='SMA')
260+
plt.legend()
261+
plt.title('Price and SMA Plot', fontsize=28, color='b')
262+
plt.xlabel('Time', color='b', fontsize=19)
263+
plt.ylabel('Price', color='b', fontsize=19)
264+
plt.savefig('sma.png', bbox_inches='tight', facecolor='orange')
265+
fig.set_facecolor('orange')
266+
plt.show()
267+
break
262268
return data1
263269

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

267-
def get_exponential_moving_average(df, periods=[20]):
273+
def get_exponential_moving_average(df, periods=[20], plot=None):
268274
"""
269275
The EMA is a moving average that places a greater weight and significance on the most recent data points.
270276
Like all moving averages, this technical indicator is used to produce buy and sell signals based on crossovers and divergences from the historical average.
@@ -280,17 +286,19 @@ def get_exponential_moving_average(df, periods=[20]):
280286
data['EMA_{}'.format(period)] = data['price'].ewm(span=period, adjust=False).mean()
281287
data = data.dropna()
282288
data1 = data
283-
fig, ax = plt.subplots(figsize=(14, 9))
284-
plt.plot(data1['date'], data1['price'], color='r', label='Price')
285-
for period in periods:
286-
plt.plot(data1['date'], data1['EMA_{}'.format(period)], label='EMA_{}'.format(period))
287-
plt.legend()
288-
plt.title('Price and EMA Plot', fontsize=28, color='b')
289-
plt.xlabel('Time', color='b', fontsize=19)
290-
plt.ylabel('Price/EMA', color='b', fontsize=19)
291-
plt.savefig('ema.png', bbox_inches='tight', facecolor='orange')
292-
fig.set_facecolor('orange')
293-
plt.show()
289+
while plot:
290+
fig, ax = plt.subplots(figsize=(14, 9))
291+
plt.plot(data1['date'], data1['price'], color='r', label='Price')
292+
for period in periods:
293+
plt.plot(data1['date'], data1['EMA_{}'.format(period)], label='EMA_{}'.format(period))
294+
plt.legend()
295+
plt.title('Price and EMA Plot', fontsize=28, color='b')
296+
plt.xlabel('Time', color='b', fontsize=19)
297+
plt.ylabel('Price/EMA', color='b', fontsize=19)
298+
plt.savefig('ema.png', bbox_inches='tight', facecolor='orange')
299+
fig.set_facecolor('orange')
300+
plt.show()
301+
break
294302
return data1
295303

296304
except Exception as e:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ This will return a plot of RSI against time and also save RSI plot in your worki
113113
- #### Get Bollinger Bands and its plot
114114

115115
```python
116-
>>> df_bb = Indices.get_bollinger_bands(price_data , 20)
116+
>>> df_bb = Indices.get_bollinger_bands(price_data , 20, plot=True)
117117
>>> df_bb.tail()
118118
date price SMA SD pluse minus
119119
2243 2013-05-02 105.21 115.2345 6.339257 127.913013 -115.2345
@@ -136,7 +136,7 @@ This will also save Bollingers bands plot in your working directory as 'bollinge
136136

137137
```python
138138

139-
>>> df_macd = Indices.get_moving_average_convergence_divergence(price_data)
139+
>>> df_macd = Indices.get_moving_average_convergence_divergence(price_data, plot=True)
140140
"""This will return a pandas DataFrame and save EMA plot as 'macd.png' in working directory.
141141
""""
142142
>>> df_macd.head()
@@ -154,7 +154,7 @@ This will also save Bollingers bands plot in your working directory as 'bollinge
154154
- #### Get Simple Moving Average (SMA) and its plot
155155

156156
```python
157-
>>> df_sma = Indices.get_simple_moving_average(price_data, 20)
157+
>>> df_sma = Indices.get_simple_moving_average(price_data, 20, plot=True)
158158
"""This will return a pandas DataFrame and save EMA plot as 'sma.png' in working directory.
159159
""""
160160
>>> df_sma.head()
@@ -172,7 +172,7 @@ This will also save Bollingers bands plot in your working directory as 'bollinge
172172
- ### Get Exponential Moving Average (EMA) and its plot
173173

174174
```python
175-
>>> df_ema = Indices.get_exponential_moving_average(price_data, [20,70])
175+
>>> df_ema = Indices.get_exponential_moving_average(price_data, [20,70], plot=True)
176176
"""This will return a pandas DataFrame and save EMA plot as 'ema.png' in working directory.
177177
""""
178178

8.73 KB
Binary file not shown.

dist/PriceIndices-1.0.2.tar.gz

7.7 KB
Binary file not shown.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
setuptools.setup(
77
name='PriceIndices',
88
packages=['PriceIndices'],
9-
version='1.0.1',
9+
version='1.0.2',
1010
license='MIT',
1111
description='A python package to get historical market data of cryptocurrencies from CoinMarketCap, and calculate & plot different indicators.',
1212
author='Dayal Chand Aichara',
1313
author_email='dc.aichara@gmail.com',
1414
url='https://github.com/dc-aichara/Price-Indices',
15-
download_url='https://github.com/dc-aichara/PriceIndices/archive/v-1.0.1.tar.gz',
15+
download_url='https://github.com/dc-aichara/PriceIndices/archive/v-1.0.2.tar.gz',
1616
keywords=['Volatility', 'blockchain', 'cryptocurrency', 'Price', 'trading', 'CoinMarketCap', 'Indices', 'Indicators'],
1717
install_requires=['requests', 'pandas', 'numpy', 'matplotlib'],
1818
classifiers=[

0 commit comments

Comments
 (0)