Bank Nifty Prediction After a Volatile Session

Posted on May 8, 2023 by Quantplay Team ‐ 2 min read

Bank Nifty Prediction After a Volatile Session

Bank nifty has corrected over 1.5% today! Are you worried what might happen tomorrow?

Market corrections can be scary but dont worry, We have compiled the data of last 3 years through our system.

This data shows what has happened on the very next day when bank nifty has corrected over more than 1.5% in a day.

We’ll also show you, How you can compile this data by using quantplay.

Let’s go step by step

Step 1 - Import the data

from quantplay.service import market
import pandas as pd

data = market.data(interval="minute",
                   symbols_by_security_type={"EQ" : ["NIFTY BANK"]})
data.loc[:, "date_only"] = pd.to_datetime(data.date.dt.date)

Step 2 - Add metrics

  • add_intraday_metrics will add intraday_high, intraday_low for the day
  • get_trades will filter single row from the minute candle
  • merge_price will add the price of specific time in the trades dataframe
market.add_intraday_metrics(data, "09:29", "15:15")
trades = market.get_trades(data, "15:15")
trades = market.merge_price(trades, data, time="09:29", column_name="intraday_open")

Step 3 - Predict the returns

Now we will predict the next day return whenever intraday open was more than 1.5% from from the intraday low.

In short we want to predict overnight activity when market crashes 1.5% during intraday window

trades.loc[:, 'next_day_return'] = trades.intraday_open.shift(-1)/trades.close - 1
trades = trades[trades.intraday_open/trades.intraday_low > 1.015]
trades['next_day_return'].describe([.01,.1,.2,.3,.4,.5,.6,.7,.8,.9,.95])
count    167.000000
mean      -0.002876
std        0.018916
min       -0.105069
1%        -0.072596
10%       -0.017573
20%       -0.012317
30%       -0.008366
40%       -0.004152
50%       -0.001888
60%        0.002415
70%        0.005086
80%        0.009131
90%        0.013449
95%        0.020218
max        0.052738
Name: next_day_return, dtype: float64

Conclusion -

After backtesting the data from the last 3 years, the result shows us that around 45% of the days, Next trading session will be volatile. Either returns will be more than 1% or less than 1%