text_plain_output_1.png
from plotly.subplots import make_subplots

import pandas as pd

import plotly.graph_objects as go

df = pd.read_csv('../input/samsung-electronics-stock-historical-price/005930.KS.csv')
df

fig = make_subplots(specs=[[{'secondary_y':True}]])
fig.add_trace(
    go.Scatter(x=df.Date,y=df.Close,name='Close')
)
fig.add_trace(
    go.Scatter(x=df.Date,y=df['Adj Close'],name='Adj Close')
)
fig.update_layout(xaxis_title='Date',
                  yaxis_title='Price'
                 )
fig.show()

def bolinger(data):
    data['MA20'] = data.Close.rolling(window=20).mean()
    data['std'] = data.Close.rolling(window=20).std()
    data['upper_20'] = data.MA20 + 2 * data['std']
    data['lower_20'] = data.MA20 - 2 * data['std']
    data.drop('std', axis=1, inplace=True)
    data.dropna(inplace=True)
    return data

df = bolinger(df)
df.ffill(inplace=True)
df.reset_index(drop=True, inplace=True)
df