Exemplo n.º 1
0
 def place_bet(self, sport_id, event_id, line_id, period_number, bet_type, stake, team=None, side=None,
               alt_line_id=None, win_risk_stake=WinRiskType.Risk.value, accept_better_line=Boolean.TRUE.name,
               odds_format=OddsFormat.Decimal.value, fill_type=FillType.Normal, pitcher1_must_start=None,
               pitcher2_must_start=None, customer_reference=None, session=None):
     """
     Place bet in the system.
     
     :param sport_id: sport identification
     :param event_id: event identification
     :param line_id: Line identification
     :param period_number: This represents the period of the match. 
     :param bet_type: type of bet to be placed, see pinnacle.enums.BetType
     :param stake: Wagered amount in Clients currency
     :param team: Chosen team type. This is needed only for SPREAD, MONEYLINE and TEAM_TOTAL_POINTS bet types
     :param side: Chosen side. This is needed only for TOTAL_POINTS and TEAM_TOTAL_POINTS bet type
     :param alt_line_id: Alternate line identification
     :param win_risk_stake: Whether the stake amount is risk or win amount
     :param accept_better_line: Whether or not to accept a bet when there is a line change in favor of the client.
     :param odds_format: Bet is processed with this odds format.
     :param fill_type: FillAndKill, if stake > maxbet will fill max bet. FillMaxLimit, ignore stake and stake to max bet.
     :param pitcher1_must_start: Baseball only. Refers to the pitcher for TEAM_TYPE. Team1. 
                                 Only for MONEYLINE bet type, for all other bet types this has to be TRUE.
     :param pitcher2_must_start: Baseball only. Refers to the pitcher for TEAM_TYPE. Team2. 
                                 Only for MONEYLINE bet type, for all other bet types this has to be TRUE.
     :param customer_reference: Reference for customer to use.
     :param session: requests session to be used.
     :return: bet success/failure.
     """
     unique_request_id = str(uuid.uuid4())
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("POST", method='/v2/bets/straight', data=params, session=session)
     return self.process_response(
         response.json(), resources.PlaceBetDetails, date_time_sent, datetime.datetime.utcnow()
     )
Exemplo n.º 2
0
 def get_bets(self,
              betids=None,
              betlist=None,
              from_date=None,
              to_date=None,
              session=None):
     """
     Get running bets or bets settled within the last 30 days.
     
     :param from_date: start date for bet query. Maximum 30 days between from_date and to_date. 
                       Required when betlist parameter is supplied.
     :param to_date: end date for bet query. to_date value is exclusive, meaning it cannot be equal to from_date.
                     Required when betlist parameter is supplied.
     :param betlist: type of bets to filter for, see pinnacle.enums.BetListType.
     :param betids: list of bet IDs, max 100, works for non settled bets and bets settled in the last 30 days.
     :param session: requests session to be used.
     :returns: All bets fitting the filtered arguments supplied. 
     """
     from_date = from_date.isoformat() if from_date else from_date
     to_date = to_date.isoformat() if to_date else to_date
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/bets',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.BetDetails, date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 3
0
 def get_bets(self, betids=None, betlist=None, unique_request_ids=None, from_date=None, to_date=None,
              bet_statuses=None, sort_dir=None, page_size=None, from_record=None, session=None):
     """
     Get running bets or bets settled within the last 30 days.
     
     :param from_date: start date for bet query. Maximum 30 days between from_date and to_date. 
                       Required when betlist parameter is supplied.
     :param to_date: end date for bet query. to_date value is exclusive, meaning it cannot be equal to from_date.
                     Required when betlist parameter is supplied.
     :param betlist: type of bets to filter for, see pinnacle.enums.BetListType.
     :param betids: list of bet IDs, max 100, works for non settled bets and bets settled in the last 30 days.
     :param unique_request_ids: list of uniqueRequestIds to query bets placed within the last 30 mins and straight bets only. 
                                If specified, is treated with highest priority, all other parameters are ignored. Maximum is 10 ids.
     :param bet_statuses: Type of bet statuse to filter for, see pinnacle.enums.BetStatusesType. 
                          This works only in conjustion with betlist, as additional filter. 
     :param sort_dir: Type of bet statuse to filter for, see pinnacle.enum.SortDirType. 
                      This works only in conjustion with betlist, as additional filter.
     :param page_size: Page size in case. Max is 1000. Respected only when querying by date range.
     :param from_record: Starting record (inclusive) of the result. Respected only when querying by date range. 
                         To fetch next page set it to toRecord+1
     :param session: requests session to be used.
     :returns: All bets fitting the filtered arguments supplied. 
     """
     from_date = from_date.strftime('%Y-%m-%d') if from_date is not None else from_date
     to_date = to_date.strftime('%Y-%m-%d') if to_date is not None else to_date
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET", method='v3/bets', params=params, session=session)
     return self.process_response(
         response.json(), resources.BetDetails, date_time_sent, datetime.datetime.utcnow()
     )
Exemplo n.º 4
0
 def place_special_bet(self,
                       line_id,
                       special_id,
                       contestant_id,
                       stake,
                       win_risk_stake=WinRiskType.Risk.value,
                       odds_format=OddsFormat.Decimal.value,
                       accept_better_line=Boolean.TRUE.value,
                       session=None):
     """
     Place special bet in the system.
     
     :param line_id: Line identification
     :param special_id: Special identification.
     :param contestant_id: Contestant identification.
     :param stake: Wagered amount in Clients currency.
     :param win_risk_stake: Whether the stake amount is risk or win amount
     :param odds_format: Bet is processed with this odds format.
     :param accept_better_line: Whether or not to accept a bet when there is a line change in favor of the client.
     :param session: requests session to be used.
     :return: bet success/failure.
     """
     unique_request_id = str(uuid.uuid4())
     params = {'bets': [clean_locals(locals())]}
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("POST",
                             method='v1/bets/special',
                             data=params,
                             session=session)
     return self.process_response(response.json().get('bets', []),
                                  resources.PlaceSpecialBetDetails,
                                  date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 5
0
 def get_fixtures(self,
                  sport_id,
                  league_ids=None,
                  since=None,
                  is_live=None,
                  event_ids=None,
                  session=None):
     """
     Get all unsettled fixtures for a given sport.
     
     :param sport_id: id of the sport.
     :param league_ids: list of league ids for given sport.
     :param since: Used to receive incremental updates. Use the value of last from previous fixtures response
     :param is_live: To retrieve ONLY live events set the value to islive =1. 
     :param event_ids: list of event ids to filter for.
     :param session: requests session to be used.
     :return: all non-settled events.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/fixtures',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.FixtureDetails, date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 6
0
 def get_special_fixtures(self,
                          sport_id,
                          league_ids=None,
                          category=None,
                          event_id=None,
                          special_id=None,
                          since=None,
                          session=None):
     """
     Get unsettled special fixtures for given sport.
     
     :param sport_id: id of the sport.
     :param league_ids: list of league ids for given sport.
     :param category: category of the special.
     :param event_id: id of the linked event.
     :param special_id: id of specific special to get.
     :param since: Used to receive incremental updates. Use the value of last from previous fixtures response
     :param session: requests session to be used.
     :return: all non-settled specials (contests)
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/fixtures/special',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.SpecialFixtureDetails,
                                  date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 7
0
 def get_line(self,
              sport_id,
              league_id,
              event_id,
              period_number,
              bet_type,
              team=None,
              side=None,
              handicap=None,
              odds_format=OddsFormat.Decimal.value,
              session=None):
     """
     Get latest odds for a line.
     
     :param sport_id: id of the sport to which the line belongs.
     :param league_id: id of the league to which the line belongs.
     :param event_id: id of the event to which the line belongs.
     :param period_number: This represents the period of the match. 
     :param bet_type: bet_type of the line, see pinnacle.enums.BetType
     :param team: Chosen team type. This is needed only for SPREAD, MONEYLINE and TEAM_TOTAL_POINTS bet types
     :param side: Chosen side. This is needed only for TOTAL_POINTS and TEAM_TOTAL_POINTS bet type
     :param handicap: This is needed for SPREAD, TOTAL_POINTS and TEAM_TOTAL_POINTS bet type
     :param odds_format: Format in which we return the odds. 
     :param session: requests session to be used. 
     :return: latest line.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/line',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.LineDetails, date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 8
0
 def get_special_odds(self,
                      sport_id,
                      league_ids=None,
                      special_id=None,
                      since=None,
                      odds_format=OddsFormat.Decimal.value,
                      session=None):
     """
     Get special odds for all non-settled events.
     
     :param sport_id: id of the sport.
     :param league_ids: list of league ids for given sport.
     :param special_id: id of specific special to filter for.
     :param odds_format: Format in which we return the odds. 
     :param since: Used to receive incremental updates. Use the value of last from previous fixtures response
     :param session: requests session to be used. 
     :return: special odds for all non-settled events.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/odds/special',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.OddsDetails, date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 9
0
    def get_leagues(self, sport_id, session=None):
        """
        Get leagues contained for a given sport.

        :param sport_id: id of the sport to get periods breakdown for.
        :param session: requests session to be used.
        :return: leagues for a given sport.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request("GET",
                                method='v2/leagues',
                                params=params,
                                session=session)
        return self.process_response(response.json().get('leagues', []),
                                     resources.LeagueDetails, date_time_sent,
                                     datetime.datetime.utcnow())
Exemplo n.º 10
0
 def get_inrunning(self, session=None):
     """
     Get all events that have a live status associated with them. 
     
     :param session: requests session to be used.
     :return: live events.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/inrunning',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.InRunningDetails,
                                  date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 11
0
 def get_bets(self, betids=None, betlist=None, unique_request_ids=None, from_date=None, to_date=None, session=None):
     """
     Get running bets or bets settled within the last 30 days.
     
     :param from_date: start date for bet query. Maximum 30 days between from_date and to_date. 
                       Required when betlist parameter is supplied.
     :param to_date: end date for bet query. to_date value is exclusive, meaning it cannot be equal to from_date.
                     Required when betlist parameter is supplied.
     :param betlist: type of bets to filter for, see pinnacle.enums.BetListType.
     :param betids: list of bet IDs, max 100, works for non settled bets and bets settled in the last 30 days.
     :param unique_request_ids: list of uniqueRequestIds to query bets placed within the last 30 mins and straight bets only. 
                                If specified, is treated with highest priority, all other parameters are ignored. Maximum is 10 ids.
     :param session: requests session to be used.
     :returns: All bets fitting the filtered arguments supplied. 
     """
     from_date = from_date.strftime('%Y-%m-%d') if from_date is not None else from_date
     to_date = to_date.strftime('%Y-%m-%d') if to_date is not None else to_date
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET", method='v2/bets', params=params, session=session)
     return self.process_response(
         response.json(), resources.BetDetails, date_time_sent, datetime.datetime.utcnow()
     )
Exemplo n.º 12
0
    def get_settled_special_fixtures(self,
                                     sport_id,
                                     league_ids=None,
                                     since=None,
                                     session=None):
        """
        Get special fixtures settled within the last 24 hours.

        :param sport_id: id of the sport.
        :param league_ids: list of league ids for given sport.
        :param since: Used to receive incremental updates. Use the value of last from previous fixtures response
        :param session: requests session to be used.
        :return: settled special fixtures.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request("GET",
                                method='v1/fixtures/special/settled',
                                params=params,
                                session=session)
        return self.process_response(response.json(),
                                     resources.SettledSpecialFixtureDetails,
                                     date_time_sent,
                                     datetime.datetime.utcnow())
Exemplo n.º 13
0
 def get_special_lines(self,
                       special_id,
                       contestant_id,
                       odds_format=OddsFormat.Decimal.value,
                       session=None):
     """
     Get latest special line.
     
     :param special_id: id of the special.
     :param contestant_id: id of the participant in the special.
     :param odds_format: Format in which we return the odds.
     :param session: requests session to be used. 
     :return: latest special line.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request("GET",
                             method='v1/line/special',
                             params=params,
                             session=session)
     return self.process_response(response.json(),
                                  resources.SpecialLineDetails,
                                  date_time_sent,
                                  datetime.datetime.utcnow())
Exemplo n.º 14
0
 def test_clean_locals(self, test_val=None, filter=123):
     params = clean_locals(locals())
     assert params == {'filter': 123}