A python package to calculate trends in stocks using Renko, PnF, LineBreak etc
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
stocktrends Added PnF HL caclulation Jun 22, 2018
tests Added HDFC data file Jun 1, 2018
.gitignore Created project with cookiecutter Feb 6, 2018
Pipfile Added linebreak chart calculations Feb 14, 2018
README.rst Added renko types to readme Aug 21, 2018
demo.py Added PnF HL caclulation Jun 22, 2018
setup.py Added linebreak chart calculations Feb 14, 2018
tox.ini Added linebreak chart calculations Feb 14, 2018

README.rst

stocktrends

A python package to calcuate trends in stock markets.

Latest PyPI version

Installation

To install stable version from pypi, run

pip install stocktrends

To install latest code from github, run

pip install git+https://github.com/chillaranand/stocktrends

Usage

Check out demo.py file for detailed usage.

Create OHLC dataframe.

In [7]: import pandas as pd

In [8]: df = pd.read_csv('/home/chillaranand/stocks/HOOLI')

In [9]: df.head()
         date    open     high      low    close
0  2015-01-01  143.15  146.000  141.825  143.950
1  2015-01-02  144.05  148.025  142.150  142.775
2  2015-01-05  142.50  145.450  137.050  137.925
3  2015-01-06  135.00  136.500  116.000  118.050
4  2015-01-07  118.55  129.400  118.500  127.150

Renko chart calcuation

from stocktrends import Renko


renko = Renko(df)
renko.brick_size = 2
data = renko.get_ohlc_data()
print(data.tail())

# renko box calcuation based on periodic close
renko.chart_type = Renko.PERIOD_CLOSE
data = renko.get_ohlc_data()
print(data.tail())

# renko box calcuation based on price movement
renko.chart_type = Renko.PRICE_MOVEMENT
data = renko.get_ohlc_data()
print(data.tail())

LineBreak chart calcuation

from stocktrends import LineBreak


lb = LineBreak(df)
lb.line_number = 3
data = lb.get_ohlc_data()
print(data.tail())

PnF chart calcuation

from stocktrends import PnF


pnf = PnF(df)
pnf.box_size = 2
pnf.reversal_size = 3

# to get boxes information
data = pnf.get_ohlc_data()
print(data)

# to get OHLC for bars
data = pnf.get_bar_ohlc_data()
print(data)

# to get boxes information based on HIGH-LOW
data = pnf.get_ohlc_data(source='HL')
print(data)

# to get OHLC for bars
data = pnf.get_bar_ohlc_data(source='HL')
print(data)