How to use the betfairlightweight.parse.models.BetfairModel 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 / betfairlightweight / parse / apiparsebetting.py View on Github external
self.side = instruction.get('side')
        self.order_type = instruction.get('orderType')
        self.handicap = instruction.get('handicap')
        if 'limitOrder' in instruction:
            self.order = PlaceOrderLimit(instruction.get('limitOrder'))


class PlaceOrderLimit:

    def __init__(self, limit_order):
        self.persistence_type = limit_order.get('persistenceType')
        self.price = limit_order.get('price')
        self.size = limit_order.get('size')


class CancelAllOrders(BetfairModel):

    def __init__(self, date_time_sent, raw_response, result):
        super(CancelAllOrders, self).__init__(date_time_sent, raw_response)
        self.status = result.get('status')
        self.instruction_report = result.get('instructionReports')


class CancelOrder(Order):  # todo cancel all orders has no response?

    def __init__(self, date_time_sent, raw_response, result):
        super(CancelOrder, self).__init__(date_time_sent, raw_response, result)
        self.instruction_reports = [CancelOrderInstructionReports(order) for order in result.get('instructionReports')]


class CancelOrderInstructionReports:
github liampauling / betfair / betfairlightweight / parse / apiparsedata.py View on Github external
def __init__(self, date_time_sent, raw_response, market_type):
        super(MarketTypeResult, self).__init__(date_time_sent, raw_response)
        self.market_type = market_type.get('marketType')
        self.market_count = market_type.get('marketCount')


class CountryResult(BetfairModel):

    def __init__(self, date_time_sent, raw_response, country):
        super(CountryResult, self).__init__(date_time_sent, raw_response)
        self.country_code = country.get('countryCode')
        self.market_count = country.get('marketCount')


class VenueResult(BetfairModel):

    def __init__(self, date_time_sent, raw_response, venue):
        super(VenueResult, self).__init__(date_time_sent, raw_response)
        self.venue = venue.get('venue')
        self.market_count = venue.get('marketCount')


class MarketCatalogue(BetfairModel):

    def __init__(self, date_time_sent, raw_response, market_catalogue):
        super(MarketCatalogue, self).__init__(date_time_sent, raw_response)
        self.market_id = market_catalogue.get('marketId')
        self.market_name = market_catalogue.get('marketName')
        self.total_matched = market_catalogue.get('totalMatched')
        self.market_start_time = strp_betfair_time(market_catalogue.get('marketStartTime'))
        if 'competition' in market_catalogue:
github liampauling / betfair / betfairlightweight / parse / apiparsedata.py View on Github external
import datetime

from ..parse.models import BetfairModel
from ..utils import strp_betfair_time, price_check


class EventType:

    def __init__(self, event_type):
        self.id = event_type.get('id')
        self.name = event_type.get('name')


class EventTypeResult(BetfairModel):

    def __init__(self, date_time_sent, raw_response, event_type):
        super(EventTypeResult, self).__init__(date_time_sent, raw_response)
        self.market_count = event_type.get('marketCount')
        self.event_type = EventType(event_type.get('eventType'))


class CompetitionResult(BetfairModel):

    def __init__(self, date_time_sent, raw_response, competition):
        super(CompetitionResult, self).__init__(date_time_sent, raw_response)
        self.market_count = competition.get('marketCount')
        self.competition_region = competition.get('competitionRegion')
        self.competition = EventType(competition.get('competition'))
github liampauling / betfair / betfairlightweight / parse / apiparsescores.py View on Github external
class RaceStatus(BetfairModel):

    def __init__(self, date_time_sent, raw_response, result):
        super(RaceStatus, self).__init__(date_time_sent, raw_response)
        self.response_code = result.get('responseCode')
        self.race_id = result.get('raceId')
        self.meeting_id = result.get('meetingId')
        self.race_status = result.get('raceStatus')
        self.last_updated = result.get('lastUpdated')

    @property
    def race_status_description(self):
        return RaceStatusEnum[self.race_status].value


class Score(BetfairModel):

    def __init__(self, date_time_sent, raw_response, result):
        super(Score, self).__init__(date_time_sent, raw_response)
        self.result = result

        self.event_id = result.get('eventId')
        self.start_time = strp_betfair_time(result.get('startTime'))
        self.broadcast = Broadcast(result.get('broadcasts'))

        state = result.get('state')
        if state:
            event_type_id = state.get('eventTypeId')
            if event_type_id == 1:
                self.state = SoccerState(state)
            elif event_type_id == 2:
                self.state = TennisState(state)
github liampauling / betfair / betfairlightweight / parse / apiparsedata.py View on Github external
self.size_lapsed = order.get('sizeLapsed')
        self.size_matched = order.get('sizeMatched')
        self.size_remaining = order.get('sizeRemaining')
        self.size_voided = order.get('sizeVoided')
        self.status = order.get('status')


class RunnerBookMatch:

    def __init__(self, match):
        self.price = match.get('price')
        self.side = match.get('side')
        self.size = match.get('size')


class CurrentOrders(BetfairModel):

    def __init__(self, date_time_sent, raw_response, current_orders):
        super(CurrentOrders, self).__init__(date_time_sent, raw_response)
        self.more_available = current_orders.get('moreAvailable')
        self.orders = [CurrentOrdersOrder(order) for order in current_orders.get('currentOrders')]


