Bank Nifty PDF
Bank Nifty PDF
● Account opening
● Checque clearing
● Locker Notices
● Updating database manually
● E- KYC
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
import yfinance as yf
import math
from sklearn.preprocessing import MinMaxScaler
asss=['AUBANK','AXISBANK','BANDHANBNK','BANKBARODA','FEDERALBNK','HDFCBANK','ICICIBANK',
components=list(asss)
components
['AUBANK',
'AXISBANK',
'BANDHANBNK',
'BANKBARODA',
'FEDERALBNK',
'HDFCBANK',
'ICICIBANK',
'IDFCFIRSTB',
'INDUSINDBK',
'KOTAKBANK',
'PNB',
'SBIN']
for i in range(len(components)):
components[i]=components[i]+'.NS'
components
['AUBANK.NS',
'AXISBANK.NS',
'BANDHANBNK.NS',
'BANKBARODA.NS',
'FEDERALBNK.NS',
'HDFCBANK.NS',
'ICICIBANK.NS',
'IDFCFIRSTB.NS',
'INDUSINDBK.NS',
'KOTAKBANK.NS',
'PNB.NS',
'SBIN.NS']
components.append('^NSEBANK')
components
['AUBANK.NS',
'AXISBANK.NS',
'BANDHANBNK.NS',
'BANKBARODA.NS',
'FEDERALBNK.NS',
'HDFCBANK.NS',
'HDFCBANK.NS',
'ICICIBANK.NS',
'IDFCFIRSTB.NS',
'INDUSINDBK.NS',
'KOTAKBANK.NS',
'PNB.NS',
'SBIN.NS',
'^NSEBANK']
data=yf.download(components,start='2007-4-1',end='2023-03-31')
data
[*********************100%***********************] 13 of 13 completed
Adj Close
Date
banknifty=yf.download('^NSEBANK',start='2007-4-1',end='2023-4-1')
[*********************100%***********************] 1 of 1 completed
banknifty
Date
plt.figure(figsize=(16,8))
plt.title('Price Chart')
plt.plot(banknifty['Close'])
plt.xlabel('Date', fontsize=18)
plt.ylabel('Closing Price',fontsize=18)
plt.show()
## volume graph
banknifty['Volume'].plot(label='nifty bank volume',figsize=(16,8))
<Axes: xlabel='Date'>
### log return
logreturn=banknifty['Log Return']=np.log(banknifty['Close']/banknifty['Close'].shift(1))
logreturn
Date
2007-09-17 NaN
2007-09-18 0.023294
2007-09-19 0.047335
2007-09-20 -0.001582
2007-09-21 0.010010
...
2023-03-24 -0.005608
2023-03-27 0.000912
2023-03-28 0.003458
2023-03-29 0.008612
2023-03-31 0.017350
Name: Close, Length: 3538, dtype: float64
## histogram volume
plt.hist(banknifty['Volume'])
plt.show()
#only closing data
close_df=banknifty.filter(['Close'])
dataset
array([[ 6897.10009766],
[ 7059.64990234],
[ 7401.85009766],
...,
[39567.8984375 ],
[39910.1484375 ],
[40608.6484375 ]])
2831
scaled_data
array([[0.08738522],
[0.09137815],
[0.09978408],
...,
[0.88992216],
[0.89832931],
[0.9154875 ]])
training_dataset= scaled_data[0:training_data_len,:]
#spliitting into xtrain and ytrain
x_train=[]
y_train=[]
for i in range(60,len(training_dataset)):
x_train.append(training_dataset[i-60:i,0])
y_train.append(training_dataset[i,0])
if i<=61:
print(x_train)
print(y_train)
print()
## reshaping data
x_train=np.reshape(x_train,(x_train.shape[0],x_train.shape[1],1))
x_train.shape
(2771, 60, 1)
## building LSTM
model=Sequential()
model.add(LSTM(50,return_sequences=True,input_shape=(x_train.shape[1],1)))
model.add(LSTM(50,return_sequences=False))
model.add(Dense(25))
model.add(Dense(1))
##compiling model
model.compile(optimizer='adam',loss='mean_squared_error')
1417.3565986341937
<ipython-input-45-fdc1f080e610>:4: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
Close prediction
Date