Example #1
0
def place_ta_bet_fix(row) :
    l_log = startBetLogging("common")
    if row['winner'] == 'home' :
        winner_name = row['home_player_name']
        winner_odds_id = row['home_odds_id']
        winner_odds = row['home_odds']
        winner_proba = row['home_player_proba']
    else :
        winner_name = row['away_player_name']
        winner_odds_id = row['away_odds_id']        
        winner_odds = row['away_odds']
        winner_proba = row['away_player_proba']

    
    #calc_stakes = round(stakes / (winner_odds - 1),1)
    calc_stakes =  stakes_fix
    
    status = placeBet(winner_odds_id, winner_odds, calc_stakes, product_id=8)
    #status = False
    
    if status :
        l_log.warn("place bet on event '" + str(row['home_player_name']) + " vs " + str(row['away_player_name']) + \
                 "' winner " + str(winner_name) + \
                 " stakes : " + str(calc_stakes) + \
                 " odds : " + str(winner_odds) + \
                 " proba : " + str(winner_proba))
        
    return True
Example #2
0
def place_ta_bet_value(row) :
    l_log = startBetLogging("common")
    if row['winner'] == 'home' :
        winner_name = row['home_player_name']
        winner_odds_id = row['home_odds_id']
        winner_odds = row['home_odds']
        winner_proba = row['home_player_proba']
        winner_value = row['home_value']
    else :
        winner_name = row['away_player_name']
        winner_odds_id = row['away_odds_id']        
        winner_odds = row['away_odds']
        winner_proba = row['away_player_proba']
        winner_value = row['away_value']


    
        
    #calc_stakes = round(stakes / (winner_odds - 1),1)
    if 'Challenger' in row['ta_tournament'] :
        calc_stakes =  stakes_value_challenger
        product = 9
    elif 'ATP' in row['ta_tournament'] :
        calc_stakes =  stakes_value_atp
        product = 10     
    elif 'WTA' in row['ta_tournament'] :
        calc_stakes =  stakes_value_wta
        product = 11
    else :
        calc_stakes = stakes_value_gs
        product = 12
        
    
    if product != 11 :
        status = placeBet(winner_odds_id, winner_odds, calc_stakes, product_id=product)
    else :
        status = False
    
    
    if status :
        l_log.warn("place bet on event '" + str(row['home_player_name']) + " vs " + str(row['away_player_name']) + \
                 "' winner " + str(winner_name) + \
                 " stakes : " + str(calc_stakes) + \
                 " odds : " + str(winner_odds) + \
                 " value : " + str(round(winner_value, 2)) + \
                 " proba : " + str(winner_proba))
        
    return True
Example #3
0
def place_ttt_bet(row):
    l_log = startBetLogging("common")
    winner_name = row['winner_player_name']
    winner_odds_id = row['winner_odds_id']
    winner_odds = row['winner_odds']
    winner_proba = row['winner_proba']

    calc_stakes = stakes

    status = placeBet(winner_odds_id, winner_odds, calc_stakes, product_id=7)
    #status = False

    if status:
        l_log.warn("place bet on event '" + str(row['winner_player_name']) + \
                 "' winner " + str(winner_name) + \
                 " stakes : " + str(calc_stakes) + \
                 " odds : " + str(winner_odds) + \
                 " proba : " + str(winner_proba))

    return True
Example #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 14 17:01:56 2017

@author: chrhae
"""
import pandas as pd
from comeon_common import connect
from sqlalchemy import update
from comeon_common import startBetLogging

conn, meta = connect()
log = startBetLogging("calculate fair odds")
tbl_match = meta.tables['tbl_match']


def updateSQLfairbet(row):


    stm = update(tbl_match).where(tbl_match.columns.match_id==row['match_id']).\
                 values(player1_proba=row['player1_proba'],
                        player2_proba=row['player2_proba'],\
                        player1_fair_odds=row['player1_fair_odds'],\
                        player2_fair_odds=row['player2_fair_odds'])

    conn.execute(stm)


def calcFairOdds():
Example #5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 14 17:01:56 2017

@author: chrhae
"""
import pandas as pd
from comeon_common import connect
from comeon_common import startBetLogging
from datetime import datetime, timedelta


conn, meta = connect()    
log = startBetLogging("create_ranking")


def createRanking(date) :
   
    log.info("Load ranking form Swisstennis")  
    sql = """
        select a."Player", a."FromDate", a."ToDate", a."SW1YALL",  b."SW3MALL", c."SW1MALL", d."SW1YG", e."SW1YH",  f."SW1YC"
        from "temp_ranking_SW1YALL" a
        left join "temp_ranking_SW3MALL" b using ("Player", "FromDate", "ToDate")
        left join "temp_ranking_SW1MALL" c using ("Player", "FromDate", "ToDate")        
        left join "temp_ranking_SW1YG" d using ("Player", "FromDate", "ToDate")
        left join "temp_ranking_SW1YH" e using ("Player", "FromDate", "ToDate")        
        left join "temp_ranking_SW1YC" f using ("Player", "FromDate", "ToDate") 
        where "FromDate" = date '{date}'         
        """
    d = {'date': date}
Example #6
0
from datetime import datetime
import numpy as np
import math
from comeon_common import connect, getBtcEurPrice
from comeon_common import startBetLogging
from comeon_common import checkBetforPlace, placeBet, checkOffer, placeOffer, closeOffer

# load data from the configuration
import yaml
with open("config.yml", 'r') as ymlfile:
    cfg = yaml.load(ymlfile)

margin_init = 0.02
margin_check = 0.01

log = startBetLogging("laybet")
con, meta = connect()
tbl_offer = meta.tables['tbl_offer']
tbl_events = meta.tables['tbl_events']
tbl_orderbook = meta.tables['tbl_orderbook']


def calcLayOdds(back_odds=1.2,
                margin=margin_init,
                invest=cfg['laybet']['invest']):
    # invest = 1

    back_stake = round(invest / back_odds, 2)
    max_lay = round(invest - back_stake, 2)
    lay_win = round(back_stake + (invest * margin), 2)
    odds_calc = (max_lay / lay_win) + 1
Example #7
0
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 13 17:25:55 2017

@author: haenec
"""

from datetime import datetime, timedelta
import os

from comeon_etl import etl_te_get_matches, etl_import_te_daily_results, etl_transform_te_results, etl_import_te_daily_player, etl_te_get_missing_players
from comeon_etl import etl_transform_te_players, etl_transform_te_matchdetails, etl_import_te_daily_matchdetails
from comeon_etl import calcFairOdds, etl_te_get_matchesdetails_all, weeklyModelSwisstennis, etl_te_get_ranking, etl_import_te_weekly_ranking, createRanking
from comeon_common import startBetLogging

log = startBetLogging("etl")

#sqllite3_path = 'c:\\users/haenec/python/home/comeon/data/te_data.db'
#todate = date

try:
    os.remove('te_data.db')
except OSError:
    pass

etl_te_get_matchesdetails_all()
etl_import_te_daily_matchdetails()
etl_transform_te_matchdetails()
Example #8
0
"""

from sqlalchemy import select, update
from sqlalchemy.dialects.postgresql import insert
from datetime import datetime
import numpy as np
from comeon_common import connect, getBtcEurPrice
from comeon_common import startBetLogging
from comeon_common import checkBetforPlace, placeBet

# load data from the configuration
import yaml
with open("config.yml", 'r') as ymlfile:
    cfg = yaml.load(ymlfile)

log = startBetLogging("surebet")
con, meta = connect()
tbl_surebet = meta.tables['tbl_surebet']
tbl_events = meta.tables['tbl_events']


def checkStake(market_stake, bookie_stake, max_market_stake_btc):
    max_market_stake_btc = float(max_market_stake_btc) * getBtcEurPrice()
    if market_stake < max_market_stake_btc:
        return market_stake, bookie_stake
    elif market_stake >= max_market_stake_btc:
        new_market_stake = round(max_market_stake_btc - 1, 2)
        new_bookie_stake = round(
            bookie_stake * (new_market_stake / market_stake), 2)
        return new_market_stake, new_bookie_stake