class CurrentOrdersOrder:

    def __init__(self, order):
        self.bet_id = order.get('betId')
        self.average_price_matched = order.get('averagePriceMatched')
        self.bsp_liability = order.get('bspLiability')
        self.handicap = order.get('handicap')
        self.market_id = order.get('marketId')
        self.matched_date = strp_betfair_time(order.get('matchedDate'))
github liampauling / betfair / betfairlightweight / parse / apiparseaccount.py View on Github external
class AccountDetails(BetfairModel):

    def __init__(self, date_time_sent, raw_response, account_details):
        super(AccountDetails, self).__init__(date_time_sent, raw_response)
        self.country_code = account_details.get('countryCode')
        self.currency_code = account_details.get('currencyCode')
        self.discount_rate = account_details.get('discountRate')
        self.first_name = account_details.get('firstName')
        self.last_name = account_details.get('lastName')
        self.locale_code = account_details.get('localeCode')
        self.points_balance = account_details.get('pointsBalance')
        self.region = account_details.get('region')
        self.timezone = account_details.get('timezone')


class AccountStatement(BetfairModel):

    def __init__(self, date_time_sent, raw_response, account_statement):
        super(AccountStatement, self).__init__(date_time_sent, raw_response)
        self.more_available = account_statement.get('moreAvailable')
        self.account_statement = [AccountStatementStatement(statement)
                                  for statement in account_statement.get('accountStatement')]


class AccountStatementStatement:

    def __init__(self, statement):
        self.amount = statement.get('amount')
        self.balance = statement.get('balance')
        self.item_class = statement.get('itemClass')
        self.item_class_data = statement.get('itemClassData')
        self.item_date = strp_betfair_time(statement.get('itemDate'))
github liampauling / betfair / betfairlightweight / parse / apiparsescores.py View on Github external
import datetime

from ..parse.models import BetfairModel
from ..parse.enums import RaceStatusEnum
from ..utils import strp_betfair_time


class RaceStatus(BetfairModel):

    def __init__(self, date_time_sent, raw_response, result):
        super(RaceStatus, self).__init__(date_time_sent, raw_response)
        self.response_code = result.get('responseCode')
        self.race_id = result.get('raceId')
        self.meeting_id = result.get('meetingId')
        self.race_status = result.get('raceStatus')
        self.last_updated = result.get('lastUpdated')

    @property
    def race_status_description(self):
        return RaceStatusEnum[self.race_status].value


class Score(BetfairModel):
github liampauling / betfair / betfairlightweight / parse / apiparseaccount.py View on Github external
class AccountStatementLegacyData:

    def __init__(self, legacy_data):
        self.avg_price = legacy_data.get('avgPrice')
        self.bet_category_type = legacy_data.get('betCategoryType')
        self.bet_size = legacy_data.get('betSize')
        self.bet_type = legacy_data.get('betType')
        self.event_id = legacy_data.get('eventId')
        self.event_type_id = legacy_data.get('eventTypeId')
        self.full_market_name = legacy_data.get('fullMarketName')
        self.gross_bet_amount = legacy_data.get('grossBetAmount')


class CurrencyRate(BetfairModel):

    def __init__(self, date_time_sent, raw_response, currency_rate):
        super(CurrencyRate, self).__init__(date_time_sent, raw_response)
        self.currency_code = currency_rate.get('currencyCode')
        self.rate = currency_rate.get('rate')


class TransferFunds(BetfairModel):

    def __init__(self, date_time_sent, raw_response, transfer_funds):
        super(TransferFunds, self).__init__(date_time_sent, raw_response)
        self.transaction_id = transfer_funds.get('transactionId')
github liampauling / betfair / betfairlightweight / parse / apiparsedata.py View on Github external
def __init__(self, date_time_sent, raw_response, competition):
        super(CompetitionResult, self).__init__(date_time_sent, raw_response)
        self.market_count = competition.get('marketCount')
        self.competition_region = competition.get('competitionRegion')
        self.competition = EventType(competition.get('competition'))


class TimeRange:

    def __init__(self, time_range):
        self._from = strp_betfair_time(time_range.get('from'))
        self.to = strp_betfair_time(time_range.get('to'))


class TimeRangeResult(BetfairModel):

    def __init__(self, date_time_sent, raw_response, time_range):
        super(TimeRangeResult, self).__init__(date_time_sent, raw_response)
        self.market_count = time_range.get('marketCount')
        self.time_range = TimeRange(time_range.get('timeRange'))


class Event:

    def __init__(self, event):
        self.id = event.get('id')
        self.open_date = strp_betfair_time(event.get('openDate'))
        self.time_zone = event.get('timezone')
        self.country_code = event.get('countryCode')
        self.name = event.get('name')
        self.venue = event.get('venue')
github liampauling / betfair / betfairlightweight / parse / apiparsebetting.py View on Github external
from ..parse.models import BetfairModel
from ..utils import strp_betfair_time


class Order(BetfairModel):

    def __init__(self, date_time_sent, raw_response, result):
        super(Order, self).__init__(date_time_sent, raw_response)
        self.market_id = result.get('marketId')
        self.status = result.get('status')
        self.customer_ref = result.get('customerRef')
        self.error_code = result.get('errorCode')


class PlaceOrder(Order):

    def __init__(self, date_time_sent, raw_response, result):
        super(PlaceOrder, self).__init__(date_time_sent, raw_response, result)
        self.instruction_reports = [PlaceOrderInstructionReports(order) for order in result.get('instructionReports')]