Last traded date does not agree with end date of an asset in the bundle (metadata)

Conder the following script that gets the last date in the bundle for SPY

 import pandas as pd
    from datetime import datetime, timedelta
    from quantrocket.zipline import download_bundle_file
    import io
    import os
    f = io.StringIO()
    lastdate = pd.read_csv(f, parse_dates=["Date"], index_col=["Date"]).index[-1].strftime("%Y-%m-%d")

today I got 2021-03-01 which makes sense

Then launch a backtest with that date:

msg: 'error running function: (''500 Server Error: INTERNAL SERVER ERROR for url:
  {''status'': ''error'', ''msg'': ''Equity(FIBBG000BDTBL9 [SPY]) does not exist on
  2021-03-01 00:00:00+00:00. It stopped trading on 2021-02-26 00:00:00+00:00.''})'

That doesn’t make sense. It looks like during the ingest the “stopped trading date” is set to the previous ingested date, not to the last ingested date.

Wait for Brian, but I’ve had a similar issue with the usstock-1d bundle not updating and it looked like it was pointing to the previous day. He pointed me to this sentence “The US Stock dataset is usually updated by 1 AM New York time with the previous day’s prices”.
Again I’m not sure if this is your issue, but here is the ticket I’m referencing.

Kevin is correct with the explanation.

When you queried the bundle file on March 1, it probably had NaNs for March 1. Check the values not just the date. The date index of the bundle file is based on the trading calendar, even if there is no data available for that date.

Tx Brian