How to retrieve recent/current stock data?

This is in python

I am trying to calculate the stocks RSI

I have tried:

current_datetime =

#Get the last 7 days of historical data
start_datetime = current_datetime - timedelta(days=7)

data = api.get_bars(“NVDA”,, start_datetime, current_datetime, limit=100000, adjustment=‘raw’).df

yet I get the error:

400 Client Error: Bad Request for url:

@Bunkiyiester The main issue is that the APIs expect a timezone. The current_datetime is timezone naive. In general, always ensure datetime objects are timezone aware and ideally (for consistancy) ensure the timezone is set to market time. In this instance however UTC is ok.

So change your code to this and it will work

from datetime import datetime, timedelta, timezone

current_datetime =
start_datetime = current_datetime - timedelta(days=7)

data = api.get_bars(“NVDA”, 

ah I see that makes sense, thanks, but is there any way to specify the interval for data?