Last active
July 24, 2024 14:31
-
-
Save archiewood/57250c41ee4694910bc3b74b63d2e6d8 to your computer and use it in GitHub Desktop.
Win Probability for the US election in SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PIVOT( | |
select | |
date, | |
contractname as candidate, | |
substring(closeshareprice,2,10)::double as implied_probability | |
from read_csv('https://www.predictit.org/Resource/DownloadMarketChartData?marketid=7456×pan=30d') | |
--where candidate in ('Trump', 'Harris', 'Biden') | |
order by date desc, implied_probability desc | |
) | |
ON candidate using sum(implied_probability) | |
order by 1 desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment