Beispiel #1
0
def bollinger(df=None, filename=None, interval=None, n=20, ndev=2):

    if filename:
        filename_abs_path = f'{os.getcwd()}/{filename}'
        try:
            df = pd.read_csv(filename_abs_path)
        except:
            raise FileNotFoundError(f'{filename_abs_path}\n\nDoes not exist.')

    # Make all columns lowercase
    df.columns = [col.lower() for col in df]

    if interval:
        df = group_candles(df, interval)

    # Make sure we have more rows of data than the size of the rolling average
    if len(df) < n:
        raise AssertionError(
            'Rolling average cannot be larger than number of records.')

    df['date'] = df['date'].shift(1)

    _bollinger = {}

    # Create base simple moving average
    _bollinger['sma'] = sma(df['close'], n=n)

    rng = ndev * sdev(df['close'], n=n)

    # Create upper and lower bands
    _bollinger['h_band'] = _bollinger['sma'] + rng
    _bollinger['l_band'] = _bollinger['sma'] - rng

    return _bollinger
Beispiel #2
0
    def __init__(self, df=None, filename=None, interval=None):

        if filename:
            df = pd.read_csv(os.getcwd() + '/' + filename)

        # Now that we have our df, make all headers lowercase
        df.columns = [col.lower() for col in df]

        if interval:
            df = group_candles(df, interval)

        self.df = df
        self.ichimoku = {}

        self._validate_data(interval)
Beispiel #3
0
    def __init__(self, df=None, filename=None, interval=None):
        if filename:
            filename_abs_path = f"{os.getcwd()}/{filename}"
            try:
                df = pd.read_csv(filename_abs_path)
            except:
                raise FileNotFoundError(
                    f"{filename_abs_path}\n\nDoes not exist.")

        # Make all columns lowercase
        df.columns = [col.lower() for col in df]

        if interval:
            df = group_candles(df, interval)

        self.df = df
        self.bollinger = {}
Beispiel #4
0
    def __init__(self, df=None, filename=None, interval=None):

        if filename:
            filename_abs_path = f"{os.getcwd()}/{filename}"
            try:
                df = pd.read_csv(filename_abs_path)
            except:
                raise FileNotFoundError(f"{filename_abs_path}\n\nDoes not exist.")

        # Now that we have our df, make all headers lowercase
        df.columns = [col.lower() for col in df]

        if interval:
            df = group_candles(df, interval)

        self.df = df
        self.ichimoku = {}

        self._validate_data(interval)