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()
download_bundle_file(bundle,sids=["FIBBG000BDTBL9"],start_date=pd.to_datetime(datetime.now()-timedelta(days=5)).strftime("%Y-%m-%d"),filepath_or_buffer=f)
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:
http://houston/zipline/backtests/ALGO?capital_base=1000000&start_date=2020-12-31&end_date=2021-03-01'',
{''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.