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

Related tags

Financestockstats
Overview

Stock Statistics/Indicators Calculation Helper

VERSION: 0.3.2

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
  • compare: le, ge, lt, gt, eq, ne
  • count: both backward(c) and forward(fc)
  • 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. (see note)
  • 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
  • TRIX: Triple Exponential Moving Average
  • TEMA: Another Triple Exponential Moving Average
  • VR: Volatility Volume Ratio

Installation

pip install stockstats

Compatibility

Please check the setup.py file.

Note that pandas add some type check after version 1.0. One type assert is skipped in StockDataFrame. Check ISSUE-50 for detail.

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'))
  • Formalize your data. This package takes for granted that your data is sorted by timestamp and contains certain columns. Please align your column name.
    • open: the open price of the interval
    • close: the close price of the interval
    • high: the highest price of the interval
    • low: the lowest price of the interval
    • volume: the volume of stocks traded during the interval
    • amount: the amount of the stocks during the interval
  • 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']

# count forward(future) where close price is larger than 10
stock['close_10.0_ge_5_fc']

# 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']

# TRIX, default to 12 days
stock['trix']
    # TRIX based on the close price for a window of 3
stock['close_3_trix']
# MATRIX is the simple moving average of TRIX
stock['trix_9_sma']
# TEMA, another implementation for triple ema
stock['tema']
    # TEMA based on the close price for a window of 2
stock['close_2_tema']

# VR, default to 26 days
stock['vr']
# MAVR is the simple moving average of VR
stock['vr_6_sma']
  • Following options are available for tuning. Note that all of them are class level options and MUST be changed before any calculation happens.
    • KDJ
      • KDJ_WINDOW: default to 9
    • BOLL
      • BOLL_WINDOW: default to 20
      • BOLL_STD_TIMES: default to 2
    • MACD
      • MACD_EMA_SHORT: default to 12
      • MACD_EMA_LONG: default to 26
      • MACD_EMA_SIGNAL: default to 9
    • PDI, MDI, DX & ADX
      • PDI_SMMA: default to 14
      • MDI_SMMA: default to 14
      • DX_SMMA: default to 14
      • ADX_EMA: default to 6
      • ADXR_EMA: default to 6
    • CR
      • CR_MA1: default to 5
      • CR_MA2: default to 10
      • CR_MA3: default to 20
    • Triple EMA
      • TRIX_EMA_WINDOW: default to 12
      • TEMA_EMA_WINDOW: default to 5
    • ATR
      • ATR_SMMA: default to 14

To file issue, please visit:

https://github.com/jealous/stockstats

MACDH Note:

In July 2017 the code for MACDH was changed to drop an extra 2x multiplier on the final value to align better with calculation methods used in tools like cryptowatch, tradingview, etc.

Contact author:

Comments
  • Append new data

    Append new data

    Hi! I was wondering if there's a method to append new data. I would like to do something like that:

    new_frame = pd.DataFrame(data=[[date, open, high, low, close]], columns=['DateTime', 'Open', 'High', 'Low', 'Close'])
    Data = Data.append(new_frame, ignore_index=True)
    

    This code will throw you an exception because you have to marge the different columns. But, it would be great if we just required to add the OHLC data so that the StockDataFrame automatically recalculates the statistics and indicators. Are there different alternatives to append new data?

    Thanks in advance,

    wontfix 
    opened by rseibane 11
  • [SettingWithCopyWarning] for getting ATR

    [SettingWithCopyWarning] for getting ATR

    my code:

        @classmethod
        def get_atr(cls, candles):
            stock = StockDataFrame.retype(TCandle.to_df(candles))
            return list(stock.get('atr'))
    

    I got the following warning:

      /Users/yurenji/.conda/envs/tangle/lib/python3.6/site-packages/pandas/core/indexing.py:189: SettingWithCopyWarning: 
      A value is trying to be set on a copy of a slice from a DataFrame
      
      See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
        self._setitem_with_indexer(indexer, value)
    
    -- Docs: http://doc.pytest.org/en/latest/warnings.html
    

    I tried 'macdh' and 'sma', they don't have this issue.

    opened by yurenji 7
  • Added vwap support

    Added vwap support

    I have added Volume Weighted Average Price indicator support

    my knowledge of vwap is based on

    code sample:- stocks = StockDataFrame.retype(df) print(stocks['vwap'].tail(10))

    gives output:- Datetime 2020-12-09 12:15:00+05:30 935.595807 2020-12-09 12:20:00+05:30 935.566596 2020-12-09 12:25:00+05:30 935.548274 2020-12-09 12:30:00+05:30 935.543816 2020-12-09 12:35:00+05:30 935.539725 2020-12-09 12:40:00+05:30 935.529548 2020-12-09 12:45:00+05:30 935.516953 2020-12-09 12:50:00+05:30 935.502845 2020-12-09 12:55:00+05:30 935.490450 2020-12-09 12:59:09+05:30 935.490450 Name: vwap, dtype: float64

    opened by Arsh0023 6
  • Add Kaufman Adaptive Moving Average

    Add Kaufman Adaptive Moving Average

    The indicator was tested against the reference investopedia article. It has more settings than other indicators, so the name could be parsed into five parts now.

    close_10_kama_2_30

    has three settings:

    • 10 is the number of periods for the Efficiency Ratio (ER).
    • 2 is the number of periods for the fastest EMA constant.
    • 30 is the number of periods for the slowest EMA constant.

    To make sure regular indicators are parsed as usual, only those within the tuple MULTI_SPLIT_INDICATORS will be parsed into five parts.

    opened by jhmenke 5
  • is TEMA and TRIX adjustable?

    is TEMA and TRIX adjustable?

    are TEMA and TRIX adjustable like other metrics such as .get('tema_20') || .get('trix_35')

    Couldn't find on stackoverflow or any other forums so I am at the source : D

    Awesome lib!

    question 
    opened by 7ruth 5
  • How to install / setup up stockstats

    How to install / setup up stockstats

    Hey,

    Wondering if somebody could help a guy out in getting this installed and setup up to use? I'm pretty new at this so any advice would be wonderful.

    I have python installed, downloaded the files and I researched that I can get the "pandas.DataFrame" through Anaconda. Not sure where to go from here.

    Thanks

    opened by toxilate 5
  • Get all indicators

    Get all indicators

    I think this would be an interesting feature that I'd be willing to help out with.

    Ideally you could call a function similar to df.get_stock_stats() that returns a data frame with every single indicator.

    any advice?

    enhancement 
    opened by camrongodbout 5
  • Groupby apply does not work with .get('macd')

    Groupby apply does not work with .get('macd')

    I'm trying to get intraday macdh data, so did the following:

    Example of df before doing anything: image

    def get_macdh(x):
        col = x.get('macdh')
        # do something with macdh
        result = True if col is not None else False
        return result
    
    stock.groupby(['date','ticker']).apply(get_macdh)
    

    Result:

    date        ticker
    2021-02-08  AAPL      False
                FB        False
    2021-02-09  AAPL      False
                FB        False
    2021-02-10  AAPL      False
                FB        False
    2021-02-11  AAPL      False
                FB        False
    2021-02-12  AAPL      False
                FB        False
    2021-02-16  AAPL      False
                FB        False
    2021-02-17  AAPL      False
                FB        False
    

    It appears no matter what i try to do, macdh isnt getting initialized within the groupby? If i do a stock.get('macdh') before, the values will be wrong as itll include previous day figures as well.

    opened by Waffleboy 4
  • rsi doesn't seem to work with pandas 1.0.0

    rsi doesn't seem to work with pandas 1.0.0

    Hi,

    Pandas recently released 1.0.0 and since then, rsi calculations seem to run into KeyError for some reason.

    Here's very simple sample code:

    #!/usr/bin/env python3
    
    import pandas_datareader.data as web
    from stockstats import StockDataFrame
    
    spx = web.DataReader('^GSPC', 'yahoo')
    dataframe = StockDataFrame.retype(spx)
    print(dataframe['rsi_14']['2020-01-31'])
    

    With pandas 0.25.3, it works fine:

    Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 int-date-0.1.8 lxml-4.5.0 numpy-1.18.1 pandas-0.25.3 pandas-datareader-0.8.1 python-dateutil-2.8.1 pytz-2019.3 requests-2.22.0 six-1.14.0 stockstats-0.3.0 urllib3-1.25.8
    $ ./test.py
    venv/lib/python3.6/site-packages/pandas/core/indexing.py:205: SettingWithCopyWarning: 
    A value is trying to be set on a copy of a slice from a DataFrame
    
    See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
      self._setitem_with_indexer(indexer, value)
    43.43522572721968
    

    However, with pandas 1.0.0, KeyError occurs:

    Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 int-date-0.1.8 lxml-4.5.0 numpy-1.18.1 pandas-1.0.0 pandas-datareader-0.8.1 python-dateutil-2.8.1 pytz-2019.3 requests-2.22.0 six-1.14.0 stockstats-0.3.0 urllib3-1.25.8
    $ ./test.py 
    See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
      self._setitem_with_indexer(indexer, value)
    Traceback (most recent call last):
      File "venv/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2646, in get_loc
        return self._engine.get_loc(key)
      File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
      File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
      File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item
      File "pandas/_libs/hashtable_class_helper.pxi", line 1622, in pandas._libs.hashtable.PyObjectHashTable.get_item
    KeyError: 'rsi_14'
    

    The problem could be on pandas side, though they bumped the major version so I suspect stockstats might want to support retyping of pandas 1.0.0 and on as well.

    bug 
    opened by satoshi 4
  • kdj columns and rsv_9 all NaN

    kdj columns and rsv_9 all NaN

    Hi,

    there are cases where the kdj columns are all NaN. This seems to be related to rsv_9 beeing NaN.

    Here is sample data (the first 20 lines of ASML stock quote) which shows the problem:

    date        adj_close     close      high       low      open     volume
    2010-01-01   29.28827  23.99998  23.99998  23.99998  23.99998        0.0
    2010-01-04   29.60560  24.26000  24.31999  23.89002  23.90003  1563900.0
    2010-01-05   29.66047  24.30497  24.62498  24.05996  24.11501  1550300.0
    2010-01-06   29.97780  24.56500  24.56500  24.18000  24.20503  1133900.0
    2010-01-07   29.42866  24.11501  24.45004  23.80001  24.45004  2648700.0
    2010-01-08   28.44013  23.30497  24.08498  23.27502  23.99998  3064200.0
    2010-01-11   27.37239  22.43002  23.45497  22.43002  23.31999  4640500.0
    2010-01-12   27.82389  22.80001  22.92998  22.60004  22.65001  3098000.0
    2010-01-13   28.28762  23.18000  23.39999  22.75003  22.80001  3732600.0
    2010-01-14   28.26319  23.15998  23.59996  23.09499  23.46998  1851800.0
    2010-01-15   27.89709  22.85999  23.43002  22.69498  23.28996  2738400.0
    2010-01-18   27.93985  22.89503  22.98504  22.62499  22.90003  1132900.0
    2010-01-19   27.67129  22.67496  22.91997  22.62499  22.80501  2392200.0
    2010-01-20   28.53165  23.37997  23.87000  22.87501  22.98997  6490400.0
    2010-01-21   29.00759  23.76998  24.06997  23.65001  23.74503  4068900.0
    2010-01-22   28.53165  23.37997  23.82003  23.33500  23.53998  3842600.0
    2010-01-25   27.78725  22.76998  23.18501  22.69998  22.70999  3091000.0
    2010-01-26   28.34861  23.22998  23.37004  22.81002  22.99998  2716300.0
    2010-01-27   28.12290  23.04502  23.13503  22.71500  23.08999  2130900.0
    2010-01-28   27.86656  22.83497  23.73001  22.83497  23.44003  3445800.0
    

    if rsv_9 is calculated with stockstats, the first value is NaN. This leads to all kdj columns beeing NaN as well. I guess this is due to a division by zero error in _get_rsv in line 251:

    df[column_name] = ((df['close'] - low_min) /
                       (high_max - low_min).astype('float64') * 100)  
    

    How should the code be modified so that this bug doesn't appear? (or what's the correct value for rsv if high_max - low_min == 0?)

    bug 
    opened by think-nice-things 4
  • Could I set other values to StockDataFrame variables?

    Could I set other values to StockDataFrame variables?

    I want to use other values for example in bollinger I would use 8 periods... how is the correct way to do it?

    just do a "Sdf.BOLL_PERIOD = 8" ?

    question 
    opened by mscampos92 3
  • Is comparison operator still supported?

    Is comparison operator still supported?

    I'm glad to see this fantastic work resume updating. Excellent work, and many thanks.

    It seems that all the comparison operators have been removed since commit 68f105de6019525b8e940ae369eed308d1065ec5, although I think they are quite an important feature in my case (ee.g. kdjj_0_le_15_c).

    Is there any way to do the same thing in the new version? Or do I have to do this comparison by myself?

    Anyway, there are still "compare: le, ge, lt, gt, eq, ne" in the new readme file, so I think there might be something going on...

    opened by isiosia 0
  • Energy Index's window is not in the column

    Energy Index's window is not in the column

    When user specify a customized window for the energy index, it should appear in the column name. The customized column should not overwrite the column with the default window size.

    bug 
    opened by jealous 0
  • Fix issue 125 - Supertrend misscalculation

    Fix issue 125 - Supertrend misscalculation

    Adjusting supertrend evaluation by comparing previous close value instead of current

    Link to the issue (I am unable to link them direcly over github).

    opened by fniko 1
  • Supertrend indicator seems to incorrectly change orientation

    Supertrend indicator seems to incorrectly change orientation

    Hello, I have switched my supertrend calculations from pandas_ta and I observe a inconsistency in supertrend values. The issue is (probably) caused by specific candle wicks.

    I will continously work the description of this issue, since it's a bit difficult to be to debug or even describe.

    Current behaviour

    The issue occurs at 08:45 or 08:46. The extreme weird looking candles happens and the supertrend flips for a period of one candle.

    • Dataset: Binance OHCL BTCUSDT
    • Time range: from 2020-09-14 to 2020-09-15 (UTC)
    • ST Multiplier: 2
    • ST Window length: 25
    • Python 3.10
    • Stockstats 0.4.1

    Note: I am using an web UI which is displaying only "active" supertrend. This is why is the other line missing from the chart. However I am going to provide charts with both lines, but it's a bit confusing a bit since it's not clear which one is "active".

    Code snippet

    import pandas as pd
    import stockstats
    
    filename = 'binance_btcusdt_ohcl_1m.parquet'
    ohcl = pd.read_parquet(filename, engine="fastparquet")
    st_a = stockstats.wrap(ohcl.copy())
    
    st_a.SUPERTREND_MUL = 4
    st_a.SUPERTREND_WINDOW = 25
    st_a = st_a[['supertrend', 'supertrend_ub', 'supertrend_lb']]
    # Here I merge the st_a with datetime column generated before the ST calculation
    # st_a.insert(1, "datetime", date)
    # And renaming columns in order to increase readability
    # st_b.rename(columns={'supertrend_ub': 'st_upper', 'supertrend_lb': 'st_lower'}, inplace=True)
    

    Supertrend values (raw)

    id datetime st value st upper st lower
    611587 2020-09-14 08:40:00  10447.284218  10447.284218  10388.507576
    611588 2020-09-14 08:41:00  10447.284218  10447.284218  10388.507576
    611589 2020-09-14 08:42:00  10447.284218  10447.284218  10388.507576
    611590 2020-09-14 08:43:00  10447.025543  10447.025543  10388.507576
    611591 2020-09-14 08:44:00  10447.025543  10447.025543  10388.507576
    611592 2020-09-14 08:45:00  10388.507576  10393.494348  10388.507576
    611593 2020-09-14 08:46:00  10399.716374  10399.716374  10388.507576
    611594 2020-09-14 08:47:00  10399.716374  10399.716374  10293.768281
    611595 2020-09-14 08:48:00  10399.716374  10399.716374  10293.768281
    611596 2020-09-14 08:49:00  10399.716374  10399.716374  10293.768281
    611597 2020-09-14 08:50:00  10399.716374  10399.716374  10293.768281
    
    st_values_raw

    OHCL with supertrend (stockstats) st_stockstats

    OHCL with supertrend (pandas_ta) st_pandas

    OHCL with supertrend and both [upper and lowes] values displayed (stockstats) st_stockstats_both_st

    Used data source - binance_btcusdt_ohcl_1m.parquet I am using Pandas to work with data, loading parquet is very easy - guide - however in case of any issues, I can export data in different format (JSON etc.) binance_btcusdt_ohcl_1m.parquet.zip

    Expected behaviour

    I do not think that the supertrend - trend should end (change). I think it should continue since the bull (positive/long) candle did not broke it.

    opened by fniko 4
  • copy should not modify data

    copy should not modify data

    Hi there,

    thanks for your wonderful lib, really like it.

    When using your lib together with other frameworks I run into the problem that a copy call in the other framework caused the column names to be renamed to lower case, which the other framework can't handle. I scanned your code and found that the copy function has this "feature" in it.

    As I think a copy should not modify the data compared to the original one I introduced a lowerCase-Flag in wrap and retype causing copy to leave the column names as they are. With that modification I was able to run your StockDataFrame also with other frameworks like backtesting.py

    Best regards, Neutro2

    opened by neuraldevelopment 3
  • Error calculating the number of prices greater than the close of the last 10 periods

    Error calculating the number of prices greater than the close of the last 10 periods

    Thanks for sharing this work. I'm trying to adapt to it and I just found two problems. My DataFrame is

    df = yf.download("AAPL", start="2020-01-01", end="2020-12-31") stock_df = StockDataFrame.retype(df)

    when executing

    tp = stock_df['middle'] stock_df['res'] = stock_df['middle'] > df['close'] stock_df[['middle', 'close', 'res', 'res_-10_c']]

    it returns the error

    `-------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/stockstats.py in getitem(self, item) 1249 try: -> 1250 result = wrap(super(StockDataFrame, self).getitem(item)) 1251 except KeyError:

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/pandas/core/frame.py in getitem(self, key) 3463 key = list(key) -> 3464 indexer = self.loc._get_listlike_indexer(key, axis=1)[1] 3465

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/pandas/core/indexing.py in _get_listlike_indexer(self, key, axis) 1313 -> 1314 self._validate_read_indexer(keyarr, indexer, axis) 1315

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis) 1376 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique()) -> 1377 raise KeyError(f"{not_found} not in index") 1378

    KeyError: "['res_-10_c'] not in index"

    During handling of the above exception, another exception occurred:

    IndexError Traceback (most recent call last) /tmp/ipykernel_7091/1854355926.py in 2 tp = stock_df['middle'] 3 stock_df['res'] = stock_df['middle'] > df['close'] ----> 4 stock_df[['middle', 'close', 'res', 'res_-10_c']]

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/stockstats.py in getitem(self, item) 1253 if isinstance(item, list): 1254 for column in item: -> 1255 self.__init_column(column) 1256 else: 1257 self.__init_column(item)

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/stockstats.py in __init_column(self, key) 1244 self[key] = [] 1245 else: -> 1246 self.__init_not_exist_column(key) 1247 1248 def getitem(self, item):

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/stockstats.py in __init_not_exist_column(self, key) 1229 c, r, t = ret 1230 func_name = 'get{}'.format(t) -> 1231 getattr(self, func_name)(c, r) 1232 elif len(ret) == 2: 1233 c, r = ret

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/stockstats.py in get_c(self, column, shifts) 251 """ 252 column_name = '{}{}_c'.format(column, shifts) --> 253 shifts = self.get_int_positive(shifts) 254 self[column_name] = self[column].rolling( 255 center=False,

    ~/anaconda3/envs/yfinance1/lib/python3.9/site-packages/stockstats.py in get_int_positive(self, windows) 958 window = self.to_int(windows) 959 if window <= 0: --> 960 raise IndexError("window must be greater than 0") 961 return window 962

    IndexError: window must be greater than 0`

    I will appreciate help to solve this problem.

    opened by akitxu 1
