Skip to main content

DataFrame with inline stock statistics support.

Project description

https://travis-ci.org/jealous/stockstats.svg https://coveralls.io/repos/jealous/stockstats/badge.svg https://img.shields.io/pypi/v/stockstats.svg

VERSION: 0.1.8

Introduction

Supply a wrapper StockDataFrame based on the pandas.DataFrame with inline stock statistics/indicators support.

Supported statistics/indicators are:

  • change (in percent)

  • delta

  • permutation (zero based)

  • log return

  • max in range

  • min in range

  • middle = (close + high + low) / 3

  • SMA: simple moving average

  • EMA: exponential moving average

  • MSTD: moving standard deviation

  • MVAR: moving variance

  • RSV: raw stochastic value

  • RSI: relative strength index

  • KDJ: Stochastic oscillator

  • Bolling: including upper band and lower band.

  • MACD: moving average convergence divergence. Including signal and histogram.

  • CR:

  • WR: Williams Overbought/Oversold index

  • CCI: Commodity Channel Index

  • TR: true range

  • ATR: average true range

  • line cross check, cross up or cross down.

  • DMA: Different of Moving Average (10, 50)

  • DMI: Directional Moving Index, including

    • +DI: Positive Directional Indicator

    • -DI: Negative Directional Indicator

    • ADX: Average Directional Movement Index

    • ADXR: Smoothed Moving Average of ADX

Installation

pip install stockstats

License

BSD

Tutorial

  • Initialize the StockDataFrame with the retype function which convert a pandas.DataFrame to a StockDataFrame.

stock = StockDataFrame.retype(pd.read_csv('stock.csv'))
  • There are some shortcuts for frequent used statistics/indicators like kdjk, boll_hb, macd, etc.

  • The indicators/statistics are generated on the fly when they are accessed. If you are accessing through Series, it may return not found error. The fix is to explicitly initialize it by accessing it like below:

_ = stock['macd']
# or
stock.get('macd')
  • Using get item to access the indicators. The item name following the pattern: {columnName_window_statistics}. Some statistics/indicators has their short cut. See examples below:

# volume delta against previous day
stock['volume_delta']

# open delta against next 2 day
stock['open_2_d']

# open price change (in percent) between today and the day before yesterday
# 'r' stands for rate.
stock['open_-2_r']

# CR indicator, including 5, 10, 20 days moving average
stock['cr']
stock['cr-ma1']
stock['cr-ma2']
stock['cr-ma3']

# volume max of three days ago, yesterday and two days later
stock['volume_-3,2,-1_max']

# volume min between 3 days ago and tomorrow
stock['volume_-3~1_min']

# KDJ, default to 9 days
stock['kdjk']
stock['kdjd']
stock['kdjj']

# three days KDJK cross up 3 days KDJD
stock['kdj_3_xu_kdjd_3']

# 2 days simple moving average on open price
stock['open_2_sma']

# MACD
stock['macd']
# MACD signal line
stock['macds']
# MACD histogram
stock['macdh']

# bolling, including upper band and lower band
stock['boll']
stock['boll_ub']
stock['boll_lb']

# close price less than 10.0 in 5 days count
stock['close_10.0_le_5_c']

# CR MA2 cross up CR MA1 in 20 days count
stock['cr-ma2_xu_cr-ma1_20_c']

# 6 days RSI
stock['rsi_6']
# 12 days RSI
stock['rsi_12']

# 10 days WR
stock['wr_10']
# 6 days WR
stock['wr_6']

# CCI, default to 14 days
stock['cci']
# 20 days CCI
stock['cci_20']

# TR (true range)
stock['tr']
# ATR (Average True Range)
stock['atr']

# DMA, difference of 10 and 50 moving average
stock['dma']

# DMI
# +DI, default to 14 days
stock['pdi']
# -DI, default to 14 days
stock['mdi]
# DX, default to 14 days of +DI and -DI
stock['dx']
# ADX, 6 days SMA of DX, same as stock['dx_6_ema']
stock['adx]
# ADXR, 6 days SMA of ADX, same as stock['adx_6_ema']
stock['adxr']

To file issue, please visit:

https://github.com/jealous/stockstats

Contact author:

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

stockstats-0.1.8.zip (18.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

stockstats-0.1.8.win-amd64.zip (21.1 kB view details)

Uploaded Source

stockstats-0.1.8-py2.py3-none-any.whl (13.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file stockstats-0.1.8.zip.

File metadata

  • Download URL: stockstats-0.1.8.zip
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for stockstats-0.1.8.zip
Algorithm Hash digest
SHA256 ea8079d3e0002fe90d759a644f1987d547231ffdaf5c00213c1933ee209a2213
MD5 a5a30e4a269e036f47a837b6c7a88e4d
BLAKE2b-256 c7f7ae4fa5da4f48ff11452e704afb57e4e35d89af36038ea34244b188b951b5

See more details on using hashes here.

File details

Details for the file stockstats-0.1.8.win-amd64.zip.

File metadata

File hashes

Hashes for stockstats-0.1.8.win-amd64.zip
Algorithm Hash digest
SHA256 37b95e29a8409cc3ee0b11c4c60a21e00c51ad7a760dc3cc7f5c56bbafffc523
MD5 9f47ab3eaed9a06e20b18adc896fbebb
BLAKE2b-256 4607548b8bb957bb7744cee926a9616b9f19118a67bb7a98708805dc16f448b2

See more details on using hashes here.

File details

Details for the file stockstats-0.1.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for stockstats-0.1.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8c9bbcfe773882f6750fe6e5c5211ea9c9d198c51d20fb529f70385ca3ce11ff
MD5 f0cbadb3427676d56dbef346dd99fcb3
BLAKE2b-256 32bc8129d838128a6b4d26722a01522c1b0f96d75ace9223215649244b87d518

See more details on using hashes here.

Supported by

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