Skip to content

Instantly share code, notes, and snippets.

@bnsheehy
Created December 28, 2021 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bnsheehy/cc7111a8f0a0b1e5deb8926aa41620b1 to your computer and use it in GitHub Desktop.
Save bnsheehy/cc7111a8f0a0b1e5deb8926aa41620b1 to your computer and use it in GitHub Desktop.
BPI Calculation
SELECT p.date, SUM(p.signal_name = 'BUY') / COUNT(*)
FROM base_pnf_data_historical AS p
LEFT JOIN custom_lists AS c ON p.ticker = c.ticker
WHERE p.date > '2021-01-01'
AND c.list_names LIKE 'SP500%'
GROUP BY p.date;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment