Exemplo n.º 1
0
 def get_all_races(self):
     # Get all games, even those with no scores API feed, search 2 hours in the past
     delta = datetime.timedelta(seconds=60 * 70)
     to_time = datetime.datetime.now() + delta
     event_types = self.client.list_event_types(
         MarketFilter(text_query='horse'))
     horse_racing_id = event_types[0].event_type.id
     countries = config.get('Scraping', 'countries').split()
     events = self.client.list_events(
         filter=MarketFilter(event_type_ids=[horse_racing_id],
                             market_countries=countries,
                             market_start_time=TimeRange(to=to_time)))
     # market_type_codes=self.interested_types)
     if len(events) == 0:
         return [], []  # TODO: shouldn't these be returned as defaultdict?
     markets = defaultdict(list)
     for m in self.client.list_market_catalogue(
             MarketFilter(event_ids=[e.event.id for e in events],
                          market_start_time=TimeRange(to=to_time),
                          market_type_codes=self.interested_types),
             market_projection=[
                 MarketProjection['RUNNER_DESCRIPTION'],
                 MarketProjection['EVENT'],
                 MarketProjection['MARKET_DESCRIPTION'],
                 MarketProjection['MARKET_START_TIME']
             ]):
         markets[m.event.id].append((m.market_id, m))
     return events, markets
    def get_events(self,
                   event_id=None,
                   type_ids=None,
                   inplay=False,
                   time_from=None,
                   time_to=None,
                   market_countries=None):
        get_logger().debug("asking for events",
                           event_id=event_id,
                           inplay=inplay,
                           time_from=time_from,
                           time_to=time_to)

        if event_id is not None:
            events = self.client.list_events(
                MarketFilter(event_ids=[event_id]))
            return events

        events = self.client.list_events(
            MarketFilter(event_type_ids=type_ids,
                         in_play_only=False,
                         market_start_time=TimeRange(from_=time_from,
                                                     to=time_to),
                         market_countries=market_countries), )
        return events
Exemplo n.º 3
0
    def handle(self, *args, **kwargs):
        # XXX: Hardcodign
        msk = timezone('Europe/Moscow')
        utc = timezone('UTC')

        # Loop over configured targets
        for competition in settings.TARGETS:
            cid = self.get_competition_id(competition)

            # Get event list for each target team
            for target in settings.TARGETS[competition]:
                events = self.client.list_events(
                    MarketFilter(text_query=target, competition_ids=cid)
                )
                # Event processing
                for e in events:
                    event_id = int(e.event.id)
                    raw_time = make_aware(e.event.open_date, utc)
                    start_time = localtime(raw_time, msk)
                    # Save persistent data
                    try:
                        event = Event.objects.create(id=event_id,
                                                     title=e.event.name,
                                                     start_time=start_time)
                        event.save()
                        self.stdout.write('Event #%d \'%s\' saved' % (event.id,
                                                                      event.title))
                    except IntegrityError:
                        pass
Exemplo n.º 4
0
 def get_single_race(self, market_id):
     events = self.client.list_events(filter=MarketFilter(
         market_ids=[market_id]))
     if len(events) == 0:
         return [], []  # TODO: shouldn't these be returned as defaultdict?
     markets = defaultdict(list)
     for m in self.client.list_market_catalogue(
             MarketFilter(market_ids=[market_id]),
             market_projection=[
                 MarketProjection['RUNNER_DESCRIPTION'],
                 MarketProjection['EVENT'],
                 MarketProjection['MARKET_DESCRIPTION'],
                 MarketProjection['MARKET_START_TIME']
             ]):
         markets[m.event.id].append((m.market_id, m))
     return events, markets
Exemplo n.º 5
0
def get_market_types(competition):
    """
    Retrieves list of market_types
    :param competition:
    :return:
    """

    return client.list_market_types(
        MarketFilter(competition_ids=[competition.id], ), )
 def test_list_events(self):
     delta = datetime.timedelta(seconds=24 * 60 * 60)
     to_time = datetime.datetime.now() + delta
     events = self.client.list_events(
         filter=MarketFilter(event_type_ids=['7'],
                             market_countries=['GB', 'IRL'],
                             market_start_time=TimeRange(to=to_time)))
     self.assertEqual(len(events), 6)
     self.assertEqual(events[2].event.id, '3453086')
     self.assertEqual(events[3].event.open_date,
                      datetime.datetime(2017, 10, 25, 15, 30))
Exemplo n.º 7
0
    def update_market_list(self):
        markets = self.client.list_market_catalogue(
            MarketFilter(
                event_types_ids=self.event_type,
                turn_in_play_enabled=True,
                in_play_only=False,
            ),
            sort=MarketSort.FIRST_TO_START,
            max_results=1000,
        )

        self.market_ids = [market["market_id"] for market in markets]
 def test_list_markets(self):
     markets = self.client.list_market_catalogue(
         MarketFilter(event_ids=[123, 456, 789], market_type_codes=['WIN']),
         market_projection=[
             MarketProjection['RUNNER_DESCRIPTION'],
             MarketProjection['EVENT'],
             MarketProjection['MARKET_DESCRIPTION'],
             MarketProjection['MARKET_START_TIME']
         ])
     self.assertEqual(len(markets), 27)
     self.assertEqual(len(markets[13].runners), 9)
     self.assertEqual(markets[26].runners[1].selection_id, 13161326)
    def get_markets(self, event_id, text_query=""):

        get_logger().debug("asking for markets",
                           event_id=event_id,
                           text_query=text_query)
        markets = self.client.list_market_catalogue(
            MarketFilter(event_type_ids=soccer_type_ids,
                         text_query=text_query,
                         event_ids=[event_id]),
            max_results=100,
            market_projection=[v.name for v in MarketProjection],
            sort=MarketSort.MAXIMUM_TRADED)
        return markets
Exemplo n.º 10
0
 def fetch_competitions(self):
     event_types = self.db_client.get_event_types()
     for event_type in event_types:
         competitions = self.betfair_client.list_competitions(
             filter=MarketFilter(event_type_ids=[event_type.event_type_id]))
         for competition in competitions:
             id = competition.competition.id
             name = competition.competition.name
             region = competition.competition_region
             market_count = competition.market_count
             event_type_id = event_type.event_type_id
             self.db_client.add_competition(id, name, region, market_count,
                                            event_type_id)
     self.db_client.commit_changes()
Exemplo n.º 11
0
 def fetch_events(self):
     competitions = self.db_client.get_competitions()
     for competition in competitions:
         events = self.betfair_client.list_events(filter=MarketFilter(
             competition_ids=[competition.competition_id]))
         for event in events:
             event_id = event.event.id
             name = event.event.name
             country_code = event.event.country_code
             timezone = event.event.timezone
             venue = event.event.venue
             open_date = event.event.open_date
             market_count = event.market_count
             competition_id = competition.competition_id
             self.db_client.add_event(event_id, name, country_code,
                                      timezone, venue, open_date,
                                      market_count, competition_id)
     self.db_client.commit_changes()
Exemplo n.º 12
0
    def fetch_markets_runners(self):
        events = self.db_client.get_events()
        for event in events:
            markets = self.betfair_client.list_market_catalogue(
                filter=MarketFilter(event_ids=[event.event_id]),
                market_projection=[
                    "RUNNER_DESCRIPTION", 'MARKET_DESCRIPTION',
                    'MARKET_START_TIME', 'RUNNER_METADATA'
                ])
            for market in markets:
                market_id = market.market_id
                name = market.market_name
                description = market.description.betting_type
                market_start_time = market.market_start_time
                event_id = event.event_id
                get_logger().info("adding market",
                                  market_name=name,
                                  market_id=market_id,
                                  description=description,
                                  market_start_time=market_start_time,
                                  event_id=event_id)
                db_market = self.db_client.add_market(market_id, name,
                                                      market_start_time,
                                                      description, event_id)
                for runner in market.runners:
                    selection_id = runner.selection_id
                    runner_name = runner.runner_name
                    handicap = runner.handicap
                    sort_priority = runner.sort_priority
                    meta_data_id = None
                    db_runner = self.db_client.add_runner(
                        selection_id, runner_name, handicap, sort_priority,
                        meta_data_id)
                    if selection_id == 10084745:
                        pass

                    self.db_client.add_runner_map(db_market.market_id,
                                                  db_runner.selection_id)

                self.db_client.commit_changes()
Exemplo n.º 13
0
def get_markets_ids(competition, market_type_codes):
    """
    Gets all the competition IDS in betfair for a given competiion
    and a given market_type

    :param competition: Betfair competition model
    :param market_type_codes: *String* Betfair market codes, to receive
                              market_ids for games
    :return: List of betfair MarketCatalogues for inplay markets in the
             specified league MarketCatalogues will also contain information
             about the event and description about the runners
    """

    return client.list_market_catalogue(
        MarketFilter(
            market_type_codes=[market_type_codes],
            competition_ids=[competition.id],
            # Only get games that are currently running/in play
            in_play_only=True),
        market_projection=[
            MarketProjection.EVENT, MarketProjection.RUNNER_DESCRIPTION
        ]
        # also return details about market event
    )
marketFilter = {
    'eventTypeIds': [7],
    'marketCountries': ['GB'],
    'marketTypeCodes': ["WIN"]
}

markets_hash = client.list_events(marketFilter)
markets = []

print("WRITING TO DB")
for market in markets_hash:
    if ((market.serialize()['event']['openDate'][:10] == date_today)):
        markets.append(
            client.list_market_catalogue(
                MarketFilter(event_ids=market.serialize()['event']['id'],
                             market_type_codes='WIN'),
                market_projection=[MarketProjection(3),
                                   MarketProjection(7)]))
        for event in markets:
            for race in event:
                with connection.cursor() as cursor:
                    cursor.execute(
                        """INSERT IGNORE INTO races VALUES (%s,%s,%s,%s,%s,%s)""",
                        (date_today, race.serialize()['event']['countryCode'],
                         race.serialize()['event']['venue'],
                         race.serialize()['marketStartTime'][11:19],
                         race.serialize()['event']['id'] + ' / ' +
                         race.serialize()['marketId'],
                         race.serialize()['marketName']))
print("DONE")
Exemplo n.º 15
0
def get_tennis_event(event_id):
    market_catalogue = client.list_market_catalogue(
        MarketFilter(event_ids=[event_id]))

    return market_catalogue
Exemplo n.º 16
0
def getOdds(Sport, User = "******",input_time = "Null",Market = 'MATCH_ODDS'):

    import pandas as pd
    import login
    import pytz
    import datetime
    from time import gmtime, strftime
    from betfair import utils
    from betfair import models
    from betfair import exceptions
    from betfair.models import MarketFilter
    from betfair.models import PriceProjection
    from betfair.models import ExBestOffersOverrides
    from betfair.models import MarketData

    if User == "Tom":
        #Tom
        client = login.login('Np2HwoLYyAQk2X6s', 'tombish22','parksandrec19')
    else:
        # Cal
        client = login.login('eTnX7n6jsiaoGA9g', '*****@*****.**','wyeslsc10')

    # Grab the sports that match the string provided as an argument
    event_types = client.list_event_types(MarketFilter(text_query=Sport))

    # Grab the ID of the requested sport
    sport_id = event_types[0].event_type.id

    # Pull the event details data for the sport and market specified as an argument
    betting_markets = client.list_market_catalogue(MarketFilter(event_type_ids=[sport_id], market_type_codes=[Market]), market_projection =  ['COMPETITION','EVENT','EVENT_TYPE','RUNNER_DESCRIPTION','MARKET_START_TIME'])

    # #Gets the list of market IDs in the Betting Market
    sports_market_ids = []
    for eachMarket in betting_markets:
        sports_market_ids = sports_market_ids + [eachMarket.market_id]

    # #Get the MarketBookResults
    maxpullsize = 100
    index=0
    # print len(sports_market_ids)
    marketbook_result = []
    while index+maxpullsize < len(sports_market_ids):
        marketbook_result = marketbook_result + client.list_market_book([sports_market_ids[index:index+maxpullsize]],PriceProjection(price_data=['EX_BEST_OFFERS'],exBestOffersOverrides=ExBestOffersOverrides(best_prices_depth=1)))
        index=index+maxpullsize
    marketbook_result = marketbook_result + client.list_market_book([sports_market_ids[index:len(sports_market_ids)]],PriceProjection(price_data=['EX_BEST_OFFERS'],exBestOffersOverrides=ExBestOffersOverrides(best_prices_depth=1)))  


    print 'Compiling Dataset'
    market_data = []
    for market in betting_markets:
        next_market_data = MarketData(market,next((x for x in marketbook_result if x.market_id == market.market_id), None))
        market_data.append(next_market_data)


    print 'Creating individual runner data'
    local = pytz.timezone ("Australia/Melbourne")
    runner_data = []
    for mindex, market in enumerate(market_data):
        for rindex, runner in enumerate(market.runners):
            runner_to_add = {'market_id': market.market_id, 
                                'market_name': market.market_name, 
                                'market_start_time': market.market_start_time.replace(tzinfo=pytz.utc).astimezone(local).strftime("%Y-%m-%d %H:%M:%S"),
                                'market_start_time_dt': market.market_start_time.replace(tzinfo=pytz.utc).astimezone(local),
                                #'total_matched':market.total_matched,
                                #'active_runners':market.number_of_active_runners,
                                'status':market.status,
                                #'total_available':market.total_available,
                                #'total_matched':market.total_matched,
                                #'selection_id':market.runner_catalog[rindex].selection_id,
                                'runner_name':market.runner_catalog[rindex].runner_name,
                                'price_selection_id':runner.selection_id,
                                'runner_status':runner.status
                                }
            
            if len(runner.ex.available_to_back)>0:
                runner_to_add.update({                         
                                'available_to_back_price':runner.ex.available_to_back[0].price,
                                'available_to_back_market':runner.ex.available_to_back[0].size
                                })
            if len(runner.ex.available_to_lay)>0:
                runner_to_add.update({                         
                                'available_to_lay_price':runner.ex.available_to_lay[0].price,
                                'available_to_lay_market':runner.ex.available_to_lay[0].size
                                })
            runner_data.append(runner_to_add)


    MarketDf = pd.DataFrame(runner_data)
    
    dt_cutoff = datetime.datetime.now().replace(tzinfo = local) + datetime.timedelta(days=2)

    # Only interested in open markets
    MarketDf.query("status == 'OPEN'", inplace=True)
    
    # Filter markets for those starting in the next 2 days
    MarketDf = MarketDf[(MarketDf.market_start_time_dt <= dt_cutoff)]
    
    #Add a logged time
    MarketDf.loc[:,"log_time"] = input_time
        
    #Reorder the columns and select
    cols = ["log_time","market_start_time","market_id","market_name","runner_name","price_selection_id","available_to_back_price","available_to_back_market","available_to_lay_price","available_to_lay_market"]
    MarketDf = MarketDf.loc[:,cols]
    
    return MarketDf
Exemplo n.º 17
0
def get_competition(name):
    c = client.list_competitions(MarketFilter(text_query=name))
    if len(c) > 0:
        return c
Exemplo n.º 18
0
#!/usr/bin/env python
from betfair import Betfair
import sys

print "HugeHard Test Script"
client = Betfair('fxmlhjiDhNghfmLP',
                 'C:/Users/Cong/Desktop/betfair/keys/shang.pem')
client.login('*****@*****.**', 'wabjtam@123')
print 'login successful'

sys.exit

from betfair.models import MarketFilter

event_types = client.list_event_types(MarketFilter(text_query='basketball'))

#print (len(event_types))
#print (event_types[0].event_type.name)
football_event_type = event_types[0]

competitions = client.list_competitions()
for comp in competitions:
    a = comp['competition']
    if a.name == u'NBA Matches':
        id_NBA = a.id

events = client.list_events(MarketFilter(competition_ids=[id_NBA]))
f = open('C:/Users/Cong/Desktop/betfair/log_basketball.txt', 'w')
for eventResult in events:
    e = eventResult.event
    c = eventResult.market_count
Exemplo n.º 19
0
tab = []

with open('events_schedule', 'r') as f:
    for line in f:
        tab.append(line.split(","))
race_time = tab[0][0]
marketId = [[row[2][1:9], row[2][12:-1]] for row in tab]

with open('temp_schedule', 'w+') as f:
    del tab[0]
    for row in tab:
        f.write(row[0] + ',' + row[1] + ',' + row[2])
rename('temp_schedule', 'events_schedule')

hardcoded = marketId[0][1]
runners = client.list_market_catalogue(MarketFilter(market_ids=hardcoded,
                                                    market_type_codes='WIN'),
                                       market_projection=[MarketProjection(6)])

selectionId = []
runnerName = []
for i in range(len(runners[0].serialize()['runners'])):
    selectionId.append(runners[0].serialize()['runners'][i]['selectionId'])
    runnerName.append(runners[0].serialize()['runners'][i]['runnerName'])

d = dict(zip(selectionId, runnerName))

level = 3
projection = {
    'priceData': ['EX_BEST_OFFERS', 'SP_AVAILABLE', 'SP_TRADED'],
    'virtualise': False,
    'exBestOffersOverrides': {
Exemplo n.º 20
0
def betfair_get(self, is_ip, counter, sport='Tennis'):
    start = timezone.now()
    ip = 'ip' if is_ip else 'ni'

    client = Betfair('GkhXY3b3KmncnwLe', 'certs/bf.pem')
    # client = Betfair('uv9hV1EjlFimHmgr', 'certs/bf.pem')
    client.login('sherst', 'osT1G11nRe35')
    client.keep_alive()
    tennis_event_type = self.sports[sport]
    markets = client.list_market_catalogue(
        MarketFilter(event_type_ids=[tennis_event_type],
                     market_type_codes=["MATCH_ODDS"],
                     in_play_only=is_ip),
        market_projection=["EVENT", "RUNNER_METADATA", "COMPETITION"],
        max_results=200)
    mids = [m.market_id for m in markets]
    mids_portions = [mids[x:x + 40] for x in xrange(0, len(mids), 40)]
    for mp in mids_portions:
        print(','.join(mp))
        books = client.list_market_book(
            mp,
            price_projection=PriceProjection(
                price_data=betfair.constants.PriceData.EX_BEST_OFFERS))
        for b in books:
            m = next((x for x in markets if x.market_id == b.market_id), None)
            if m.competition == None: continue
            bfcid = m.competition.id
            champname = m.competition.name
            country = m.event.country_code
            event_id = m.event.id
            ds = timezone.make_aware(m.event.open_date)
            p1 = m.runners[0].runner_name
            if (p1 == None or '/' in p1):
                continue
            rid1 = m.runners[0].selection_id
            p2 = m.runners[1].runner_name
            rid2 = m.runners[1].selection_id
            event, created = BFEvent.objects.get_or_create(bfid=event_id)
            if (created):
                champ = self.save_champ(bfcid, champname, tennis_event_type,
                                        country)
                player1 = self.save_player(p1)
                player2 = self.save_player(p2)
                event.cid = champ
                event.rid1 = rid1
                event.rid2 = rid2
                event.pid1 = player1
                event.pid2 = player2
                event.dt = ds
                event.status = 1 if is_ip else 0
                event.save()
            p1b1_odds = b.runners[0].ex.available_to_back[0].price if len(
                b.runners[0].ex.available_to_back) > 0 else 0
            p1b1_size = b.runners[0].ex.available_to_back[0].size if len(
                b.runners[0].ex.available_to_back) > 0 else 0
            p1l1_odds = b.runners[0].ex.available_to_lay[0].price if len(
                b.runners[0].ex.available_to_lay) > 0 else 0
            p1l1_size = b.runners[0].ex.available_to_lay[0].size if len(
                b.runners[0].ex.available_to_lay) > 0 else 0
            p2b1_odds = b.runners[1].ex.available_to_back[0].price if len(
                b.runners[1].ex.available_to_back) > 0 else 0
            p2b1_size = b.runners[1].ex.available_to_back[0].size if len(
                b.runners[1].ex.available_to_back) > 0 else 0
            p2l1_odds = b.runners[1].ex.available_to_lay[0].price if len(
                b.runners[1].ex.available_to_lay) > 0 else 0
            p2l1_size = b.runners[1].ex.available_to_lay[0].size if len(
                b.runners[1].ex.available_to_lay) > 0 else 0
            if (self.is_debug):
                self.stdout.write('*** evid [%s] %s - %s at %s, changed %s\n' %
                                  (event.id, event.pid1.name, event.pid2.name,
                                   event.dt, event.dtc),
                                  ending='')
            try:
                odds = BFOdds.objects.filter(eid=event).latest('dtc')
                if (odds.b1odds != p1b1_odds or odds.b2odds != p2b1_odds
                        or odds.l1odds != p1l1_odds
                        or odds.l2odds != p2l1_odds):
                    self.save_odds(event, p1b1_odds, p2b1_odds, p1l1_odds,
                                   p2l1_odds, p1b1_size, p2b1_size, p1l1_size,
                                   p2l1_size, is_ip)
                    if (self.is_debug):
                        self.stdout.write(
                            'evid[%s], mid[%s] %s %s - %s in %s: %s/%s\n' %
                            (event_id, b.market_id, ds, p1.replace(
                                '\\', ''), p2.replace('\\', ''), country,
                             b.total_matched, b.total_available),
                            ending='')
                        self.stdout.write(
                            '[%s]%s:%s@%s\t|%s@%s\n' %
                            (rid1, p1.replace('\\', ''), p1b1_size, p1b1_odds,
                             p1l1_size, p1l1_odds),
                            ending='')
                        self.stdout.write(
                            '[%s]%s:%s@%s\t|%s@%s\n' %
                            (rid2, p2.replace('\\', ''), p2b1_size, p2b1_odds,
                             p2l1_size, p2l1_odds),
                            ending='')
            except:
                self.save_odds(event, p1b1_odds, p2b1_odds, p1l1_odds,
                               p2l1_odds, p1b1_size, p2b1_size, p1l1_size,
                               p2l1_size, is_ip)
                if (self.is_debug):
                    self.stdout.write(
                        'evid[%s], mid[%s] %s %s - %s in %s: %s/%s\n' %
                        (event_id, b.market_id, ds, p1.replace(
                            '\\', ''), p2.replace('\\', ''), country,
                         b.total_matched, b.total_available),
                        ending='')
                    self.stdout.write('[%s]%s:%s@%s\t|%s@%s\n' %
                                      (rid1, p1.replace('\\', ''), p1b1_size,
                                       p1b1_odds, p1l1_size, p1l1_odds),
                                      ending='')
                    self.stdout.write('[%s]%s:%s@%s\t|%s@%s\n' %
                                      (rid2, p2.replace('\\', ''), p2b1_size,
                                       p2b1_odds, p2l1_size, p2l1_odds),
                                      ending='')
    end = timezone.now()
    log = ALog()
    log.name = 'update_bf_%s_%s' % (sport, ip)
    log.dts = start
    log.counter = counter
    log.duration = (end - start).total_seconds()
    log.save()
    if (self.is_debug):
        self.stdout.write('total execution is %s seconds\n' % (end - start),
                          ending='')
Exemplo n.º 21
0
from betfair_wrapper.authenticate import authenticate
from list_team import team_list, over_under

client = authenticate()

from betfair.models import MarketFilter
event_types = client.list_event_types(MarketFilter(event_type_ids=[]))
print(len(event_types))

for et in event_types:
    print(et.event_type.name)
    print(et.event_type.id)
# 'Tennis'
soccer_type_ids = [1]
all_over_under = ','.join(over_under)
market_porjection = [
    "COMPETITION", "MARKET_START_TIME", "RUNNER_DESCRIPTION", "EVENT"
]
markets = client.list_market_catalogue(MarketFilter(
    event_type_ids=soccer_type_ids,
    event_types=team_list,
    text_query="OVER_UNDER_*5"),
                                       market_projection=market_porjection,
                                       max_results=1000)

print("here")
#book = client.list_market_book(market_ids=)

for market in markets:
    market._data["event_name"] = market._data["event"]["name"]
 def test_event_types(self):
     event_types = self.client.list_event_types(
         MarketFilter(text_query='horse'))
     self.assertEqual(event_types[0].event_type.id, '7')
Exemplo n.º 23
0
 def get_competition_id(self, name):
     competitions = self.client.list_competitions(
         MarketFilter(text_query=name)
     )
     for obj in competitions:
         return obj.competition.id
<<<<<<< HEAD
client = login.login('eTnX7n6jsiaoGA9g', '*****@*****.**','wyeslsc10')
=======
#client = login.login('eTnX7n6jsiaoGA9g', '*****@*****.**','wyeslsc10')

client.keep_alive()
>>>>>>> origin/master

from betfair.models import MarketFilter
from betfair.models import PriceProjection
from betfair.models import ExBestOffersOverrides
from betfair.models import MarketData

MarketSearch = raw_input('Enter Sports String to search: ')

event_types = client.list_event_types(MarketFilter(text_query=MarketSearch))

print 'Sports That Match: ' + str(len(event_types))
key = 0
for events in event_types:
    print 'Key : ' + str(key) + ' Sport: ' + events.event_type.name
    key = key+1

SportSearch = raw_input('Enter Key of Sport:')

sport_event_type = event_types[int(SportSearch)]
print 'Sport Selected: ' + event_types[int(SportSearch)].event_type.name + 'Sport ID: ' + str(sport_event_type.event_type.id)
market_types = client.list_market_types(MarketFilter(event_type_ids=[sport_event_type.event_type.id]))

key = 0
for markets in market_types:
Exemplo n.º 25
0
import betfair

from betfair import Betfair
client = Betfair('eTnX7n6jsiaoGA9g',
                 ('certs/client-2048.crt', 'certs/client-2048.key'))
print 'Logging in'
client.login('*****@*****.**', 'wyeslsc10')

print 'Keeping alive'
client.keep_alive()

account_details = client.get_account_details()
print account_details
a = account_details.currency_code
print a

from betfair.models import MarketFilter
event_types = client.list_event_types(MarketFilter(text_query='tennis'))
print event_types
print event_types[0]
print event_types[0].event_type

print(len(event_types))  # 2
print(event_types[0].event_type.name)  # 'Tennis'

tennis_event_type = event_types[0]
markets = client.list_market_catalogue(
    MarketFilter(event_type_ids=[tennis_event_type.event_type.id]))
print markets[0].market_name  # 'Djokovic Tournament Wins'

client.logout()
Exemplo n.º 26
0
from betfair import models
from betfair import exceptions

#Tom
#client = login.login('Np2HwoLYyAQk2X6s', 'tombish22','parksandrec19')
# Cal
client = login.login('eTnX7n6jsiaoGA9g', '*****@*****.**', 'wyeslsc10')

from betfair.models import MarketFilter
from betfair.models import PriceProjection
from betfair.models import ExBestOffersOverrides
from betfair.models import MarketData

MarketSearch = raw_input('Enter Sports String to search: ')

event_types = client.list_event_types(MarketFilter(text_query=MarketSearch))

print 'Sports That Match: ' + str(len(event_types))
key = 0
for events in event_types:
    print 'Key : ' + str(key) + ' Sport: ' + events.event_type.name
    key = key + 1

SportSearch = raw_input('Enter Key of Sport:')

sport_event_type = event_types[int(SportSearch)]
print 'Sport Selected: ' + event_types[int(
    SportSearch)].event_type.name + 'Sport ID: ' + str(
        sport_event_type.event_type.id)
market_types = client.list_market_types(
    MarketFilter(event_type_ids=[sport_event_type.event_type.id]))
Exemplo n.º 27
0
#!/usr/bin/env python
from betfair import Betfair
import sys

print "HugeHard Test Script"
client = Betfair('fxmlhjiDhNghfmLP',
                 '/home/shang/git/betfair.py/certs/betfair.pem')
client.login('*****@*****.**', 'wabjtam@123')
print 'login successful'

from betfair.models import MarketFilter
event_types = client.list_event_types(MarketFilter(text_query='soccer'))

print(len(event_types))
print(event_types[0].event_type.name)
football_event_type = event_types[0]

events = client.list_events(
    MarketFilter(event_type_ids=[football_event_type.event_type.id]))

for eventResult in events:
    e = eventResult.event
    c = eventResult.market_count
    print "id:" + e.id + ", name=" + e.name + ", market_count:" + str(c)
    markets = client.list_market_catalogue(MarketFilter(event_ids=[e.id]))
    for m in markets:
        print "    - market: ", m.market_id, m.market_name

#markets = client.list_market_catalogue(
#    MarketFilter(event_type_ids=[football_event_type.event_type.id])
#)