Shoonya-Dev / ShoonyaApi-py

145 stars 135 forks source link

get_daily_price_series not working #176

Open Ashiiish82 opened 3 months ago

Ashiiish82 commented 3 months ago

below code not giving data

def candle3(symbol, exchange): end = datetime.datetime.today() end = end.replace(hour=0, minute=15, second=0, microsecond=0) start_date = end - datetime.timedelta(days=10) # Adjusted to 5 days for testing

start_date_str = start_date.strftime('%d-%m-%Y %H:%M:%S')  # Format start_date as string
end_date_str = end.strftime('%d-%m-%Y %H:%M:%S')  # Format end as string

print("Start Date:", start_date_str)
print("End Date:", end_date_str)

# Fetch daily price series
print(f"Fetching data for symbol {symbol} from {start_date_str} to {end_date_str}...")

try:
    ret = api.get_daily_price_series(
        exchange=exchange, 
        tradingsymbol=symbol, 
        startdate=start_date.timestamp(), 
        enddate=end.timestamp()
    )
    print("API Response:", ret)       

except Exception as e:
    print("An error occurred:", e)

Example usage

candle3('NIFTY INDEX', 'NSE')