Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayal Chand Aichara committed May 30, 2019
1 parent 23c606a commit 78bf61d
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 7 deletions.
13 changes: 13 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2019 Dayal Chand Aichara

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 changes: 6 additions & 1 deletion PriceIndices/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from .price_indicators import PriceIndices
from .price_indicators import price, indices





Binary file added PriceIndices/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file not shown.
13 changes: 8 additions & 5 deletions PriceIndices/price_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from requests.packages.urllib3.util.retry import Retry


class PriceIndices:
class price:
__Crypto_Price_Base_URL = 'https://coinmarketcap.com/currencies/'

def __init__(self, price_url=__Crypto_Price_Base_URL):
Expand Down Expand Up @@ -53,7 +53,10 @@ def get_price(self, coin_id, start_date, end_date):

print('Please, check inputs. Coin id, and dates are strings. Date format is "YYYYMMDD"')

def get_bvol_index(self, price_data):

class indices:

def get_bvol_index( price_data):

""" Calculate Cryptocureency price's 30 days volatile index """
try:
Expand All @@ -69,7 +72,7 @@ def get_bvol_index(self, price_data):
except Exception as e:
print(e)

def get_bvol_graph(self, bvol_data):
def get_bvol_graph( bvol_data):

"""Make a line graph of bvol index with respect to time"""
try:
Expand Down Expand Up @@ -103,7 +106,7 @@ def get_bvol_graph(self, bvol_data):
except Exception as e:
print(e)

def get_rsi(self, price_data):
def get_rsi(price_data):

"""calculate Relative Strength Index"""
try:
Expand Down Expand Up @@ -132,7 +135,7 @@ def get_rsi(self, price_data):
except Exception as e:
print(e)

def get_rsi_graph(self, rsi_data):
def get_rsi_graph(rsi_data):
try:
df = rsi_data
fig, ax = plt.subplots(figsize=(16, 12))
Expand Down
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# Price-Indices

## Installation

### pip

```
pip install PriceIndics
```
### From Source (Github)

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

cd PriceIndices

python3 setup.py install

## Usages

```python
from PriceIndices import price, indices

```
## Examples

```python
>>> price = price()

>>> df = price.get_price('bitcoin', '20130428', '20190529')

>>>print(df.head())

date price
0 2019-05-29 8659.49
1 2019-05-28 8719.96
2 2019-05-27 8805.78
3 2019-05-26 8673.22
4 2019-05-25 8052.54

>>> df_bvol = indices.get_bvol_index(df)
>>> print(df_bvol.head())
date price BVOL_Index
0 2019-05-28 8719.96 0.853529
1 2019-05-27 8805.78 0.853605
2 2019-05-26 8673.22 0.849727
3 2019-05-25 8052.54 0.852357
4 2019-05-24 7987.37 0.826548

>>> indices.get_bvol_graph(df_bvol)

"""This will return a plot of BVOL index against time."""

>>> df_rsi = indices.get_rsi(df)

>>> 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

>>> indices.get_rsi_graph(df_rsi)

"""This will return a plot of RSI against time."""
```

### License
[MIT](https://choosealicense.com/licenses/mit/) © [Dayal Chand Aichara](https://github.com/dc-aichara)
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
29 changes: 29 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import setuptools
from os import path
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setuptools.setup(
name = 'PriceIndices',
packages = ['PriceIndices'],
version = '0.1',
license='MIT',
description = 'This package can be useful to get historical price 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/Price-Indices/archive/v_0.1.tar.gz',
keywords = ['Volatility', 'blockchain', 'cryptocurrency', 'Price', 'trading'],
install_requires=['requests', 'bs4', 'pandas', 'numpy', 'matplotlib'],
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Statistics',
'Intended Audience :: Traders',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Operating System :: OS Independent'
],
long_description=long_description,
long_description_content_type='text/markdown'
)

0 comments on commit 78bf61d

Please sign in to comment.