Satelite output into var via cron

I have written a small script that gets the last date in the bundle and I can launch it with Satelite:

jupyter:/codeload $ eval 'quantrocket satellite exec codeload.scripts.satelite.get_lastdate'
output: '2021-03-01'
status: success

Now I want to feed that output into the backtest end-date (via the var $END):

quantrocket zipline backtest riskpar.DEF -s $LOOK_BACK -e $END -o "/codeload/results/result-riskpar-$now.csv"

How can I set a variable with the output of the first script?

for completeness: the script to get the last day in the bundle:

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

Just parse the bash output into a variable, or use the Python API to run everything and pass the variable that way.

1 Like