Getting error in running strategy 1

I was busy for past couple of weeks and now when I try to run the Strategy 1 which is Nifty breakout strategy I am getting error from Upstox api in test mode.

    upstox_client.rest.ApiException: (400)

Reason: Bad Request
HTTP response headers: HTTPHeaderDict({‘Date’: ‘Mon, 21 Jul 2025 16:42:00 GMT’, ‘Content-Type’: ‘application/json’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘vary’: ‘Origin, Access-Control-Request-Method, Access-Control-Request-Headers’, ‘message’: ‘request failed’, ‘requestid’: ‘8daf5d18-36b7-4c6a-9e35-d1042e4cd66a’, ‘x-content-type-options’: ‘nosniff’, ‘x-xss-protection’: ‘1; mode=block’, ‘Cache-Control’: ‘no-cache, no-store, max-age=0, must-revalidate’, ‘pragma’: ‘no-cache’, ‘expires’: ‘0’, ‘strict-transport-security’: ‘max-age=0; includeSubDomains’, ‘x-frame-options’: ‘DENY’, ‘CF-Cache-Status’: ‘MISS’, ‘Set-Cookie’: ‘__cf_bm=UfREsPwMwKoDC1Hkwv4xKao9HDrQmUl80okB9UjhXnQ-1753116120-1.0.1.1-joZfGNb0Psl8C13dhsk7AERqPwwZnQGb7TQsGnvwnQsdcIv6lqoEQGdYpvQWIrCh; path=/; expires=Mon, 21-Jul-25 17:12:00 GMT; domain=.upstox.com; HttpOnly; Secure; SameSite=None, _cfuvid=fPJcDaed92P8yYMYzGm2pTO2FWEkFBMpdNpMlo5ihzE-1753116120582-0.0.1.1-604800000; path=/; domain=.upstox.com; HttpOnly; Secure; SameSite=None’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘962c26297df13b5b-BOM’, ‘alt-svc’: ‘h3=“:443”; ma=86400’})
HTTP response body: b’{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100500”,“message”:“From and to difference too high for interval”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100500”,“property_path”:null,“invalid_value”:null}]}’

This used to work before and I checked documentation seems like api version 2 is getting deprecated. I tried to change to api v3 but still got some more errors. Can someone help in fixing this issue.

Max gap between from and to dates can be only 5 days. This is their new unreasonable restriction.

Yes I had to change the hardcoded 9 days interval to 5 and this step worked. Finally I was able to run this strategy completely today. So a lot of things you need to change. It took me few hours to fix all the issues. Notable things which I remember

  • NSE.csv.gz is deprecated and you have to use NSE.gson.gz. It has changed name for some attributes like tradingsymbol to trading_symbol, strike with strike_price and option_type to instrument_type. AI can fix other errors related to this file.
  • The expiry value which comes in NSE file to get option instrument is changed to Unix epoch timestamp and has to converted first.
  • Finally the response of full market quotes api is also different and code needs to be changed to parse the response.

Hope it will help for anyone who is struggling.

I think they have fixed the problem. Now you can get one month data. Yes I also think this expiry date should be in date format instead of Unix timestamp as expiry is not tone constrained. It adds extra steps to convert 1000s of records to date format.