Is there any way to obtain the previous 7 day close for SPY? I'm trying to buy a stock if the current price on close is less than the previous 7 day close, but in my current algorithim, it accounts for the current 7 day close so no orders are being placed. Any help is appreciated!

Author