Hi Remi,
I worked on a similar topic this week so happy to help. To get price X days earlier you will need to create a CustomFactor. Find an example below:
class Close_Price_2_Days_Ago(CustomFactor):
# A factor to return the close price 2 days ago (the day before yesterday)
inputs = [USEquityPricing.close]
window_length = 2
def compute(self, today, assets, out, close_price):
out[:] = close_price[0]
I found the way to call historical prices in output out[:] a bit confusing at start but the logic is the same than in numpy arrays.
close[-1] is close of the latest row (so last data available). close[0] is first close in the selected array, so the oldest close in the array defined by the window_length parameter. If window_length = 20 it means that you have an array of 20 rows (=20 days)*more than 8000 columns (one per stock).
You can find numerous posts explaining this.
Regarding USEquityPricing , it is called a Dataset. Please have a look at the following Help page.
It is very clear. Think of USEquityPricing.close or USEquityPricing .open as numpy arrays with size (dates * assets).
Good luck!