Guided Python project
Backtest a Pre-Market Stock Signal in Python
How does raising the minimum pre-market score change which stocks a daily short rule selects?
Choose Teaching sample to run Python without signing in.
How to run the test
Select a stock using its pre-market score. After the close, attach the stock’s open-to-close return. The workbench flips the sign of that return for a short position.
Worked example · fictional data
Fictional stock EX01 has a score of 0.72. It qualifies at a cutoff of 0.65 but not at 0.80. Its price goes from $10.00 at the open to $9.38 at the close.
score, cutoff = 0.72, 0.65
open_price, close_price = 10.00, 9.38
if score >= cutoff:
gross_short_pct = 100 * (open_price - close_price) / open_price
print(round(gross_short_pct, 2)) # 6.2What the result tells you
The 0.65 rule includes this observation at a gross short return of 6.2%. The 0.80 rule excludes it. Pick your rule on the earlier data, then use it unchanged on the later period.
The score estimates the chance of a drop of at least 5% from open to close. It is not an expected return. Gross outcomes omit trading costs and do not establish that shares were available to short.