How to use the betfairlightweight.filters.market_filter function in betfairlightweight

To help you get started, we’ve selected a few betfairlightweight examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liampauling / betfair / tests / unit / test_filters.py View on Github external
def test_market_filter(self):
        response = market_filter()
        assert response == {}

        response = market_filter(market_ids=['1.123'])
        assert response == {'marketIds': ['1.123']}
github liampauling / betfair / tests / unit / test_filters.py View on Github external
def test_market_filter(self):
        response = market_filter()
        assert response == {}

        response = market_filter(market_ids=['1.123'])
        assert response == {'marketIds': ['1.123']}
github liampauling / betfair / betfairlightweight / endpoints / betting.py View on Github external
    def list_competitions(self, filter=market_filter(), locale=None, session=None, lightweight=None):
        """
        Returns a list of Competitions (i.e., World Cup 2013) associated with
        the markets selected by the MarketFilter.

        :param dict filter: The filter to select desired markets
        :param str locale: The language used for the response
        :param requests.session session: Requests session object
        :param bool lightweight: If True will return dict not a resource

        :rtype: list[resources.CompetitionResult]
        """
        params = clean_locals(locals())
        method = '%s%s' % (self.URI, 'listCompetitions')
        (response, elapsed_time) = self.request(method, params, session)
        return self.process_response(response, resources.CompetitionResult, elapsed_time, lightweight)
github liampauling / betfair / examples / exampleone.py View on Github external
import betfairlightweight
from betfairlightweight import filters


# create trading instance
trading = betfairlightweight.APIClient('username', 'password', app_key='appKey')

# login
trading.login()

# make event type request to find horse racing event type
horse_racing_event_type_id = trading.betting.list_event_types(
    filter=filters.market_filter(
        text_query='Horse Racing'
    )
)

# returns one result
print(horse_racing_event_type_id)

for event_type in horse_racing_event_type_id:
    # prints id, name and market count
    print(
        event_type.event_type.id, event_type.event_type.name, event_type.market_count
    )
    horse_racing_id = event_type.event_type.id

    # list all horse racing market catalogues
    market_catalogues = trading.betting.list_market_catalogue(
github liampauling / betfair / betfairlightweight / endpoints / betting.py View on Github external
    def list_market_catalogue(self, filter=market_filter(), market_projection=None, sort=None, max_results=1,
                              locale=None, session=None, lightweight=None):
        """
        Returns a list of information about published (ACTIVE/SUSPENDED) markets
        that does not change (or changes very rarely).

        :param dict filter: The filter to select desired markets
        :param list market_projection: The type and amount of data returned about the market
        :param str sort: The order of the results
        :param int max_results: Limit on the total number of results returned, must be greater
        than 0 and less than or equal to 10000
        :param str locale: The language used for the response
        :param requests.session session: Requests session object
        :param bool lightweight: If True will return dict not a resource

        :rtype: list[resources.MarketCatalogue]
        """
github liampauling / betfair / betfairlightweight / endpoints / betting.py View on Github external
    def list_events(self, filter=market_filter(), locale=None, session=None, lightweight=None):
        """
        Returns a list of Events (i.e, Reading vs. Man United) associated with
        the markets selected by the MarketFilter.

        :param dict filter: The filter to select desired markets
        :param str locale: The language used for the response
        :param requests.session session: Requests session object
        :param bool lightweight: If True will return dict not a resource

        :rtype: list[resources.EventResult]
        """
        params = clean_locals(locals())
        method = '%s%s' % (self.URI, 'listEvents')
        (response, elapsed_time) = self.request(method, params, session)
        return self.process_response(response, resources.EventResult, elapsed_time, lightweight)
github liampauling / flumine / flumine / worker.py View on Github external
def poll_market_catalogue(context: dict, flumine) -> None:
    client = flumine.client
    live_markets = list(flumine.markets.markets.keys())
    for market_ids in chunks(live_markets, 25):
        try:
            market_catalogues = client.betting_client.betting.list_market_catalogue(
                filter=filters.market_filter(market_ids=market_ids),
                max_results=25,
                market_projection=[
                    "COMPETITION",
                    "EVENT",
                    "EVENT_TYPE",
                    "RUNNER_DESCRIPTION",
                    "RUNNER_METADATA",
                    "MARKET_START_TIME",
                    "MARKET_DESCRIPTION",
                ],
            )
        except BetfairError as e:
            logger.error(
                "poll_market_catalogue error",
                exc_info=True,
                extra={"trading_function": "list_market_catalogue", "response": e},
github liampauling / betfair / betfairlightweight / endpoints / betting.py View on Github external
    def list_time_ranges(self, filter=market_filter(), granularity='DAYS', session=None, lightweight=None):
        """
        Returns a list of time ranges in the granularity specified in the
        request (i.e. 3PM to 4PM, Aug 14th to Aug 15th) associated with
        the markets selected by the MarketFilter.

        :param dict filter: The filter to select desired markets
        :param str granularity: The granularity of time periods that correspond
        to markets selected by the market filter
        :param requests.session session: Requests session object
        :param bool lightweight: If True will return dict not a resource

        :rtype: list[resources.TimeRangeResult]
        """
        params = clean_locals(locals())
        method = '%s%s' % (self.URI, 'listTimeRanges')
        (response, elapsed_time) = self.request(method, params, session)
github liampauling / betfair / betfairlightweight / endpoints / betting.py View on Github external
    def list_market_types(self, filter=market_filter(), locale=None, session=None, lightweight=None):
        """
        Returns a list of market types (i.e. MATCH_ODDS, NEXT_GOAL) associated with
        the markets selected by the MarketFilter.

        :param dict filter: The filter to select desired markets
        :param str locale: The language used for the response
        :param requests.session session: Requests session object
        :param bool lightweight: If True will return dict not a resource

        :rtype: list[resources.MarketTypeResult]
        """
        params = clean_locals(locals())
        method = '%s%s' % (self.URI, 'listMarketTypes')
        (response, elapsed_time) = self.request(method, params, session)
        return self.process_response(response, resources.MarketTypeResult, elapsed_time, lightweight)