Created
October 29, 2016 19:46
-
-
Save benrules2/2e21186645bab06e12853dbe5c8de764 to your computer and use it in GitHub Desktop.
Get Bet Info
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
def get_bet_info(base_url, username, password, bet, favourable_odds = 1.91): | |
b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
headers = {'Content-length' : '0', | |
'Content-type' : 'application/json', | |
'Authorization' : "Basic " + b64str.decode('utf-8')} | |
url_without_team = base_url + "/v1/line?sportId={0}&leagueId={1}&eventId={2}&periodNumber={3}&betType=MONEYLINE&OddsFormat=DECIMAL"\ | |
.format(bet['sportId'], bet['leagueId'], bet['eventId'],bet['period']) | |
url = url_without_team + "&Team=Team1" | |
req = ulib.Request(url, headers=headers) | |
responseData = ulib.urlopen(req).read() | |
line_info = json.loads(responseData.decode('utf-8')) | |
if line_info['price'] < favourable_odds: | |
bet['minRiskStake'] = line_info['minRiskStake'] | |
bet['team'] = "Team1" | |
return | |
url = url_without_team + "&Team=Team2" | |
req = ulib.Request(url, headers=headers) | |
responseData = ulib.urlopen(req).read() | |
line_info = json.loads(responseData.decode('utf-8')) | |
bet['minRiskStake'] = line_info['minRiskStake'] | |
bet['team'] = "Team2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment