Get most recent bars

Is there a function to ONLY get the most recent bar for a given symbol using historical bar data (not websocket live data)? I understand get_bars is able to retrieve the most recent bars if passed timestamps through but trying to be more precise here.

@suraj One can use the latest_bar endpoint to get the last available bar (see the docs here).

There are a few things to be aware of

  • this will return the latest minute bar (ie cannot be specified as any other timeframe)
  • bars are only created if there are ‘valid’ trades - because of this, the latest bar may be several minutes old
  • bars are created about 2-3 seconds after the minute - synch ones local clock to NIST time and poll a few seconds after each minute to get the latest bar. Polling sooner will return the previous bar.

One can also get the latest bar information, along with a lot of other data, by using the snapshot endpoint (see the docs here). That also includes the current quote information which may be more helpful than bar prices for some strategies.

Thank you that helps