issue with greek data
-
LOGIN FUNCTION
-----------------------
def login_once():
print("Logging in...")
totp = pyotp.TOTP(totp_secret).now()
smart = SmartConnect(api_key)
session = smart.generateSession(client_code, pin, totp)
jwt = session['data']['jwtToken']
return jwt-----------------------
MAIN EXECUTION
-----------------------
if name == "main":
jwt_token = login_once()# ✅ Your machine info local_ip = public_ip = mac_addr = url = "https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/optionGreek" headers = { "Authorization": f"Bearer {jwt_token}", "X-ClientLocalIP": local_ip, "X-ClientPublicIP": public_ip, "X-MACAddress": mac_addr, "X-UserType": "USER", "X-SourceID": "WEB", "Content-Type": "application/json", "Accept": "application/json" } payload = { "name": "NIFTY", "expirydate": "26JUN2025" } print("📡 Fetching Greeks...") try: response = requests.post(url, headers=headers, json=payload, timeout=10) data = response.json() print("📦 Full response:") print(data) if "data" in data and data["data"]: print("✅ Option Greeks:") for option in data["data"]: print( f"{option['strikePrice']} {option['optionType']} | " f"Δ={option['delta']} Γ={option['gamma']} Θ={option['theta']} " f"Vega={option['vega']} IV={option['impliedVolatility']} Vol={option['tradeVolume']}" ) else: print("⚠️ No data found in response or empty 'data' array.") except Exception as e: print("❌ Failed to fetch or parse response:", e)
getting error as follwoing
Logging in...
[I 250625 16:22:56 smartConnect:121] in pool
Fetching Greeks...
Full response:
{'success': False, 'message': 'Invalid Token', 'errorCode': 'AG8001', 'data': ''}
️ No data found in response or empty 'data' array.