Releases(v0.5.1)
  • v0.5.1(Nov 19, 2022)

    What's Changed

    • [GH-130] CR window is not in the name. by @jealous in https://github.com/jealous/stockstats/pull/131

    Full Changelog: https://github.com/jealous/stockstats/compare/v0.5.0...v0.5.1

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Nov 17, 2022)

    What's Changed

    • [GH-112] Fix minor errors in readme. by @jealous in https://github.com/jealous/stockstats/pull/113
    • Fixing typo in readme - stochastic oscillator examples by @fniko in https://github.com/jealous/stockstats/pull/127
    • [GH-122] Update calculation of middle by @jealous in https://github.com/jealous/stockstats/pull/129

    New Contributors

    • @fniko made their first contribution in https://github.com/jealous/stockstats/pull/127

    Full Changelog: https://github.com/jealous/stockstats/compare/v0.4.1...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.4.1(Jan 7, 2022)

  • v0.4.0(Jan 6, 2022)

Owner
Cedric Zhuang
Cedric Zhuang
ffn - a financial function library for Python

ffn - Financial Functions for Python Alpha release - please let me know if you find any bugs! If you are looking for a full backtesting framework, ple

Philippe Morissette 1.4k Jan 01, 2023
bt - flexible backtesting for Python

bt - Flexible Backtesting for Python bt is currently in alpha stage - if you find a bug, please submit an issue. Read the docs here: http://pmorissett

