Created
February 1, 2012 18:08
-
-
Save danielkorzekwa/1718385 to your computer and use it in GitHub Desktop.
Validating tennis probabilities
This file contains 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
select SUM(total) from bets | |
select sum(total) from (select *, row_number() over (partition by event_id,selection_id order by latest_taken desc) as row from bets) A where row=1 | |
-- P&L per weeek | |
select row_number() over (order by DATEPART(year,settled_date),DATEPART(wk,settled_date)),DATEPART(year,settled_date),DATEPART(wk,settled_date) as week | |
,SUM(total) as total from bets group by DATEPART(year,settled_date),DATEPART(wk,settled_date) | |
--P&L per probability range | |
select cast((1/odds)*100 as int) as price_implied_prob,sum(total) as profit,count(*) as num_of_markets, SUM(cast(win_flag as int)) as wins, | |
100*SUM(cast(win_flag as real)) / count(*) as true_prob, 100*avg(predicted_prob) as predicted_prob | |
from bets s group by cast((1/odds)*100 as int) order by price_implied_prob | |
--Reload probabilities | |
delete from market_prob | |
--insert market probabilities to sql | |
BULK | |
INSERT market_prob | |
FROM 'C:\daniel\betfair_data\tennis_prob_data.csv' | |
WITH | |
( | |
FIELDTERMINATOR = ',', | |
ROWTERMINATOR = '\n', | |
FIRSTROW=2 | |
) | |
delete from market_prob where probability=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment