contest about S&P 500

Hi,Mr. Must the dataframe output from the payout function be from 2007-01-03 to 2016-12-30? In the absence of previous historical data, how to select the stocks to be invested on the first day or in the initial period?

Either you don’t, or you create a logic which is specific to this period.

The payout function doesn’t have to contain the same dates as the input data. Each date in the output (each row) represent a date on which you trade. If your payout first date is 2008-01-03, it means you start allocating to your portfolio at that date; prior to this, you were not invested (you were only holding cash). If the second row of your payout is 2008-02-03, it means you hold the same weights from 2008-01-03 to 2008-02-03 and then change weight. Have a look at the knowledge base (in your menu under research) to see more explanation around what the payout function should be structured.