Hi TradeHull,
I am unable to get atm values for sensex options,
Below is the error I am facing while running my code,
Can you pls check and sugget me.
Hi TradeHull,
I am unable to get atm values for sensex options,
Below is the error I am facing while running my code,
Can you pls check and sugget me.
Hi @Rizwan,
Itseems the name passed would be incorrect. Do check the underlying name which is been passed.
Hi Priya,
I am able to get name and ltp_name, but option_name is not working…
screenshot attached below… Pls suggest…
Hi @Rizwan ,
Do use our latest updated codebase.
Reference-
https://pypi.org/project/Zerodha-Tradehull/
Hi Priya,
I have updated codebase to 1.0.3 but still I am facing same error. screenshorts attached below.
Hi @Rizwan ,
Can you share the code?
# ================== CORE ENTRY LOGIC ==================
def compute_underlying_context(name: str):
"""Underlying multi-timeframe + market type + swings."""
df = TH.get_short_length_hist_data(name=name, exchange="BSE", interval="5minute", oi=True)
if df.empty or len(df) < 30:
return None, None, None
df["rsi"] = talib.RSI(df["close"], 10)
df["atr"] = talib.ATR(df["high"], df["low"], df["close"], 14)
df["previous_high"] = df["high"].shift(1)
df["previous_low"] = df["low"].shift(1)
df["previous_rsi"] = df["rsi"].shift(1)
df["nifty_vol_ma"] = df["volume"].rolling(8).mean()
sqn_lib.sqn(df=df, period=14)
df["market_type"] = df["sqn"].apply(sqn_lib.market_type)
df.dropna(inplace=True)
df.set_index("date", inplace=True)
completed_candle = df.iloc[-1]
def build_option_df(option_name: str):
"""Indicators on option."""
option_df = TH.get_short_length_hist_data(option_name, "BFO", "5minute", oi=True)
if option_df.empty or len(option_df) < 30:
return None
option_df["rsi"] = talib.RSI(option_df["close"], 10)
option_df["atr"] = talib.ATR(option_df["high"], option_df["low"], option_df["close"], 14)
option_df["macd"], option_df["macd_signal"], _ = talib.MACD(option_df["close"], fastperiod=8, slowperiod=17, signalperiod=7)
indi = ta.supertrend(option_df["high"], option_df["low"], option_df["close"], 7, 3)
option_df = pd.concat([option_df, indi], axis=1, join="inner")
option_df["previous_high"] = option_df["high"].shift(1)
option_df["previous_low"] = option_df["low"].shift(1)
option_df["previous_rsi"] = option_df["rsi"].shift(1)
sqn_lib.sqn(df=option_df, period=14)
option_df["market_type"] = option_df["sqn"].apply(sqn_lib.market_type)
# Volume MA
option_df["sma_20_volume"] = talib.MA(option_df["volume"], timeperiod=20, matype=0)
option_df.set_index("date", inplace=True)
return option_df
def option_entry_decision(
name: str,
script_type: str,
completed_candle,
recent_resistance,
recent_support,
df_underlying,
trend_up,
):
name_ltp = TH.get_data_for_single_script("BSE", name, "ltp")
if name_ltp is None:
return False, None, None, None
bc6 = completed_candle["market_type"] != "neutral"
pdb.set_trace()
# Get ATM option
option_name, expiry, strike = TH.get_atm(ltp=name_ltp, underlying=name, expiry=0, script_type=script_type)
option_ltp = TH.get_data_for_single_script("BFO", option_name, "ltp")
if option_ltp is None:
return False, None, None, None
option_df = build_option_df(option_name)
if option_df is None:
return False, None, None, None
return condition_passed, option_name, option_candle, option_ltp
# ================== MAIN LOOP ==================
Hi @Rizwan ,
Itseems your still using previous functions to fetch data -
name_ltp = TH.get_data_for_single_script("BSE", name, "ltp")
Please refer the below documentation on how to use updated functions-
https://pypi.org/project/Zerodha-Tradehull/
# for ltp
ltp = tsl.get_ltp("SENSEX", "BSE")
Hi @Rizwan ,
As said, functions have been updated. Please refer the below link-
https://pypi.org/project/Zerodha-Tradehull/
# Historical Data
data = tsl.get_short_term_hist_data(name="NIFTY25OCTFUT", exchange="NFO", interval="minute", oi = True)
print(data)
Hi Priya,
I am still gettiing same issue, can you guide me on this…if requried, pls set a call to solve my query.
Hi @Rizwan ,
Please check the name of the function. You are still passing older function.
use the below code
# Historical Data
data = tsl.get_short_term_hist_data(name="NIFTY25OCTFUT", exchange="NFO", interval="minute", oi = True)
print(data)
Got it, Issue resolved.
Thanks, Priya…