Hi, I am doing option trading call/put buy based on RSI and 5 min green/ red candle. I am using data column ‘Symbol’ which is storing all F&O stocks
So can you clarify me why the below errors coming and how to rectify it so that if less volume in options could also be able to buy.
Note: i want to use strike price having maximum vol /delta OTM position so what will be the syntax to pick it.
PAPER_MODE = False
MAX_TRADES = 5
MAX_LOTS = 2
TOTAL_CAPITAL = 9000
PARTIAL_TARGET1 = 1.47
TRADE_TYPE = “MIS”
STOP_ENTRY_TIME = datetime.time(14,45)
FORCE_EXIT_TIME = datetime.time(15.10)
IGNORE_SYMBOLS = {
“NIFTY”,“BANKNIFTY”,“FINNIFTY”,“MIDCPNIFTY”,“NIFTYNXT50”
}
positions = {}
traded_symbols = set()
def get_5m_candles(symbol):
data = tsl.get_historical_data(symbol, “NSE”, “5”)
df = pd.DataFrame(data)
return df if len(df) >= 20 else None
def get_ltp(symbol):
try:
if not isinstance(symbol, str):
print(f"Invalid symbol type for LTP: {symbol}")
return None
res = tsl.get_ltp_data(names=symbol)
if not res or symbol not in res:
print(f"LTP fetch failed for {symbol}: {res}")
return None
ltp = res[symbol]
if ltp is None or ltp <= 0:
print(f"Invalid LTP value for {symbol}: {ltp}")
return None
return float(ltp)
except Exception as e:
print(f"Exception at calling ltp for {symbol}: {e}")
return None
CE, PE, _, _ = tsl.OTM_Strike_Selection(Underlying=symbol, Expiry=0, OTM_count=1)
opt = CE if direction == "CE" else PE
opt = str(opt).strip() # CRITICAL FIX
ltp = get_ltp(opt)
if ltp is None:
continue
lot = tsl.get_lot_size(tradingsymbol=opt)
qty = MAX_LOTS * lot
if not PAPER_MODE:
tsl.order_placement(
tradingsymbol=opt, exchange="NFO",
quantity=qty, price=0, trigger_price=0,
order_type="MARKET", transaction_type="BUY",
trade_type=TRADE_TYPE
)
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
LTP fetch failed for BANKINDIA 27 JAN 165 CALL: {}
Skipping BANKINDIA 27 JAN 165 CALL due to LTP failure
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
LTP fetch failed for WIPRO 27 JAN 245 PUT: {}
Skipping WIPRO 27 JAN 245 PUT due to LTP failure
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
LTP fetch failed for RBLBANK 27 JAN 295 PUT: {}
Skipping RBLBANK 27 JAN 295 PUT due to LTP failure
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
LTP fetch failed for 360ONE 27 JAN 1180 PUT: {}
Skipping 360ONE 27 JAN 1180 PUT due to LTP failure
Also let me know your advance video where i can find option buying call/ put without using XLS storing information that video i had already watched . I want simple steps with easy syntax, please guide me.