Philippe Morissette 1.6k Jan 05, 2023
crypto utilities as a way of learning

cryptos Just me developing a pure Python from-scratch zero-dependency implementation of Bitcoin for educational purposes. This includes a lot of the c

Andrej 958 Jan 02, 2023
Python Algorithmic Trading Library

PyAlgoTrade PyAlgoTrade is an event driven algorithmic trading Python library. Although the initial focus was on backtesting, paper trading is now pos

Gabriel Becedillas 3.9k Jan 01, 2023
A banking system is a group or network of institutions that provide financial services for us

A banking system is a group or network of institutions that provide financial services for us. These institutions are responsible for operating a payment system, providing loans, taking deposits, and

UTTKARSH PARMAR 1 Oct 24, 2021
rotki is an open source portfolio tracking, analytics, accounting and tax reporting tool that respects your privacy.

rotki is an open source portfolio tracking, analytics, accounting and tax reporting tool that respects your privacy. The mission of rotki is to bring transparency into the crypto and financial sector

Rotki 2k Dec 30, 2022
Python Backtesting library for trading strategies

backtrader Yahoo API Note: [2018-11-16] After some testing it would seem that data downloads can be again relied upon over the web interface (or API v

DRo 9.8k Dec 30, 2022
Zipline, a Pythonic Algorithmic Trading Library

Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zipline is currently used in production as the backte

Quantopian, Inc. 15.7k Jan 02, 2023
Technical Analysis Library using Pandas and Numpy

Technical Analysis Library in Python It is a Technical Analysis library useful to do feature engineering from financial time series datasets (Open, Cl

Darío López Padial 3.4k Jan 02, 2023
:mag_right: :chart_with_upwards_trend: :snake: :moneybag: Backtest trading strategies in Python.

Backtesting.py Backtest trading strategies with Python. Project website Documentation the project if you use it. Installation $ pip install backtestin

3.1k Dec 31, 2022
Q-Fin: A Python library for mathematical finance.

Q-Fin A Python library for mathematical finance. Installation https://pypi.org/project/QFin/ pip install qfin Bond Pricing Option Pricing Black-Schol

Roman Paolucci 247 Jan 01, 2023
Supply a wrapper ``StockDataFrame`` based on the ``pandas.DataFrame`` with inline stock statistics/indicators support.

Stock Statistics/Indicators Calculation Helper VERSION: 0.3.2 Introduction Supply a wrapper StockDataFrame based on the pandas.DataFrame with inline s

Cedric Zhuang 1.1k Dec 28, 2022
Fourth and final milestone project

Milestone Project 4: Pound Dog Click link to visit "Pound Dog" Aim of the project The aim of this project is to provide access to a website informing

Jamie Wilson 1 Oct 31, 2021
A python wrapper for Alpha Vantage API for financial data.

alpha_vantage Python module to get stock data/cryptocurrencies from the Alpha Vantage API Alpha Vantage delivers a free API for real time financial da

Romel Torres 3.8k Jan 07, 2023
Beibo is a Python library that uses several AI prediction models to predict stocks returns over a defined period of time.

Beibo is a Python library that uses several AI prediction models to predict stocks returns over a defined period of time.

Santosh 54 Dec 10, 2022
personal finance tracker, written in python 3 and using the wxPython GUI toolkit.

personal finance tracker, written in python 3 and using the wxPython GUI toolkit.

wenbin wu 23 Oct 30, 2022
Indicator divergence library for python

Indicator divergence library This module aims to help to find bullish/bearish divergences (regular or hidden) between two indicators using argrelextre

8 Dec 13, 2022
Github.com/CryptoSignal - #1 Quant Trading & Technical Analysis Bot - 2,100 + stars, 580 + forks

CryptoSignal - #1 Quant Trading & Technical Analysis Bot - 2,100 + stars, 580 + forks https://github.com/CryptoSignal/Crypto-Signal Development state:

Github.com/Signal - 2,100 + stars, 580 + forks 4.2k Jan 01, 2023
Python library for backtesting trading strategies & analyzing financial markets (formerly pythalesians)

finmarketpy (formerly pythalesians) finmarketpy is a Python based library that enables you to analyze market data and also to backtest trading strateg

Cuemacro 3k Dec 30, 2022
An open source reinforcement learning framework for training, evaluating, and deploying robust trading agents.

TensorTrade: Trade Efficiently with Reinforcement Learning TensorTrade is still in Beta, meaning it should be used very cautiously if used in producti

4k Dec 30, 2022